public override void ProcessFrame(Playable playable, FrameData info, object playerData) { if (!Application.isPlaying) { return; } int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); ScriptPlayable <TimeMachineBehaviour> inputPlayable = (ScriptPlayable <TimeMachineBehaviour>)playable.GetInput(i); TimeMachineBehaviour input = inputPlayable.GetBehaviour(); if (inputWeight > 0f) { if (!input.clipExecuted) { switch (input.action) { //case TimeMachineBehaviour.TimeMachineAction.Pause: // if (input.ConditionMet()) // { // GameManager.instance.PauseTimeline(director); // input.clipExecuted = true; //this prevents the command to be executed every frame of this clip // } // break; case TimeMachineBehaviour.TimeMachineAction.JumpToTime: case TimeMachineBehaviour.TimeMachineAction.JumpToMarker: if (input.ConditionMet()) { //Rewind if (input.action == TimeMachineBehaviour.TimeMachineAction.JumpToTime) { //Jump to time (playable.GetGraph().GetResolver() as PlayableDirector).time = (double)input.timeToJumpTo; } else { //Jump to marker double t = markerClips[input.markerToJumpTo]; (playable.GetGraph().GetResolver() as PlayableDirector).time = t; } input.clipExecuted = false; //we want the jump to happen again! } break; } } } } }
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) { var playable = ScriptPlayable <TimeMachineBehaviour> .Create(graph, template); TimeMachineBehaviour clone = playable.GetBehaviour(); clone.markerToJumpTo = markerToJumpTo; clone.conditionalBehaviour = interactionDetector.Resolve(graph.GetResolver()); clone.action = action; clone.condition = condition; clone.markerLabel = markerLabel; clone.timeToJumpTo = timeToJumpTo; return(playable); }