【问题标题】:how to delay animation in gui button?如何延迟gui按钮中的动画?
【发布时间】:2015-08-11 01:38:34
【问题描述】:

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

使用 UnityEngine; 使用 System.Collections;

公共类游戏: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;
        }
    }

}

【问题讨论】:

    标签: c# animation unity3d augmented-reality


    【解决方案1】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多