public override Playable CreatePlayable(PlayableGraph graph, GameObject go)
        {
            bool autoRebalance = false;
            bool createOutputs = graph.GetPlayableCount() == 0;
            ScriptPlayable <TimelinePlayable> playable = TimelinePlayable.Create(graph, this.GetOutputTracks(), go, autoRebalance, createOutputs);

            return((!playable.IsValid <ScriptPlayable <TimelinePlayable> >()) ? Playable.Null : playable);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an instance of the timeline
        /// </summary>
        /// <param name="graph">PlayableGraph that will own the playable</param>
        /// <param name="go">The gameobject that triggered the graph build</param>
        /// <returns>The Root Playable of the Timeline</returns>
        public override Playable CreatePlayable(PlayableGraph graph, GameObject go)
        {
            bool autoRebalanceTree = false;

            #if UNITY_EDITOR
            autoRebalanceTree = true;
            #endif

            // only create outputs if we are not nested
            bool createOutputs = graph.GetPlayableCount() == 0;
            var  timeline      = TimelinePlayable.Create(graph, GetOutputTracks(), go, autoRebalanceTree, createOutputs);
            timeline.SetPropagateSetTime(true);
            return(timeline.IsValid() ? timeline : Playable.Null);
        }
Esempio n. 3
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;
    }