Exemple #1
0
    // 初始化
    private void Initialize()
    {
        if (m_Initialized)
        {
            return;
        }

        // 设置Animator
        m_Animator             = GetComponent <Animator>();
        m_Animator.updateMode  = m_AnimatePhysics ? AnimatorUpdateMode.AnimatePhysics : AnimatorUpdateMode.Normal;
        m_Animator.cullingMode = m_CullingMode;

        // 创建PlayableGraph
        m_Graph = PlayableGraph.Create();
        m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);

        // 创建ScriptPlayable<SimpleAnimationPlayable>
        SimpleAnimationPlayable template = new SimpleAnimationPlayable();
        var playable = ScriptPlayable <SimpleAnimationPlayable> .Create(m_Graph, template, 1);

        m_Playable         = playable.GetBehaviour();
        m_Playable.onDone += OnPlayableDone;

        // 如果没有EditorState
        // 设置一个
        if (m_States == null)
        {
            m_States    = new EditorState[1];
            m_States[0] = new EditorState();
            m_States[0].defaultState = true;
            m_States[0].name         = "Default";
        }


        // 根据编辑器上设置
        // 在SimpleAnimationPlayable上
        // 添加Clip
        if (m_States != null)
        {
            foreach (var state in m_States)
            {
                if (state.clip)
                {
                    m_Playable.AddClip(state.clip, state.name);
                }
            }
        }

        // 创建默认的播放状态Default
        EnsureDefaultStateExists();

        // Q: ??
        AnimationPlayableUtilities.Play(m_Animator, m_Playable.playable, m_Graph);

        Play();
        Kick();
        m_Initialized = true;
    }
Exemple #2
0
    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();

        Debug.Log(m_Graph.GetPlayableCount());

        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;
    }
    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);
        // 先自行new一個出來再當作template塞進Create方法(應該是為了確保Constructor執行)
        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();

        // 綁定m_Aniamtor採用起點為m_Playable的graph(懶人寫法不需要再自行處理PlayableOutput)
        AnimationPlayableUtilities.Play(m_Animator, m_Playable.playable, m_Graph);
        Play();
        Kick();
        m_Initialized = true;
    }
Exemple #4
0
 public IStateEnumerable(SimpleAnimationPlayable owner)
 {
     m_Owner = owner;
 }
Exemple #5
0
 public IStateEnumerator(SimpleAnimationPlayable owner)
 {
     m_Owner   = owner;
     m_Version = m_Owner.StatesVersion;
     Reset();
 }
 public StateHandle(SimpleAnimationPlayable s, int index, Playable target)
 {
     m_Parent = s;
     m_Index  = index;
     m_Target = target;
 }