コード例 #1
0
        public sealed override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
        {
            ScriptPlayable <ArgumentPlayableBehaviour> playable = ScriptPlayable <ArgumentPlayableBehaviour> .Null;
            ScriptPlayable <ArgumentPlayableBehaviour> templete = ScriptPlayable <ArgumentPlayableBehaviour> .Null;

            for (int i = 0; i < graph.GetRootPlayableCount(); i++)
            {
                if (graph.GetRootPlayable(i).GetPlayableType().IsTypeOrSubTypeOf(typeof(ArgumentPlayableBehaviour)))
                {
                    templete = (ScriptPlayable <ArgumentPlayableBehaviour>)graph.GetRootPlayable(i);
                }
            }
            OnBeforeCreateArgumentPlayable(graph, owner);
            if (!templete.Equals(playable))
            {
                playable = (ScriptPlayable <ArgumentPlayableBehaviour>)OnCreateArgumentPlayable(graph, owner);
                ArgumentPlayableBehaviour behaviour = playable.GetBehaviour();
                director                = owner.GetComponent <PlayableDirector>();
                timeline                = (TimelineAsset)director.playableAsset;
                trackAsset              = templete.GetBehaviour().trackAsset;
                timelineClip            = trackAsset.FindTimelineClip(this);
                genericBindingObject    = director.GetGenericBinding(trackAsset);
                behaviour.playableAsset = this;
                OnAfterCreateArgumentPlayable(graph, owner, playable);
            }
            return(playable);
        }
コード例 #2
0
ファイル: PlayAnimation.cs プロジェクト: NibbleByte/DevLocker
        public void Play()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            var playable = _playableGraph.GetRootPlayable(0);

            playable.Play();
            playable.SetTime(0);
        }
 public override void ProcessFrame(Playable playable, FrameData info, object playerData)
 {
     //IL_000f: Unknown result type (might be due to invalid IL or missing references)
     //IL_0010: Unknown result type (might be due to invalid IL or missing references)
     //IL_0015: Unknown result type (might be due to invalid IL or missing references)
     //IL_0019: Unknown result type (might be due to invalid IL or missing references)
     //IL_006a: Unknown result type (might be due to invalid IL or missing references)
     //IL_00ac: Unknown result type (might be due to invalid IL or missing references)
     //IL_00b3: Unknown result type (might be due to invalid IL or missing references)
     //IL_00ba: Unknown result type (might be due to invalid IL or missing references)
     //IL_00bf: Unknown result type (might be due to invalid IL or missing references)
     //IL_00c7: Unknown result type (might be due to invalid IL or missing references)
     //IL_00f6: Unknown result type (might be due to invalid IL or missing references)
     //IL_013b: Unknown result type (might be due to invalid IL or missing references)
     if (!(null == m_characterObject))
     {
         PlayableGraph graph = PlayableExtensions.GetGraph <Playable>(playable);
         double        time  = PlayableExtensions.GetTime <Playable>(graph.GetRootPlayable(0));
         foreach (TimelineClip clip in m_clips)
         {
             double start = clip.get_start();
             if (time < start)
             {
                 if (clip.IsPreExtrapolatedTime(time))
                 {
                     CharacterObjectColorModifierPlayableAsset characterObjectColorModifierPlayableAsset = (CharacterObjectColorModifierPlayableAsset)clip.get_asset();
                     m_characterObject.SetColorModifier(characterObjectColorModifierPlayableAsset.startColor);
                     m_currentClip = characterObjectColorModifierPlayableAsset;
                     return;
                 }
             }
             else
             {
                 double end = clip.get_end();
                 if (time <= end)
                 {
                     CharacterObjectColorModifierPlayableAsset characterObjectColorModifierPlayableAsset2 = (CharacterObjectColorModifierPlayableAsset)clip.get_asset();
                     float num           = Mathf.InverseLerp((float)start, (float)end, (float)time);
                     Color colorModifier = Color.Lerp(characterObjectColorModifierPlayableAsset2.startColor, characterObjectColorModifierPlayableAsset2.endColor, num);
                     m_characterObject.SetColorModifier(colorModifier);
                     m_currentClip = characterObjectColorModifierPlayableAsset2;
                     return;
                 }
                 if (clip.IsPostExtrapolatedTime(time))
                 {
                     CharacterObjectColorModifierPlayableAsset characterObjectColorModifierPlayableAsset3 = (CharacterObjectColorModifierPlayableAsset)clip.get_asset();
                     m_characterObject.SetColorModifier(characterObjectColorModifierPlayableAsset3.endColor);
                     m_currentClip = characterObjectColorModifierPlayableAsset3;
                     return;
                 }
             }
         }
         if (null != m_currentClip)
         {
             m_characterObject.SetColorModifier(m_currentClip.endColor);
             m_currentClip = null;
         }
     }
 }
コード例 #4
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        if (m_textBoxRef == null)
        {
            m_textBoxRef = playerData as TextBoxRef;
        }

        if (!m_textBoxRef)
        {
            return;
        }

        if (Application.isPlaying && began == false)
        {
            if (m_textBoxRef.dialogueRunner.isDialogueRunning == false)
            {
                began = true;
                Debug.Log("<color=green>TEXTBOX STARTED</color>");

                m_textBoxRef.dialogueRunner.Clear();// UNLOADS ALL LOADED YARN FILES.

                if (useInlineDialogue)
                {
                    m_textBoxRef.dialogueRunner.AddScript(inlineDialogue);
                }
                else if (dialogueAsset != null)
                {
                    m_textBoxRef.dialogueRunner.AddScript(dialogueAsset);
                }

                m_dialougeUI.onEnd.AddListener(m_onEnd);
                m_textBoxRef.CallTextBox(startNode);

                //Pause without breaking the current animation states. Work around for 2018.2
                if (pauseTimeline)
                {
                    m_graph.GetRootPlayable(0).SetSpeed(0);
                }
                if (jumpToEndOfClip)
                {
                    JumpToEndofPlayable();
                }
            }
        }
    }
コード例 #5
0
    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
        if (Application.isPlaying)
        {
            PlayableOutput playableOutput = graph.GetOutput(0);

            if (playableOutput.IsOutputValid())
            {
                ScriptPlayable <TimeNotificationBehaviour> scriptPlayable =
                    (ScriptPlayable <TimeNotificationBehaviour>)playableOutput.GetSourcePlayable().GetInput(0);



                TimeNotificationBehaviour timeNotificationBehaviour = scriptPlayable.GetBehaviour();

                var simpleMarkers = this.GetMarkers().OfType <SimpleMarker>();

                m_Receiver = new ReceiverExample();

                playableOutput.AddNotificationReceiver(m_Receiver);

                foreach (var marker in simpleMarkers)
                {
                    scriptPlayable.GetBehaviour().AddNotification(marker.time, marker);
                }
            }
            else
            {
                playableOutput = ScriptPlayableOutput.Create(graph, "NotificationOutput");

                m_Receiver = new ReceiverExample();

                //why also here and in "outputs"
                playableOutput.AddNotificationReceiver(m_Receiver);

                //Create a TimeNotificationBehaviour
                var timeNotificationPlayable = ScriptPlayable <TimeNotificationBehaviour> .Create(graph);

                playableOutput.SetSourcePlayable(graph.GetRootPlayable(0));
                timeNotificationPlayable.GetBehaviour().timeSource = playableOutput.GetSourcePlayable();
                playableOutput.GetSourcePlayable().SetInputCount(playableOutput.GetSourcePlayable().GetInputCount() + 1);
                graph.Connect(timeNotificationPlayable, 0, playableOutput.GetSourcePlayable(), playableOutput.GetSourcePlayable().GetInputCount() - 1);

                var simpleMarkers = this.GetMarkers().OfType <SimpleMarker>();


                foreach (var marker in simpleMarkers)
                {
                    timeNotificationPlayable.GetBehaviour().AddNotification(marker.time, marker);
                }
            }
        }

        return(base.CreateTrackMixer(graph, go, inputCount));
    }
コード例 #6
0
ファイル: AnimatorHandler.cs プロジェクト: Farl/SSCore2017
    private void RecursiveDump(PlayableGraph graph)
    {
        var count = graph.GetRootPlayableCount();

        for (int i = 0; i < count; i++)
        {
            var p = graph.GetRootPlayable(i);
            Debug.Log(p.ToString());
            RecursiveDump(p);
        }
    }
コード例 #7
0
        public static T FindOutput <T>(PlayableGraph graph, bool recursive = false) where T : PlayableBehaviour, new()
        {
            int outputs = graph.GetRootPlayableCount();

            for (int i = 0; i < outputs; i++)
            {
                var found = FindOutput <T>(graph.GetRootPlayable(i), recursive);
                if (found != null)
                {
                    return(found);
                }
            }
            return(null);
        }
コード例 #8
0
        public static bool TryFindTimelinePlayable(PlayableGraph graph, out Playable timelinePlayable)
        {
            timelinePlayable = Playable.Null;

            if (!graph.IsValid())
            {
                Debug.LogError("Cant find TimelinePlayable: PlayableGraph is not valid");
                return(false);
            }

            bool TraverseSearchTimelinePlayable(Playable pl, ref Playable timeline)
            {
                if (timeline.IsValid())
                {
                    return(true);
                }
                if (pl.IsValid() && pl.GetPlayableType() == typeof(TimelinePlayable))
                {
                    timeline = pl;
                    return(true);
                }

                for (var k = 0; k < pl.GetInputCount(); k++)
                {
                    var input = pl.GetInput(k);
                    if (TraverseSearchTimelinePlayable(input, ref timeline))
                    {
                        break;
                    }
                }

                return(timeline.IsValid());
            }

            for (var i = 0; i < graph.GetOutputCount(); i++)
            {
                var rootOutput = graph.GetRootPlayable(i);
                if (TraverseSearchTimelinePlayable(rootOutput, ref timelinePlayable))
                {
                    break;
                }
            }

            return(timelinePlayable.IsValid());
        }
コード例 #9
0
            public static PlayableBehaviour GetTrackMixer(PlayableGraph graph, TrackAsset track, Type type)
            {
                int rootCount = graph.GetRootPlayableCount();

                for (int i = 0; i < rootCount; i++)
                {
                    Playable root = graph.GetRootPlayable(i);

                    PlayableBehaviour trackMixer = GetTrackMixer(root, track, type);

                    if (trackMixer != null)
                    {
                        return(trackMixer);
                    }
                }

                return(null);
            }
コード例 #10
0
            //Finds the track mixer for a track given a playable graph instance
            public static T GetTrackMixer <T>(PlayableGraph graph, TrackAsset track) where T : class, IPlayableBehaviour, ITrackMixer, new()
            {
                int rootCount = graph.GetRootPlayableCount();

                for (int i = 0; i < rootCount; i++)
                {
                    Playable root = graph.GetRootPlayable(i);

                    T trackMixer = GetTrackMixer <T>(root, track);

                    if (trackMixer != null)
                    {
                        return(trackMixer);
                    }
                }

                return(null);
            }
コード例 #11
0
 public static IEnumerable <T> EnumerateBehaviours <T>(PlayableGraph playableGraph) where T : class, IPlayableBehaviour, new()
 {
     //IL_0008: Unknown result type (might be due to invalid IL or missing references)
     //IL_0009: Unknown result type (might be due to invalid IL or missing references)
     if (playableGraph.IsValid())
     {
         int rootPlayableCount = playableGraph.GetRootPlayableCount();
         int num;
         for (int rootPlayableIndex = 0; rootPlayableIndex < rootPlayableCount; rootPlayableIndex = num)
         {
             Playable rootPlayable = playableGraph.GetRootPlayable(rootPlayableIndex);
             foreach (T item in EnumerateBehaviours <T>(rootPlayable))
             {
                 yield return(item);
             }
             num = rootPlayableIndex + 1;
         }
     }
 }
コード例 #12
0
            //Get all playable behaviours in a playable graph of type T, or implementing interface of type T
            public static List <T> GetPlayableBehaviours <T>(PlayableGraph graph) where T : class
            {
                List <T> playables = new List <T>();

                int rootCount = graph.GetRootPlayableCount();

                for (int i = 0; i < rootCount; i++)
                {
                    Playable root = graph.GetRootPlayable(i);

                    int inputCount = root.GetInputCount();;

                    for (int j = 0; j < inputCount; j++)
                    {
                        GetPlayableBehaviours(root.GetInput(j), ref playables);
                    }
                }

                return(playables);
            }