using UnityEngine;
using System.Collections;
public class SwitchbackGroundimage : MonoBehaviour {
//计数器
public Texture[] image;
private int index=0;
//public int number = 3;
private float _time;
private float _endTime;
// Use this for initialization
void Start () {
//开始时刻的时间
_time = Time.time;
}
// Update is called once per frame
void Update () {
//Debug.Log(Time.time);
//现在的时间
_endTime = Time.time;
//开始时刻 到现在的时间差值
float timeOffset = _endTime- _time;
if (timeOffset >2) {
if (index <image.Length) {
guiTexture.texture= image[index];
index+=1;
}else {
index = 0;
guiTexture.texture = image[index];
}
//记下换好下一张图片的时间
_time = Time.time;
}
}
}