NGUI UITexture 设置帧动画闪烁(不显示)问题
解决:.enabled = false;
.enabled = true;
示例代码:
public class TextureAnimation : MonoBehaviour {
public Texture[] TextureAll;
private UITexture curtexture;
public float speed = 0.01f;
private float timer = 0;
private int index = 0;
// Use this for initialization
void Start () {
curtexture = GetComponent<UITexture> ();
}
// Update is called once per frame
void Update () {
play ();
}
private void play(){
if(TextureAll == null | TextureAll.Length<1){
return;
}
timer += Time.deltaTime;
if (timer > speed) {
timer = 0;
if (index < (TextureAll.Length - 1)) {
index++;
} else {
index = 0;
}
curtexture.enabled = false;
curtexture.mainTexture = TextureAll [index];
curtexture.enabled = true;
}
}
public void reset(){
timer = 0;
index = 0;
curtexture.mainTexture = TextureAll[0];
}
}