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 Playable CreateTrackPlayable(PlayableGraph graph, Playable timelinePlayable, TrackAsset track, GameObject go, bool createOutputs)
        {
            Playable result;

            TimelinePlayable.ConnectionCache connectionCache;
            if (!track.compilable)
            {
                result = timelinePlayable;
            }
            else if (this.m_PlayableCache.TryGetValue(track, out connectionCache))
            {
                result = connectionCache.playable;
            }
            else if (track.get_name() == "root")
            {
                result = timelinePlayable;
            }
            else
            {
                TrackAsset trackAsset = track.parent as TrackAsset;
                Playable   playable   = (!(trackAsset != null)) ? timelinePlayable : this.CreateTrackPlayable(graph, timelinePlayable, trackAsset, go, createOutputs);
                Playable   playable2  = TimelinePlayable.CreatePlayableGraph(graph, track, go, this.m_IntervalTree);
                bool       flag       = false;
                if (!PlayableExtensions.IsValid <Playable>(playable2))
                {
                    throw new InvalidOperationException(string.Concat(new object[]
                    {
                        track.get_name(),
                        "(",
                        track.GetType(),
                        ") did not produce a valid playable. Use the compilable property to indicate whether the track is valid for processing"
                    }));
                }
                if (PlayableExtensions.IsValid <Playable>(playable) && PlayableExtensions.IsValid <Playable>(playable2))
                {
                    int inputCount = PlayableExtensions.GetInputCount <Playable>(playable);
                    PlayableExtensions.SetInputCount <Playable>(playable, inputCount + 1);
                    flag = graph.Connect <Playable, Playable>(playable2, 0, playable, inputCount);
                    PlayableExtensions.SetInputWeight <Playable>(playable, inputCount, 1f);
                }
                if (createOutputs && flag)
                {
                    this.CreateTrackOutput(graph, track, playable, PlayableExtensions.GetInputCount <Playable>(playable) - 1);
                }
                this.CacheTrack(track, playable2, (!flag) ? -1 : (PlayableExtensions.GetInputCount <Playable>(playable) - 1), playable);
                result = playable2;
            }
            return(result);
        }
Esempio n. 4
0
        private void CreateTrackOutput(PlayableGraph graph, TrackAsset track, Playable playable, int port)
        {
            if (!track.isSubTrack)
            {
                IEnumerable <PlayableBinding> outputs = track.outputs;
                foreach (PlayableBinding binding in outputs)
                {
                    switch (binding.streamType)
                    {
                    case DataStreamType.Animation:
                    {
                        AnimationPlayableOutput animationPlayableOutput = AnimationPlayableOutput.Create(graph, binding.streamName, null);
                        TimelinePlayable.SetPlayableOutputParameters <AnimationPlayableOutput>(animationPlayableOutput, playable, port, binding);
                        this.EvaluateWeightsForAnimationPlayableOutput(track, animationPlayableOutput);
                        break;
                    }

                    case DataStreamType.Audio:
                    {
                        AudioPlayableOutput output = AudioPlayableOutput.Create(graph, binding.streamName, null);
                        TimelinePlayable.SetPlayableOutputParameters <AudioPlayableOutput>(output, playable, port, binding);
                        break;
                    }

                    case DataStreamType.Texture:
                        goto IL_B8;

                    case DataStreamType.None:
                    {
                        ScriptPlayableOutput output2 = ScriptPlayableOutput.Create(graph, binding.streamName);
                        TimelinePlayable.SetPlayableOutputParameters <ScriptPlayableOutput>(output2, playable, port, binding);
                        break;
                    }

                    default:
                        goto IL_B8;
                    }
                    continue;
IL_B8:
                    throw new NotImplementedException("Unsupported stream type");
                }
            }
        }