Beispiel #1
0
    private void BuildOutput()
    {
        PlayableDirector.Evaluate();

        if (PlayableDirector.playableGraph.IsValid())
        {
            _outputTrackIndex       = 0;
            _trackAsset             = (PlayableDirector.playableAsset as TimelineAsset)?.GetOutputTrack(_outputTrackIndex);
            _originalOutput         = (AnimationPlayableOutput)PlayableDirector.playableGraph.GetOutputByType <AnimationPlayableOutput>(_outputTrackIndex);
            _originalSourcePlayable = _originalOutput.GetSourcePlayable();
            _clone         = PlayableDirector.playableAsset.CreatePlayable(PlayableDirector.playableGraph, PlayableDirector.gameObject);
            _mixer         = AnimationMixerPlayable.Create(PlayableDirector.playableGraph, 2);
            _cloneIndex    = _mixer.AddInput(_clone, 0);
            _originalIndex = _mixer.AddInput(_originalSourcePlayable, 0, 1f);

            if (_originalOutput.IsOutputValid() && _originalOutput.GetTarget() != null)
            {
                _output = AnimationPlayableOutput.Create(PlayableDirector.playableGraph, "OverridedDirectorOutput" + GetInstanceID(), _originalOutput.GetTarget());
                _output.SetSourcePlayable(_mixer);
                _output.SetSourceOutputPort(_originalOutput.GetSourceOutputPort());
                _output.SetWeight(1f);
                _originalOutput.SetTarget(null);
            }
            else
            {
                Debug.Log("Original Director Output is invalid");
            }
        }
    }
Beispiel #2
0
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private void Setup()
        {
            if (!this.runtimeController)
            {
                throw new Exception(ERR_NORTC);
            }

            if (this.characterAnimator.animator.playableGraph.IsValid())
            {
                this.characterAnimator.animator.playableGraph.Destroy();
            }

            if (this.graph.IsValid())
            {
                this.graph.Destroy();
            }

            this.graph = PlayableGraph.Create(GRAPH_NAME);
            this.graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);

            AnimationPlayableOutput output = AnimationPlayableOutput.Create(
                this.graph, GRAPH_NAME,
                this.characterAnimator.animator
                );

            this.SetupSectionDefaultStates();
            this.SetupSectionStates();
            this.SetupSectionGestures();

            output.SetSourcePlayable(this.mixerGesturesOutput);
            output.SetSourceOutputPort(0);

            this.graph.Play();
        }
Beispiel #3
0
        static public void Play(Animator animator, Playable playable, PlayableGraph graph)
        {
            AnimationPlayableOutput playableOutput = AnimationPlayableOutput.Create(graph, "AnimationClip", animator);

            playableOutput.SetSourcePlayable(playable);
            playableOutput.SetSourceOutputPort(0);
            graph.SyncUpdateAndTimeMode(animator);
            graph.Play();
        }