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];
}
}
本文介绍了一种使用Unity结合NGUI实现帧动画的方法。通过禁用和启用UITexture组件来解决帧动画偶尔出现的闪烁问题。示例代码展示了如何循环播放一系列纹理帧,并在每帧之间设置延迟。
4814

被折叠的 条评论
为什么被折叠?



