2017-10-28 130 views
0

我試着在我的動畫完成播放後開始一個協調例程。Unity - 等到動畫完成

我想它是這樣的:

... 

while (animCamera.isPlaying) { 
    new WaitForSeconds(1); 
} 

StartCoroutine(LoadAsync(sceneName, sliderLoadbar, sliderLoadbarText)); 

但這儘快進入while循環崩潰了一段時間後,我的統一,甚至我的瀏覽器和我團結stucks。

我該如何解決這個問題?

+1

語法'收率返回新WaitForSeconds(1)'; – Hellium

+1

但是你可能感興趣:'yield return new WaitUntil((()=> animCamera.isPlaying);'或者[狀態機行爲](https://unity3d.com/fr/learn/tutorials/modules/beginner/ 5-pre-order-beta/state-machine-behaviors) – Hellium

+0

不錯,看起來很有前途,但是我的嘗試失敗了。 Unity不會凍結或崩潰,但沒有任何反應,並且遊戲陷入困境。 – Black

回答

3
在你的動畫遊戲物體的動畫標籤

建立在動畫的最後一幀的情況下,附着上面的腳本這個遊戲物體,並選擇您想在它的結束運行的方法

enter image description here

除去協程,只是作簡單的方法

public void LoadScene() 
{ 
    LoadAsync(sceneName, sliderLoadbar, sliderLoadbarText) 
}