private void EnsureDefaultStateExists() { if (m_Playable != null && m_Clip != null && m_Playable.GetState(kDefaultStateName) == null) { m_Playable.AddClip(m_Clip, kDefaultStateName); Kick(); } }
private void Initialize() { if (m_Initialized) { return; } m_Animator = GetComponent <Animator>(); m_Animator.updateMode = m_AnimatePhysics ? AnimatorUpdateMode.AnimatePhysics : AnimatorUpdateMode.Normal; m_Animator.cullingMode = m_CullingMode; m_Graph = PlayableGraph.Create(); m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime); SimpleAnimationPlayable template = new SimpleAnimationPlayable(); var playable = ScriptPlayable <SimpleAnimationPlayable> .Create(m_Graph, template, 1); m_Playable = playable.GetBehaviour(); m_Playable.onDone += OnPlayableDone; if (m_States == null) { m_States = new EditorState[1]; m_States[0] = new EditorState(); m_States[0].defaultState = true; m_States[0].name = "Default"; } if (m_States != null) { foreach (var state in m_States) { if (state.clip) { m_Playable.AddClip(state.clip, state.name); } } } EnsureDefaultStateExists(); AnimationPlayableUtilities.Play(m_Animator, m_Playable.playable, m_Graph); Play(); Kick(); m_Initialized = true; }