如何在gui按钮中延迟动画?

时间:2015-08-11 01:38:35

标签: c# animation unity3d augmented-reality

我有一个项目AR,我有3个(Pa,Pa2,Pa3)动画,当我按下gui按钮时动画播放,问题是我的动画将一起播放,我必须延迟我的动画(在此案例是Pa3,见下面的代码),有人可以帮帮我吗?这是我的代码

使用UnityEngine; 使用System.Collections;

公共课Play:MonoBehaviour {

public ParticleSystem Pa;   //my animation
public ParticleSystem Pa2;
public GameObject Pa3;


void OnGUI(){


    if(GUI.Button(new Rect(8*Screen.width/10 ,Screen.height/10, Screen.width/10,Screen.height/10),"Play")){

        Pa.Play();
        Pa2.Play();

        Pa3.animation.Play("cloud");
        Pa3.animation.wrapMode = WrapMode.Once;
        }
    }

}

1 个答案:

答案 0 :(得分:0)

试试这个:

StartCoroutine(PlayAnimation())
IEnumerator PlayAnimation() {
    Pa.play();
    yield return new WaitForSeconds(Pa.length);
    Pa2.play();
    yield return new WaitForSeconds(Pa2.length);
    Pa3.play();
}