無意中翻到這篇問答LINK,發現了Sample的用法
如果想讓Animation在編輯器狀態下預覽,也可以用這個接口
當你想要直接獲得動畫的運行結果,而不是等幀數執行到這,這時候就得調用Sample:
void LateUpdate() { Debug.Log("frame: " + Time.frameCount + " position: " + transform.position); var state = anim["Anim2"]; state.normalizedTime = 5f; anim.Sample(); Debug.Log("Sampled frame: " + Time.frameCount + " position: " + transform.position); }