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;
}
}
}
}
{:5_412:}{:5_412:}{:5_412:}谢谢楼主 怎么我测试有问题呢 很不错 真心顶 说的非常好 不错不错 LZ真是人才 很不错 楼主是超人
页:
[1]