由於標題指出動畫未播放。告訴它玩的線在協同程序中,代碼在waitfreesconds(3f)之前。統一動畫從協同程序中播放
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Play : MonoBehaviour {
public Animator AnimatorRef;
// Use this for initialization
void Start() {
if (AnimatorRef == null)
{
AnimatorRef = GetComponent<Animator>();
}
}
public void PlayGame()
{
StartCoroutine(TitlePlay());
Debug.Log("playing");
}
IEnumerator TitlePlay()
{
Debug.Log("playing1");
AnimatorRef.SetBool("Enlarge", true);
yield return new WaitForSeconds(3f);
Debug.Log("playing2");
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
它抓住動畫師參考罰款和所有三個評論顯示。
所以,你說當你在'PlayGame'中直接調用'AnimatorRef.SetBool(「Enlarge」,true);'時,它可以正常工作? – UnholySheep