Solution for Animator become uninitialized, after SetGenericBinding()-> and removed from timeline.

Solution for Animator become uninitialized, after SetGenericBinding()-> and removed from timeline.

During the development on 用 TimeLine 來實作跳越障礙物, I discover the Animator will be uninitialized.
waiting the answer on Forum, but the solution I made up was manually re-initialize all private reference and avoid keeping the long term reference on SMB,

here is the sample code to detect Animator become uninitialized.

private bool m_AnimationDirty = false;
private void Update()
{
	if (!m_AnimationDirty && !animator.isInitialized)
	{
		m_AnimationDirty = true;
		Debug.LogWarning("Animator dirty", animator);
	}
	else if (m_AnimationDirty && animator.isInitialized)
	{
		m_AnimationDirty = false;
		ReInitSMB(); // reinitialize reference right here.
		Debug.Log("Animator Re-init SMB reference.", animator);
	}
}

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

*

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料