Beispiel #1
0
            public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
            {
                var playable = ScriptPlayable <AnimatedCameraPlayableBehaviour> .Create(graph, new AnimatedCameraPlayableBehaviour());

                AnimatedCameraPlayableBehaviour clone = playable.GetBehaviour();

                clone._snapshot = _snapshot.Resolve(graph.GetResolver()) as IAnimatedCameraStateSource;
                return(playable);
            }
Beispiel #2
0
            public override void ProcessFrame(Playable playable, FrameData info, object playerData)
            {
                _trackBinding = playerData as AnimatedCamera;

                if (_trackBinding == null)
                {
                    return;
                }

                if (!_firstFrameHappened)
                {
                    _defaultState       = _trackBinding.GetState();
                    _firstFrameHappened = true;
                }

                AnimatedCameraState blendedState = _defaultState;

                int inputPort = 0;

                foreach (TimelineClip clip in _clips)
                {
                    ScriptPlayable <AnimatedCameraPlayableBehaviour> scriptPlayable = (ScriptPlayable <AnimatedCameraPlayableBehaviour>)playable.GetInput(inputPort);
                    AnimatedCameraPlayableBehaviour inputBehaviour = scriptPlayable.GetBehaviour();

                    if (inputBehaviour != null)
                    {
                        double clipStart    = clip.hasPreExtrapolation ? clip.extrapolatedStart : clip.start;
                        double clipDuration = clip.hasPreExtrapolation || clip.hasPostExtrapolation ? clip.extrapolatedDuration : clip.duration;

                        //If currently playing
                        if (_director.time >= clipStart && _director.time <= clipStart + clipDuration)
                        {
                            float inputWeight = playable.GetInputWeight(inputPort);

                            AnimatedCameraState behaviourState = inputBehaviour._snapshot.GetState();

                            //Interpolated behavior
                            if (inputBehaviour._snapshotTo != null)
                            {
                                double clipT = Math.Min(Math.Max(_director.time - clip.start, 0.0) / clip.duration, 1.0);
                                behaviourState = behaviourState.InterpolateTo(_trackBinding, inputBehaviour._snapshotTo.GetState(), inputBehaviour._easeType, (float)clipT);
                            }

                            //Fade playable over current state using its weight
                            blendedState = blendedState.InterpolateTo(_trackBinding, behaviourState, eInterpolation.Linear, inputWeight);
                        }
                    }

                    ++inputPort;
                }

                _trackBinding.SetState(blendedState);
            }