public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            base.ProcessFrame(playable, info, playerData);

            // Get time of the root playable in the playable graph, which is the timeline itself.
            var curTime  = playable.GetGraph().GetRootPlayable(0).GetTime();
            var prevTime = playable.GetGraph().GetRootPlayable(0).GetPreviousTime();

            // If there's an event at the beginning of the track, and we're currently at the
            // beginning of the track, we should fire it now.
            checkFireTimeZeroEvent(curTime);

            if (!_firstFrameFired)
            {
                _firstFrameFired = true;
            }
            else
            {
                if (prevTime <= curTime)
                {
                    // Sweep forward from prevTime to curTime if moving forward.
                    sweepFireEvents(prevTime, curTime);
                }
                else
                {
                    // When scrubbing backwards, sweep from the beginning of the track, potentially
                    // firing events based on the eventScrubType.
                    sweepFireFromBeginning(prevTime, curTime);
                }
            }
        }
Exemplo n.º 2
0
    // Called each frame while the state is set to Play
    public override void PrepareFrame(Playable playable, FrameData info)
    {
        var anim = Anim.Resolve(playable.GetGraph().GetResolver());

        if (anim != null)
        {
            if (!string.IsNullOrEmpty(AnimName))
            {
                anim.Play(AnimName);
            }

            if (!string.IsNullOrEmpty(AnimParamName))
            {
                anim.SetInteger(AnimParamName, AnimParamValue);
            }
        }


        var spriteAnim = SpriteAnim.Resolve(playable.GetGraph().GetResolver());


        if (spriteAnim != null)
        {
            if (IsPause)
            {
                spriteAnim.IsStop(true);
                return;
            }

            spriteAnim.Play(SpriteAnimName, IsLoop, AnimSpeed == 0 ? 1 : AnimSpeed);
        }
    }
Exemplo n.º 3
0
 public override void OnGraphStart(Playable playable)
 {
     // コイツは UnityEngine.Timeline.TimelinePlayable であるコトを期待している
     RootPlayable     = playable.GetGraph().GetRootPlayable(0);
     PlayableDirector = (PlayableDirector)playable.GetGraph().GetResolver();
     ActiveTracks     = ((TimelineAsset)PlayableDirector.playableAsset).GetOutputTracks().OfType <ActiveTrack>();
 }
        /// <summary>
        /// This function is called during the ProcessFrame phase of the PlayableGraph.
        /// </summary>
        /// <param name="playable">The playable this behaviour is attached to.</param>
        /// <param name="info">A FrameData structure that contains information about the current frame context.</param>
        /// <param name="playerData">unused</param>
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            if (director == null || !director.isActiveAndEnabled || director.playableAsset == null)
            {
                return;
            }

            if (m_SyncTime || DetectOutOfSync(playable))
            {
                UpdateTime(playable);
                if (director.playableGraph.IsValid())
                {
                    director.playableGraph.Evaluate();
#if TIMELINE_FRAMEACCURATE
                    director.playableGraph.SynchronizeEvaluation(playable.GetGraph());
#endif
                }
                else
                {
                    director.Evaluate();
                }
            }

            m_SyncTime = false;
#if UNITY_2021_2_OR_NEWER
            SyncStop(playable.GetGraph(), playable.GetTime());
#endif
        }
Exemplo n.º 5
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
#if UNITY_EDITOR
            /*
             * Process frame is called from OnGUI() when auditioning.
             * Check playing to avoid retriggering sounds while scrubbing or repainting.
             * Check IsQuitting to avoid accessing the RuntimeManager during the Play-In-Editor to Editor transition.
             */
            bool playing = playable.GetGraph().IsPlaying();
            if (!playing)
            {
                return;
            }
            /* When auditioning manually update the StudioSystem in place of the RuntimeManager. */
            if (!Application.isPlaying)
            {
                FMODUnity.RuntimeManager.StudioSystem.update();
            }
#endif //UNITY_EDITOR

            int   inputCount = playable.GetInputCount();
            float time       = (float)playable.GetGraph().GetRootPlayable(0).GetTime();

            for (int i = 0; i < inputCount; i++)
            {
                ScriptPlayable <FMODEventPlayableBehavior> inputPlayable = (ScriptPlayable <FMODEventPlayableBehavior>)playable.GetInput(i);
                FMODEventPlayableBehavior input = inputPlayable.GetBehaviour();

                input.UpdateBehaviour(time);
            }
        }
Exemplo n.º 6
0
        public override void PrepareFrame(Playable playable, FrameData info)
        {
            if (asset == null)
            {
                return;
            }

            // Ensure whether the current state should require the
            // asset to be playing.
            if (!asset.IsPlaying())
            {
                if (Application.isPlaying &&
                    playable.GetGraph().IsPlaying())
                {
                    PlayAsset();
                }
            }

            float playableTime = (float)playable.GetTime();
            float delta        = playableTime - asset.GetCurrentTime();

            if (Math.Abs(delta) > m_maxTimeDelta ||
                !playable.GetGraph().IsPlaying())
            {
                if (playableTime > 0 &&
                    playableTime < asset.GetDuration())
                {
                    asset.Seek(playableTime);
                }
            }
        }
Exemplo n.º 7
0
    /// <summary>
    /// OnBehaviorPause is called when clip becomes deactivated. This occurs when the timeline starts, when the clip is passed it's duration, or if the timeline is stopped.
    /// </summary>
    /// <param name="playable"></param>
    /// <param name="info"></param>
    public override void OnBehaviourPause(Playable playable, FrameData info)
    {
        //Check on _dialoguePlayed is needed b/c OnBehaviorPause is called also at the beginning of the Timeline, so we need to make sure
        //that the Timeline has actually gone through this clip (i.e. called OnBehaviorPlay) at least once before we stop it.
        if (Application.isPlaying && playable.GetGraph().IsPlaying() &&
            !playable.GetGraph().GetRootPlayable(0).IsDone() &&
            _dialoguePlayed)
        {
            if (_pauseWhenClipEnds && !_rewindWhenClipEnds)
            {
                if (PauseTimelineEvent != null)
                {
                    PauseTimelineEvent.RaiseEvent();
                }
            }

            else if (!_pauseWhenClipEnds && _rewindWhenClipEnds)
            {
                if (RewindTimelineEvent != null)
                {
                    RewindTimelineEvent.RaiseEvent(_rewindTime, _advanceTime);
                }
            }
        }
    }
Exemplo n.º 8
0
 public override void OnGraphStop(Playable playable)
 {
     _subject = subject.Resolve(playable.GetGraph().GetResolver());
     if (_subject != null && isFirstClipInTrack)
     {
         if (useQuaternion)
         {
             if (isLocal)
             {
                 _subject.localRotation = Quaternion.Lerp(Quaternion.Euler(src), Quaternion.Euler(dst), curve.Evaluate(0f));
             }
             else
             {
                 _subject.rotation = Quaternion.Lerp(Quaternion.Euler(src), Quaternion.Euler(dst), curve.Evaluate(0f));
             }
         }
         else
         {
             if (isLocal)
             {
                 _subject.localEulerAngles = Vector3.Lerp(src, dst, curve.Evaluate(0f));
             }
             else
             {
                 _subject.eulerAngles = Vector3.Lerp(src, dst, curve.Evaluate(0f));
             }
         }
         _subject = subject.Resolve(playable.GetGraph().GetResolver());
     }
 }
Exemplo n.º 9
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        //ScriptPlayable<TimeMachineBehaviour> inputPlayable = (ScriptPlayable<TimeMachineBehaviour>)playable.GetInput(i);
        //Debug.Log(PlayableExtensions.GetTime<ScriptPlayable<TimeMachineBehaviour>>(inputPlayable));

        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())
                        {
                            // TODO: musíš implementovať GameManager, pomocou ktorého
                            // budes ovládať hru a prepínať hlavné udalosti
                            // teraz by to mohla byť ten TimelineManager
                            // 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;
                    }
                }
            }
        }
    }
Exemplo n.º 10
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        //ScriptPlayable<TimeMachineBehaviour> inputPlayable = (ScriptPlayable<TimeMachineBehaviour>)playable.GetInput(i);
        //Debug.Log(PlayableExtensions.GetTime<ScriptPlayable<TimeMachineBehaviour>>(inputPlayable));

        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 > 0.0f)
            {
                if (!input.clipExecuted)
                {
                    switch (input.action)
                    {
                    /*
                     *                      case TimeMachineBehaviour.TimeMachineAction.Pause:
                     *                              if(input.ConditionMet())
                     *                              {
                     *                                      //GameManager.Instance.PauseTimeline(director);   //perlu buat sendiri condition agar bisa keluar dari pause
                     *                                      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 if (input.action == TimeMachineBehaviour.TimeMachineAction.JumpToMarker)
                            {
                                //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;
                    }
                }
            }
        }
    }
Exemplo n.º 11
0
 public override void OnPlayableCreate(Playable playable)
 {
     _self = playable;
     _self.SetInputCount(1);
     _self.SetInputWeight(0, 1);
     _mixer = AnimationMixerPlayable.Create(_self.GetGraph(), 1, true);
     _graph = _self.GetGraph();
     _graph.Connect(_mixer, 0, _self, 0);
     _graph.Play();
 }
Exemplo n.º 12
0
    public override void OnBehaviourPlay(Playable playable, FrameData info)
    {
        _mTran          = mTran.Resolve(playable.GetGraph().GetResolver());
        _relativeTarget = relativeTarget.Resolve(playable.GetGraph().GetResolver());

        if (_mTran != null && _relativeTarget != null)
        {
            _mTran.position = _relativeTarget.position + _relativeTarget.rotation * offsetPos;
            _mTran.rotation = Quaternion.LookRotation(_relativeTarget.position - _mTran.position);
            _mTran.transform.localEulerAngles += offsetRot;
        }
    }
Exemplo n.º 13
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        //ScriptPlayable<TimeMachineBehaviour> inputPlayable = (ScriptPlayable<TimeMachineBehaviour>)playable.GetInput(i);
        //Debug.Log(PlayableExtensions.GetTime<ScriptPlayable<TimeMachineBehaviour>>(inputPlayable));

        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)
            {
                switch (input.action)
                {
                case TimeMachineBehaviour.TimeMachineAction.Pause:
                    Debug.Log("Pause");
                    (playable.GetGraph().GetResolver() as PlayableDirector).Pause();
                    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;
                        }
                    }
                    break;
                }
            }
        }
    }
Exemplo n.º 14
0
 public override void OnBehaviourPause(Playable playable, FrameData info)
 {
     // The check on _dialoguePlayed is needed because OnBehaviourPause is called also at the beginning of the Timeline,
     // so we need to make sure that the Timeline has actually gone through this clip (i.e. called OnBehaviourPlay) at least once before we stop it
     if (Application.isPlaying &&
         playable.GetGraph().IsPlaying() &&
         !playable.GetGraph().GetRootPlayable(0).IsDone() &&
         _dialoguePlayed)
     {
         if (_pauseWhenClipEnds)
         {
             cutsceneManager.PauseTimeline();
         }
     }
 }
Exemplo n.º 15
0
 // 销毁playable
 public void DestroyPlayable()
 {
     if (m_Playable.IsValid())
     {
         m_Playable.GetGraph().DestroySubgraph(m_Playable);
     }
 }
Exemplo n.º 16
0
    /// <summary>
    /// Displays a line of dialogue on screen by interfacing with the <c>CutsceneManager</c>. This happens as soon as the playhead reaches the clip.
    /// </summary>
    public override void OnBehaviourPlay(Playable playable, FrameData info)
    {
        if (_dialoguePlayed)
        {
            return;
        }

        // Need to ask the CutsceneManager if the cutscene is playing, since the graph is not actually stopped/paused: it's just going at speed 0
        // This check is needed because when two clips are side by side and the first one stops the cutscene,
        // the OnBehaviourPlay of the second clip is still called and thus its dialogueLine is played (prematurely). This check makes sure it's not.
        if (playable.GetGraph().IsPlaying() &&
            cutsceneManager.IsCutscenePlaying)
        {
            //TODO: Find a way to "play" dialogue lines even when scrubbing the Timeline not in Play Mode
            if (_dialogueLine != null)
            {
                cutsceneManager.PlayDialogueFromClip(_dialogueLine);
                _dialoguePlayed = true;
            }
            else
            {
                Debug.LogWarning("This clip contains no DialogueLine");
            }
        }
    }
Exemplo n.º 17
0
        // Called every frame that the timeline is evaluated. This is called prior to
        // PrepareFrame on any of its input playables.
        public override void PrepareFrame(Playable playable, FrameData info)
        {
            // Searches for clips that are in the 'preload' area and prepares them for playback
            var timelineTime = playable.GetGraph().GetRootPlayable(0).GetTime();

            for (int i = 0; i < playable.GetInputCount(); i++)
            {
                if (playable.GetInput(i).GetPlayableType() != typeof(VideoPlayableBehaviour))
                {
                    continue;
                }

                if (playable.GetInputWeight(i) <= 0.0f)
                {
                    ScriptPlayable <VideoPlayableBehaviour> scriptPlayable = (ScriptPlayable <VideoPlayableBehaviour>)playable.GetInput(i);
                    VideoPlayableBehaviour videoPlayableBehaviour          = scriptPlayable.GetBehaviour();
                    double preloadTime = Math.Max(0.0, videoPlayableBehaviour.preloadTime);
                    double clipStart   = videoPlayableBehaviour.startTime;

                    if (timelineTime > clipStart - preloadTime && timelineTime <= clipStart)
                    {
                        videoPlayableBehaviour.PrepareVideo();
                    }
                }
            }
        }
Exemplo n.º 18
0
        private void ProcessCurrentClip(Playable playable, object playerData, DialogueBehaviour input, ClipData clipData)
        {
            double currentTime = playable.GetTime();

            if (currentTime > 0f)
            {
                if (clipData.state == ClipState.Pending)
                {
                    clipData.state = ClipState.Started;
                    (playerData as DialogueBinder)?.SetDialog(input.dialogueID);
                }

                if (clipData.state == ClipState.Started)
                {
                    if (currentTime >= m_clipsData[m_currentClipIndex].Range.End - k_StopThreshold)
                    {
                        clipData.state = ClipState.Ended;
                    }
                }

                if (clipData.state == ClipState.Ended)
                {
                    if (NextClipIndexInBounds(m_currentClipIndex + 1))
                    {
                        m_currentClipIndex++;
                        playable.SetTime(m_clipsData[m_currentClipIndex].Range.Start);
                        if (input.stopGraphOnClipEnd)
                        {
                            playable.GetGraph().Stop();
                        }
                    }
                }
            }
        }
Exemplo n.º 19
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        int inputCount = playable.GetInputCount();

        var rootPlayable = playable.GetGraph().GetRootPlayable(0);

        float time = (float)rootPlayable.GetTime();

        for (int i = 0; i < inputCount; i++)
        {
            var inputPlayable = (ScriptPlayable <PC2DAddOrRemoveCameraTargetBehaviour>)playable.GetInput(i);
            var input         = inputPlayable.GetBehaviour();

            if (Application.isPlaying &&
                (_currentTime <= input.ClipStartTime) && (time > input.ClipStartTime))
            {
                if (input.action == PC2DAddOrRemoveCameraTarget.Add)
                {
                    ProCamera2D.Instance.AddCameraTarget(input.cameraTarget);
                }
                else
                {
                    ProCamera2D.Instance.RemoveCameraTarget(input.cameraTarget);
                }
            }
        }

        _currentTime = time;
    }
Exemplo n.º 20
0
    public override void OnPlayableCreate(Playable playable)
    {
        base.OnPlayableCreate(playable);
        m_playableGraph = playable.GetGraph();

        inPlayable = playable;
    }
        public override void PrepareFrame(Playable playable, FrameData info)
        {
            // The playable graph can sometimes evaluate outside of our control, due to the way the Timeline Window
            // takes control of playback, so we check if this is a manual evaluation from RecordedSessionDirector
            if (m_VideoPlayer == null || !m_VideoPlayer.isPrepared || !m_SessionDirector.IsEvaluating || m_SessionDirector.IsSyncing)
            {
                return;
            }

            var time = playable.GetTime();

            if (time >= m_VideoLength)
            {
                m_VideoPlayer.time = m_VideoLength;
                return;
            }

            var videoTime = time;

            m_VideoPlayer.externalReferenceTime = videoTime;

            if (!m_VideoPlayer.isPlaying)
            {
                m_VideoPlayer.time = videoTime;
                if (playable.GetGraph().IsPlaying())
                {
                    m_VideoPlayer.Play();
                }
            }
        }
Exemplo n.º 22
0
    //Called each frame when timeline is played
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        if (_dialoguePlayed)
        {
            return;
        }

        if (Application.isPlaying)
        {
            //Need to ask the CutsceneManager if the cutscene is playing, since the graph is not actually stopped/paused: it is just going at speed 0.

            if (playable.GetGraph().IsPlaying())
            {
                if (_dialogueLine != null && _actor != null)
                {
                    if (PlayDialogueEvent != null)
                    {
                        PlayDialogueEvent.RaiseEvent(_dialogueLine, _actor);
                    }
                    _dialoguePlayed = true;
                }
                else
                {
                    Debug.LogWarning("This clip contains no DialogueLine");
                }
            }
        }
    }
Exemplo n.º 23
0
        protected override IObservable <Unit> OnRegisterInputTrigger(Playable playable)
        {
            var collider = colliderReference.Resolve(playable.GetGraph().GetResolver());

            if (collider == null)
            {
                return(null);
            }

            switch (method)
            {
            case Method.TriggerEnter:
                return(collider.OnTriggerEnterAsObservable().AsUnitObservable());

            case Method.TriggerExit:
                return(collider.OnTriggerExitAsObservable().AsUnitObservable());

            case Method.CollisionEnter:
                return(collider.OnCollisionEnterAsObservable().AsUnitObservable());

            case Method.CollisionExit:
                return(collider.OnCollisionExitAsObservable().AsUnitObservable());

            default:
                Debug.unityLogger.LogError(nameof(WaitForInputColliderBehaviour), $"Not implementation {method}");
                return(null);
            }
        }
Exemplo n.º 24
0
 public override void OnPlayableCreate(Playable playable)
 {
     m_playable   = playable;
     m_graph      = playable.GetGraph();
     m_onEnd      = OnDialogueEnd;
     m_dialougeUI = GameObject.FindObjectOfType <DialougeUI>();
 }
Exemplo n.º 25
0
    /// <summary>
    /// Displays a line of dialogue on screen by interfacing with the <c>CutsceneManager</c>.
    /// </summary>
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        if (_dialoguePlayed)
        {
            return;
        }

        if (Application.isPlaying)          //TODO: Find a way to "play" dialogue lines even when scrubbing the Timeline not in Play Mode
        {
            // Need to ask the CutsceneManager if the cutscene is playing, since the graph is not actually stopped/paused: it's just going at speed 0.
            if (playable.GetGraph().IsPlaying() &&
                cutsceneManager.IsCutscenePlaying)
            {
                if (_dialogueLine != null)
                {
                    cutsceneManager.PlayDialogueFromClip(_dialogueLine);
                    _dialoguePlayed = true;
                }
                else
                {
                    Debug.LogWarning("This clip contains no DialogueLine");
                }
            }
        }
    }
        void PrepareParticleSystem(Playable playable)
        {
            // Disable automatic random seed to get deterministic results.
            if (particleSystem.useAutoRandomSeed)
            {
                particleSystem.useAutoRandomSeed = false;
            }

            // Override the random seed number.
            if (particleSystem.randomSeed != randomSeed)
            {
                particleSystem.randomSeed = randomSeed;
            }

            // Retrieve the total duration of the track.
            var rootPlayable = playable.GetGraph().GetRootPlayable(0);
            var duration     = (float)rootPlayable.GetDuration();

            // Particle system duration should be longer than the track duration.
            var main = particleSystem.main;

            if (main.duration < duration)
            {
                main.duration = duration;
            }
        }
Exemplo n.º 27
0
        /************************************************************************************************************************/

        /// <summary>[Pro-Only]
        /// Reconnects the input of the specified `playable` to its output.
        /// </summary>
        public static void RemovePlayable(Playable playable, bool destroy = true)
        {
            if (!playable.IsValid())
            {
                return;
            }

            Debug.Assert(playable.GetInputCount() == 1,
                         $"{nameof(RemovePlayable)} can only be used on playables with 1 input.");
            Debug.Assert(playable.GetOutputCount() == 1,
                         $"{nameof(RemovePlayable)} can only be used on playables with 1 output.");

            var input = playable.GetInput(0);

            if (!input.IsValid())
            {
                if (destroy)
                {
                    playable.Destroy();
                }
                return;
            }

            var graph  = playable.GetGraph();
            var output = playable.GetOutput(0);

            if (output.IsValid())// Connected to another Playable.
            {
                if (destroy)
                {
                    playable.Destroy();
                }
                else
                {
                    Debug.Assert(output.GetInputCount() == 1,
                                 $"{nameof(RemovePlayable)} can only be used on playables connected to a playable with 1 input.");
                    graph.Disconnect(output, 0);
                    graph.Disconnect(playable, 0);
                }

                graph.Connect(input, 0, output, 0);
            }
            else// Connected to the graph output.
            {
                Debug.Assert(graph.GetOutput(0).GetSourcePlayable().Equals(playable),
                             $"{nameof(RemovePlayable)} can only be used on playables connected to another playable or to the graph output.");

                if (destroy)
                {
                    playable.Destroy();
                }
                else
                {
                    graph.Disconnect(playable, 0);
                }

                graph.GetOutput(0).SetSourcePlayable(input);
            }
        }
Exemplo n.º 28
0
 public override void OnGraphStart(Playable playable)
 {
     if (!IsPlaying())
     {
         return;
     }
     BeginRecording(playable.GetTime(), Clip.GetExportRoot(playable.GetGraph()));
 }
 public override void OnPlayableCreate(Playable playable)
 {
     director = playable.GetGraph().GetResolver() as PlayableDirector;
     if (director)
     {
         director.stopped += OnDirectorStopped;
     }
 }
Exemplo n.º 30
0
 public void OnFrameEnd(Playable playable, FrameData info, object playerData)
 {
     if (!playable.IsValid())
     {
         return;
     }
     ProcessRecording(playable.GetTime(), Clip.GetExportRoot(playable.GetGraph()));
 }