public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
        var scriptPlayable = ScriptPlayable <TimeMachineMixerBehaviour> .Create(graph, inputCount);

        TimeMachineMixerBehaviour b = scriptPlayable.GetBehaviour();

        b.markerClips = new System.Collections.Generic.Dictionary <string, double>();

        var events = (graph.GetResolver() as PlayableDirector)?.GetComponent <TimelineControllerEvents>();


        foreach (var c in GetClips())
        {
            TimeMachineClip clip = (TimeMachineClip)c.asset;

            clip.clip = c;

            clip.events = events;

            if (!b.markerClips.ContainsKey(c.displayName))
            {
                b.markerClips.Add(c.displayName, (double)c.start);
            }
        }

        return(scriptPlayable);
    }
    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
        var scriptPlayable = ScriptPlayable <TimeMachineMixerBehaviour> .Create(graph, inputCount);

        TimeMachineMixerBehaviour b = scriptPlayable.GetBehaviour();

        b.markerClips = new System.Collections.Generic.Dictionary <string, double>();


        foreach (var c in GetClips())
        {
            TimeMachineClip clip     = (TimeMachineClip)c.asset;
            string          clipName = c.displayName;

            switch (clip.action)
            {
            case TimeMachineBehaviour.TimeMachineAction.Pause:
                clipName = "||";
                break;

            case TimeMachineBehaviour.TimeMachineAction.Marker:
                clipName = "● " + clip.markerLabel.ToString();

                //Insert the marker clip into the Dictionary of markers
                if (!b.markerClips.ContainsKey(clip.markerLabel))                        //happens when you duplicate a clip and it has the same markerLabel
                {
                    b.markerClips.Add(clip.markerLabel, (double)c.start);
                }
                break;

            case TimeMachineBehaviour.TimeMachineAction.JumpToMarker:
                clipName = "↩︎  " + clip.markerToJumpTo.ToString();
                break;

            case TimeMachineBehaviour.TimeMachineAction.JumpToTime:
                clipName = "↩ " + clip.timeToJumpTo.ToString();
                break;
            }

            c.displayName = clipName;


            if (clip.action == TimeMachineBehaviour.TimeMachineAction.Marker)
            {
                if (!b.markerClips.ContainsKey(clip.markerLabel))                //happens when you duplicate a clip and it has the same markerLabel
                {
                    b.markerClips.Add(clip.markerLabel, (double)c.start);
                }
            }
        }

        return(scriptPlayable);
    }
예제 #3
0
    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
        var scriptPlayable = ScriptPlayable <TimeMachineMixerBehaviour> .Create(graph, inputCount);

        TimeMachineMixerBehaviour b = scriptPlayable.GetBehaviour();

        b.markerClips = new System.Collections.Generic.Dictionary <string, double>();


        //This foreach will rename clips based on what they do, and collect the markers and put them into a dictionary
        //Since this happens when you enter Preview or Play mode, the object holding the Timeline must be enabled or you won't see any change in names
        foreach (var c in GetClips())
        {
            TimeMachineClip clip     = (TimeMachineClip)c.asset;
            string          clipName = c.displayName;

            switch (clip.action)
            {
            /*
             *              case TimeMachineBehaviour.TimeMachineAction.Pause:
             *                      clipName = "||";
             *                      break;
             */

            case TimeMachineBehaviour.TimeMachineAction.Marker:
                clipName = "● " + clip.markerLabel.ToString();

                //Insert the marker clip into the Dictionary of markers
                if (!b.markerClips.ContainsKey(clip.markerLabel))                        //happens when you duplicate a clip and it has the same markerLabel
                {
                    b.markerClips.Add(clip.markerLabel, (double)c.start);
                }
                break;

            case TimeMachineBehaviour.TimeMachineAction.JumpToMarker:
                clipName = "↩︎  " + clip.markerToJumpTo.ToString();
                break;

            case TimeMachineBehaviour.TimeMachineAction.JumpToTime:
                clipName = "↩ " + clip.timeToJumpTo.ToString();
                break;
            }

            c.displayName = clipName;
        }

        return(scriptPlayable);
    }
    public void RunAction(TimeMachineMixerBehaviour mixer)
    {
        switch (Action)
        {
        case TimeMachineAction.None:
            break;

        case TimeMachineAction.JumpToClip:
            if (mixer.markerClips.TryGetValue(markerToJumpTo, out var time))
            {
                if (ConditionMet())
                {
                    mixer.director.Pause();
                    mixer.director.time = time;
                    //mixer.director.Evaluate();
                    mixer.director.Play();
                }
            }
            break;

        case TimeMachineAction.Pause:
            if (ConditionMet())
            {
                mixer.director.Pause();
            }
            break;

        case TimeMachineAction.TriggerEvent:
            if (mixer.events != null)
            {
                mixer.events.RunEvent(EventName);
            }

            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }