fjkrl 发表于 2013-3-4 12:16

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

Unity3D点击照片切换照片,不点击按时间间隔切换照片代码using UnityEngine;
using System.Collections;

public class change : MonoBehaviour
{

public Texture[] picture;
public int i = 0;
public float waitTime = 2;
private float currentTime = 0;
void Start()
{
i = 0;
gameObject.renderer.material.mainTexture = picture;
currentTime = Time.time;
}
// Update is called once per frame
void Update()
{

if (Time.time > (currentTime + waitTime))
{
if (i < (picture.Length -1))
{
i++;
}
else
{
i = 0;
}

currentTime = Time.time;

}

gameObject.renderer.material.mainTexture = picture;
}

void OnGUI()
{
if (GUILayout.Button("Next"))
{
currentTime = Time.time;
if (i < (picture.Length - 1))
{
i++;
}
else
{
i = 0;
}
}
}
}

悠走 发表于 2013-7-15 17:23

{:5_412:}{:5_412:}{:5_412:}谢谢楼主

sherolyll 发表于 2014-5-17 02:52

怎么我测试有问题呢

fu1393391287 发表于 2017-3-9 19:44

很不错

brokenwing 发表于 2017-3-9 19:15

真心顶

seungsoo 发表于 2017-3-9 19:41

说的非常好

xiaosi1278 发表于 2017-3-9 19:37

不错不错

brokenwing 发表于 2017-3-9 19:03

LZ真是人才

jia1009 发表于 2017-3-19 19:56

很不错

cvadhl 发表于 2017-3-19 20:22

楼主是超人
页: [1]
查看完整版本: Unity3D点击照片切换照片,不点击按时间间隔切换照片代码