static public void Reg(UpdateObject pobj) { List <UpdateObject> towner = null; switch (pobj.updateType) { case AnimatorUpdateMode.Normal: towner = Instance.lateUpdataList; break; case AnimatorUpdateMode.AnimatePhysics: towner = Instance.fixedUpdataList; break; case AnimatorUpdateMode.UnscaledTime: towner = Instance.unscaleUpdataList; break; default: Debug.LogError("erro animatorUpdateode"); return; } if (pobj.owner != towner) { pobj.owner?.Remove(pobj); pobj.owner = towner; towner.Add(pobj); } }
static public void UnReg(UpdateObject pobj) { if (pobj.owner != null) { pobj.owner.Remove(pobj); } }
private void Initialize() { if (m_IsInitialized) { return; } m_Animator = GetComponent <Animator>(); if (m_Animator != null) { Destroy(m_Animator); } m_Animator = gameObject.AddComponent <Animator>(); m_Graph = PlayableGraph.Create(); m_Graph.SetTimeUpdateMode(DirectorUpdateMode.Manual); m_StateController = new PlayableStateController(m_Graph); var template = new PlayableAmimatorDriver(); template.Initialize(m_Graph, m_StateController); m_OutputPlayable = ScriptPlayable <PlayableAmimatorDriver> .Create(m_Graph, template, 1); AnimationPlayableUtilities.Play(m_Animator, m_OutputPlayable, m_Graph); m_Graph.Stop(); updateObject = new UpdateObject(this, UpdateGraph, mode); PlayableUpdateManager.Reg(updateObject); m_IsInitialized = true; }