找回密码
 立即注册
楼主: fjkrl

Unity3D点击照片切换照片,不点击按时间间隔切换照片代码

  [复制链接]
发表于 2013-3-4 12:16 | 显示全部楼层 |阅读模式
Unity3D点击照片切换照片,不点击按时间间隔切换照片代码
  1. using UnityEngine;
  2. using System.Collections;

  3. public class change : MonoBehaviour
  4. {

  5. public Texture[] picture;
  6. public int i = 0;
  7. public float waitTime = 2;
  8. private float currentTime = 0;
  9. void Start()
  10. {
  11. i = 0;
  12. gameObject.renderer.material.mainTexture = picture;
  13. currentTime = Time.time;
  14. }
  15. // Update is called once per frame
  16. void Update()
  17. {

  18. if (Time.time > (currentTime + waitTime))
  19. {
  20. if (i < (picture.Length -1))
  21. {
  22. i++;
  23. }
  24. else
  25. {
  26. i = 0;
  27. }

  28. currentTime = Time.time;

  29. }

  30. gameObject.renderer.material.mainTexture = picture;
  31. }

  32. void OnGUI()
  33. {
  34. if (GUILayout.Button("Next"))
  35. {
  36. currentTime = Time.time;
  37. if (i < (picture.Length - 1))
  38. {
  39. i++;
  40. }
  41. else
  42. {
  43. i = 0;
  44. }
  45. }
  46. }
  47. }
复制代码

评分

参与人数 1鲜花 +2 收起 理由
sherolyll + 2 赞一个!

查看全部评分

发表于 2013-7-15 17:23 | 显示全部楼层
{:5_412:}{:5_412:}{:5_412:}谢谢楼主
发表于 2014-5-17 02:52 | 显示全部楼层
怎么我测试有问题呢
发表于 2017-3-9 19:44 | 显示全部楼层
很不错
发表于 2017-3-9 19:15 | 显示全部楼层
真心顶
发表于 2017-3-9 19:41 | 显示全部楼层
说的非常好
发表于 2017-3-9 19:37 | 显示全部楼层
不错不错
发表于 2017-3-9 19:03 | 显示全部楼层
LZ真是人才
发表于 2017-3-19 19:56 | 显示全部楼层
很不错
发表于 2017-3-19 20:22 | 显示全部楼层
楼主是超人
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-6-3 23:53 , Processed in 0.091820 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表