private void FindMixers(Playable parent, int port, Playable node)
 {
     if (node.IsValid <Playable>())
     {
         Type playableType = node.GetPlayableType();
         if (playableType == typeof(AnimationMixerPlayable) || playableType == typeof(AnimationLayerMixerPlayable))
         {
             int inputCount = node.GetInputCount <Playable>();
             for (int i = 0; i < inputCount; i++)
             {
                 this.FindMixers(node, i, node.GetInput(i));
             }
             AnimationOutputWeightProcessor.WeightInfo item = new AnimationOutputWeightProcessor.WeightInfo
             {
                 parentMixer = parent,
                 mixer       = node,
                 port        = port,
                 modulate    = (playableType == typeof(AnimationLayerMixerPlayable))
             };
             this.m_Mixers.Add(item);
         }
         else
         {
             int inputCount2 = node.GetInputCount <Playable>();
             for (int j = 0; j < inputCount2; j++)
             {
                 this.FindMixers(parent, port, node.GetInput(j));
             }
         }
     }
 }
示例#2
0
        protected override void OnUpdate(float time, float previousTime)
        {
            if (animator == null || !animator.gameObject.activeInHierarchy)
            {
                return;
            }

#if UNITY_2017_1_OR_NEWER
            if (!graph.IsValid())
            {
                return;
            }

            baseClipPlayable.SetTime(time * basePlaybackSpeed);
            graph.Evaluate(0);
#elif UNITY_5_6_OR_NEWER
            if (!graph.IsValid())
            {
                return;
            }

            baseClipPlayableHandle.time = time * basePlaybackSpeed;
            graph.Evaluate(0);
#else
            if (!mixerPlayable.IsValid())
            {
                return;
            }

            if (!animator.isInitialized)
            {
                animator.Play(mixerPlayable);
            }

            if (baseAnimationClip != null)
            {
                var basePlayable = mixerPlayable.GetInput(0);
                basePlayable.time = time * basePlaybackSpeed;
                mixerPlayable.SetInput(basePlayable, 0);
            }

            animator.Update(0);
#endif

            if (useRootMotion && useBakedRootMotion)
            {
                ApplyBakedRootMotion(time);
            }
        }
        private void Traverse(Playable pl, List <AnimationLayerMixerPlayable> mixers, bool addedMixer = false)
        {
            for (var i = 0; i < pl.GetInputCount(); i++)
            {
                var p = pl.GetInput(i);
                if (!p.IsValid())
                {
                    continue;
                }
                // var w = p.GetInputWeight(0);
                Debug.Log(p.GetPlayableType() + " - " + i + " output: " + p.GetOutputCount());

                var t = p.GetPlayableType();
                if (t == typeof(AnimationLayerMixerPlayable))
                {
                    var amp = (AnimationLayerMixerPlayable)p;
                    if (!addedMixer) // only add first found mixer per playable
                    {
                        mixers.Add(amp);
                    }

                    addedMixer = true;
                }
                else
                {
                    Debug.Log(t + ", " + p.GetInputCount());
                }

                Traverse(p, mixers, addedMixer);
            }
        }
示例#4
0
 public void Init(Playable playable)
 {
     // Build our vcam registry for scrubbing updates
     mAllCamerasForScrubbing = new List <List <CinemachineVirtualCameraBase> >();
     for (int i = 0; i < playable.GetInputCount(); ++i)
     {
         var clip = (ScriptPlayable <CinemachineShotPlayable>)playable.GetInput(i);
         CinemachineShotPlayable shot = clip.GetBehaviour();
         if (shot != null && shot.IsValid)
         {
             var vcam      = shot.VirtualCamera;
             int nestLevel = 0;
             for (ICinemachineCamera p = vcam.ParentCamera; p != null; p = p.ParentCamera)
             {
                 ++nestLevel;
             }
             while (mAllCamerasForScrubbing.Count <= nestLevel)
             {
                 mAllCamerasForScrubbing.Add(new List <CinemachineVirtualCameraBase>());
             }
             if (mAllCamerasForScrubbing[nestLevel].IndexOf(vcam) < 0)
             {
                 mAllCamerasForScrubbing[nestLevel].Add(vcam);
             }
         }
     }
 }
示例#5
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            texthandler = playerData as SubTitleHandler;

            if (texthandler == null)
            {
                return;
            }

            int inputCount = playable.GetInputCount();

            for (int i = 0; i < inputCount; i++)
            {
                ScriptPlayable <TextHandlerBehaviour> inputPlayable =
                    (ScriptPlayable <TextHandlerBehaviour>)playable.GetInput(i);
                TextHandlerBehaviour input = inputPlayable.GetBehaviour();
                if (!input.isInQueue && playable.GetInputWeight(i) > float.Epsilon)
                {
                    texthandler.NextInQueue(input.clipTextSo, input.Speed);
                    if (Application.isPlaying)
                    {
                        input.isInQueue = true;
                    }
                }
            }
        }
        //////////////////////////////////////////////////////////////////////////
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            // try to get mixer
            var audioMixer = playerData as AudioMixer ?? SoundManager.Mixer;

            if (audioMixer == null)
            {
                return;
            }

            var finalValue = 0.0f;

            // calculate weights
            var inputCount = playable.GetInputCount();

            for (var i = 0; i < inputCount; i++)
            {
                //if (playable.IsPlayableOfType<ScriptPlayable<MixerPlayableBehaviour>>() == false)
                //    continue;

                // get clips data
                var inputWeight   = playable.GetInputWeight(i);
                var inputPlayable = (ScriptPlayable <AudioMixerPlayableBehaviour>)playable.GetInput(i);
                var input         = inputPlayable.GetBehaviour();

                // add weighted impact of the clip to final value
                finalValue += input.Value * inputWeight;
            }

            // assign result
            audioMixer.SetFloat(Parameter, finalValue);
        }
示例#7
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        m_trackBinding = playerData as CanvasGroup;
        if (m_trackBinding == null)
        {
            return;
        }

        if (!m_firstFrameHappened)
        {
            // 初期値の記憶
            m_initialValue       = m_trackBinding.alpha;
            m_firstFrameHappened = true;
        }

        // 全clipのalpha値をweightに応じて合計する
        int   inputCount = playable.GetInputCount();
        float alpha      = 0;

        for (int i = 0; i < inputCount; ++i)
        {
            var inputWeight   = playable.GetInputWeight(i);
            var inputPlayable = (ScriptPlayable <AlphaBehaviour>)playable.GetInput(i);
            var input         = inputPlayable.GetBehaviour();
            alpha += input.Alpha * inputWeight;
        }

        // 反映
        m_trackBinding.alpha = alpha;
    }
示例#8
0
        public static T FindInput <T>(Playable h, bool recursive = false) where T : PlayableBehaviour, new()
        {
            if (!h.IsValid())
            {
                return(null);
            }

            for (int port = 0; port < h.GetInputCount(); ++port)
            {
                var playable = h.GetInput(port);
                if (playable.IsValid())
                {
                    var type = playable.GetPlayableType();
                    if (type == typeof(T))
                    {
                        return(((ScriptPlayable <T>)playable).GetBehaviour());
                    }
                    else if (recursive)
                    {
                        return(FindInput <T>(playable, recursive));
                    }
                }
            }
            return(null);
        }
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        this.m_TrackBinding = (playerData as Image);
        if (this.m_TrackBinding == null)
        {
            return;
        }
        if (!this.m_FirstFrameHappened)
        {
            this.m_DefaultColor       = this.m_TrackBinding.color;
            this.m_FirstFrameHappened = true;
        }
        int   inputCount = playable.GetInputCount <Playable>();
        Color a          = Color.clear;
        float num        = 0f;
        float num2       = 0f;
        int   num3       = 0;

        for (int i = 0; i < inputCount; i++)
        {
            float inputWeight = playable.GetInputWeight(i);
            ScreenFaderBehaviour behaviour = ((ScriptPlayable <T>)playable.GetInput(i)).GetBehaviour();
            a   += behaviour.color * inputWeight;
            num += inputWeight;
            if (inputWeight > num2)
            {
                num2 = inputWeight;
            }
            if (!Mathf.Approximately(inputWeight, 0f))
            {
                num3++;
            }
        }
        this.m_TrackBinding.color = a + this.m_DefaultColor * (1f - num);
    }
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            if (m_Clips == null)
            {
                return;
            }

            int inputPort = 0;

            foreach (TimelineClip clip in m_Clips)
            {
                ScriptPlayable <VideoPlayableBehaviour> scriptPlayable =
                    (ScriptPlayable <VideoPlayableBehaviour>)playable.GetInput(inputPort);

                VideoPlayableBehaviour videoPlayableBehaviour = scriptPlayable.GetBehaviour();

                if (videoPlayableBehaviour != null)
                {
                    double preloadTime = Math.Max(0.0, videoPlayableBehaviour.preloadTime);
                    if (m_Director.time >= clip.start + clip.duration ||
                        m_Director.time <= clip.start - preloadTime)
                    {
                        videoPlayableBehaviour.StopVideo();
                    }
                    else if (m_Director.time > clip.start - preloadTime)
                    {
                        videoPlayableBehaviour.PrepareVideo();
                    }
                }

                ++inputPort;
            }
        }
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        // Use instead of the Play function
        var trackBinding = playerData as Record3DPlayback;

        if (trackBinding == null)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

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

            if (input == null || input.endLocation == null)
            {
                continue;
            }

            int frameIdx = (int)Math.Round(playableInput.GetTime() * input.endLocation.fps);
            input.endLocation.LoadFrame(frameIdx);
        }
    }
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        Camera trackBinding = playerData as Camera;

        if (trackBinding == null)
        {
            return;
        }

        if (!DefaultFOWValue.HasValue)
        {
            DefaultFOWValue = trackBinding.fieldOfView;
        }

        float totalWeight = 0f;
        float blendedFOW  = 0f;

        for (int i = 0, inputCount = playable.GetInputCount(); i < inputCount; i++)
        {
            ScriptPlayable <CameraDoTweenBehaviour> playableInput =
                (ScriptPlayable <CameraDoTweenBehaviour>)playable.GetInput(i);

            float weight = playable.GetInputWeight(i);
            CameraDoTweenBehaviour behaviour = playableInput.GetBehaviour();

            blendedFOW  += behaviour.Evaluate(playableInput.GetTime(), Durations[i]).FOW *weight;
            totalWeight += weight;
        }

        trackBinding.fieldOfView = blendedFOW + (1f - totalWeight) * DefaultFOWValue.Value;
    }
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            //Get our inputs
            int inputCount = playable.GetInputCount();

            //Calculate blended game time
            double blendedGameTime = 0;
            double totalWeight     = 0;

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

                blendedGameTime += input.gameTime * inputWeight;
                totalWeight     += inputWeight;
            }

            //We will only update world manager if we got some weights i.e. we are being affected by the timeline
            if (!Mathf.Approximately((float)totalWeight, 0f))
            {
                //Debug.Log("TW " + totalWeight + " " + blendedGameTime);
                WorldManager.Instance.SetDecimalTime(blendedGameTime);
            }
        }
 public override void PrepareFrame(Playable playable, FrameData info)
 {
     if (mixer.GetInputCount() == 0)
     {
         return;
     }
     timeToNextClip -= info.deltaTime;
     if (timeToNextClip <= 0f)
     {
         currentClipIndex++;
         if (currentClipIndex >= mixer.GetInputCount())
         {
             currentClipIndex = 0;
         }
         var currentClip = (AnimationClipPlayable)mixer.GetInput(currentClipIndex);
         currentClip.SetTime(0);
         // 一个一个播动画
         timeToNextClip = currentClip.GetAnimationClip().length;
     }
     for (int clipIndex = 0; clipIndex < mixer.GetInputCount(); clipIndex++)
     {
         if (clipIndex == currentClipIndex)
         {
             mixer.SetInputWeight(clipIndex, 1f);
         }
         else
         {
             mixer.SetInputWeight(clipIndex, 0);
         }
     }
 }
        private void SetInitialColor(Playable playable)
        {
            if (boundGameObject == null)
            {
                return;
            }

            Image image     = boundGameObject.GetComponent <Image>();
            var   enumlator = m_clips.GetEnumerator();

            enumlator.MoveNext();
            if (playable.GetInputCount <Playable>() > 0)
            {
                var myScriptPlayable = (ScriptPlayable <FaderPlayableBehaviour>)playable.GetInput(0);
                var myBehaviour      = myScriptPlayable.GetBehaviour();
                if (myBehaviour == null)
                {
                    return;
                }
#if false
                var clip = myBehaviour.m_clip;
#else
                var clip = enumlator.Current;
#endif
                var asset = clip.asset as FaderPlayableAsset;

                m_initialColor = asset.m_color;

                if (image != null)
                {
                    image.color = m_initialColor;
                }
            }
        }
示例#16
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        TextMeshProUGUI titulky      = playerData as TextMeshProUGUI;
        string          currentText  = "";
        float           currentAlpha = 0f;

        if (!titulky)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

        for (int i = 0; i < inputCount; i++)
        {
            float inputWeight = playable.GetInputWeight(i);
            if (inputWeight > 0f)
            {
                ScriptPlayable <TitulkyBehaviour> inputPlayable;
                inputPlayable = (ScriptPlayable <TitulkyBehaviour>)playable.GetInput(i);
                TitulkyBehaviour input = inputPlayable.GetBehaviour();

                currentText  = input.titulkyText;
                currentAlpha = inputWeight;
            }
        }
        titulky.text  = currentText;
        titulky.color = new Color(1, 1, 1, currentAlpha);
    }
示例#17
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        Renderer renderer     = playerData as Renderer;
        float    finalFloat   = 0;
        Vector4  finalVector4 = Vector4.zero;
        Color    finalColor   = Color.black;

        if (renderer == null)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

        float totalWeight = 0;

        for (int index = 0; index < inputCount; index++)
        {
            float weight        = playable.GetInputWeight(index);
            var   inputPlayable = (ScriptPlayable <ShaderPlayable>)playable.GetInput(index);
            var   behaviour     = inputPlayable.GetBehaviour();

            finalFloat   += behaviour.FloatVal * weight;
            finalVector4 += behaviour.VectorVal * weight;
            finalColor   += behaviour.ColorVal * weight;

            totalWeight += weight;
        }

        if (totalWeight < 0.5f)
        {
            return;
        }

        Material mat;

        if (Application.isPlaying)
        {
            mat = renderer.material;
        }
        else
        {
            mat = renderer.sharedMaterial;
        }

        switch (VariableType)
        {
        case ShaderTrack.ShaderControlType.SetFloat:
            mat.SetFloat(ShaderVarName, finalFloat);
            break;

        case ShaderTrack.ShaderControlType.SetVector:
            mat.SetVector(ShaderVarName, finalVector4);
            break;

        case ShaderTrack.ShaderControlType.SetColor:
            mat.SetColor(ShaderVarName, finalColor);
            break;
        }
    }
示例#18
0
    //Happens every frame in Edit mode.
    //Uses transform.position of the enemy to approximate what they would do in Play mode with the NavMeshAgent
    private void ProcessEditModeFrame(Playable playable)
    {
        previousInputFinalPosition = defaultPosition;
        int inputCount = playable.GetInputCount();

        for (int i = 0; i < inputCount; i++)
        {
            float inputWeight = playable.GetInputWeight(i);

            ScriptPlayable <EnemyControlBehaviour> inputPlayable;
            inputPlayable = (ScriptPlayable <EnemyControlBehaviour>)playable.GetInput(i);
            EnemyControlBehaviour input = inputPlayable.GetBehaviour();

            //final position je to isté ako targetposition
            finalPosition = input.targetPosition;

            if (inputWeight > 0f)
            {
                double progress = inputPlayable.GetTime() / inputPlayable.GetDuration();
                newPosition = Vector3.Lerp(previousInputFinalPosition, finalPosition, (float)progress);
                enemy.transform.position = newPosition;
                continue;
            }
            else
            {
                previousInputFinalPosition = finalPosition;                 //cached to act as initial position for the next input
            }
        }
    }
示例#19
0
    // NOTE: This function is called at runtime and edit time.  Keep that in mind when setting the values of properties.

    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        VisualEffect vfxComponent = playerData as VisualEffect;

        if (!vfxComponent)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

        for (int i = 0; i < inputCount; i++)
        {
            float inputWeight     = playable.GetInputWeight(i);
            bool  newEnabledState = inputWeight != 0.0f;

            var inputPlayable = (ScriptPlayable <VisualEffectActivationBehaviour>)playable.GetInput(i);
            var input         = inputPlayable.GetBehaviour();

            if (enabledStates[i] != newEnabledState)
            {
                if (newEnabledState)
                {
                    input.SendEventEnter(vfxComponent);
                }
                else
                {
                    input.SendEventExit(vfxComponent);
                }

                enabledStates[i] = newEnabledState;
            }
        }
    }
示例#20
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        var m_TrackBinding = playerData as TimelineLabel;

        if (m_TrackBinding == null)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

        string message = defaultText;

        int start = 0;

        for (int i = start; i < inputCount; i++)
        {
            float inputWeight = playable.GetInputWeight(i);
            if (inputWeight > 0)
            {
                var inputPlayable = (ScriptPlayable <Subtitle2Behaviour>)playable.GetInput(i);
                message = m_TrackBinding.message.texts[i];
                break;
            }
            else
            {
                continue;
            }
        }

        m_TrackBinding.label.text = message;
    }
示例#21
0
        public override void PrepareFrame(Playable playable, FrameData info)
        {
            if (!playable.IsValid() || !playable.IsPlayableOfType <AudioMixerPlayable>())
            {
                return;
            }

            var inputCount = playable.GetInputCount();

            for (int i = 0; i < inputCount; ++i)
            {
                if (playable.GetInputWeight(i) > 0.0f)
                {
                    var input = playable.GetInput(i);

                    if (input.IsValid() && input.IsPlayableOfType <AudioClipPlayable>())
                    {
                        var audioClipPlayable   = (AudioClipPlayable)input;
                        var audioClipProperties = input.GetHandle().GetObject <AudioClipProperties>();

                        audioClipPlayable.SetVolume(Mathf.Clamp01(volume * audioClipProperties.volume));
                        audioClipPlayable.SetStereoPan(Mathf.Clamp(stereoPan, -1.0f, 1.0f));
                        audioClipPlayable.SetSpatialBlend(Mathf.Clamp01(spatialBlend));
                    }
                }
            }
        }
示例#22
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();
                    }
                }
            }
        }
示例#23
0
        //ProcessFrame is like "the Update of Timeline"
        public override void ProcessFrame(Playable playable, FrameData info, object arg)
        {
            //Insert logic per frame in here
            var inputPlayable = (ScriptPlayable <SimpleBehaviour>)playable.GetInput(0);

            LogCat.Log(message);
        }
示例#24
0
        // NOTE: This function is called at runtime and edit time.  Keep that in mind when setting the values of properties.
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            LeapPlayableProvider provider = playerData as LeapPlayableProvider;

            if (!provider)
            {
                return;
            }

            int inputCount = playable.GetInputCount();

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

                if (inputWeight > 0 && input.recording != null)
                {
                    if (input.recording.Sample((float)inputPlayable.GetTime(), _frame, clampTimeToValid: true))
                    {
                        provider.SetCurrentFrame(_frame);
                        break;
                    }
                }
            }
        }
示例#25
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        GameObject subsObject   = playerData as GameObject;
        string     currentText  = "";
        float      currentAlpha = 0f;

        if (!subsObject)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

        for (int i = 0; i < inputCount; i++)
        {
            float inputWeight = playable.GetInputWeight(i);
            if (inputWeight > 0f)
            {
                ScriptPlayable <SubtitleBehaviour> inputPlayable;
                inputPlayable = (ScriptPlayable <SubtitleBehaviour>)playable.GetInput(i);
                SubtitleBehaviour input = inputPlayable.GetBehaviour();

                currentText  = input.subtitleText;
                currentAlpha = inputWeight;
            }
        }
        UpdateText(subsObject, currentText, currentAlpha);
    }
示例#26
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            var binding = (BindingType)playerData;

            if (binding == null)
            {
                return;
            }

            int inputCount = playable.GetInputCount();

            if (inputCount == 0)
            {
                return;
            }

            float totalWeight = 0;

            Init(binding);
            for (int i = 0; i < inputCount; i++)
            {
                var   inputPlayable  = (ScriptPlayable <BehaviourType>)playable.GetInput(i);
                var   inputBehaviour = inputPlayable.GetBehaviour();
                float inputWeight    = playable.GetInputWeight(i);
                totalWeight += inputWeight;
                Input(binding, inputBehaviour, inputWeight);
            }
            Output(binding, totalWeight);
        }
示例#27
0
            private static void GetPlayableBehaviours <T>(Playable root, ref List <T> playables) where T : class
            {
                int inputCount = root.GetInputCount();

                for (int i = 0; i < inputCount; i++)
                {
                    Playable node = root.GetInput(i);

                    if (node.IsValid())
                    {
                        Type playableType = node.GetPlayableType();

                        if (SystemUtils.IsTypeOf(typeof(T), playableType))
                        {
                            T playable = GetPlayableBehaviour(node, playableType) as T;

                            if (playable != null)
                            {
                                playables.Add(playable);
                            }
                        }

                        GetPlayableBehaviours(node, ref playables);
                    }
                }
            }
示例#28
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            PlayerController target     = playerData as PlayerController;
            bool             allowInput = false;

            if (!target)
            {
                return;
            }

            int clipCount = playable.GetInputCount();

            for (int i = 0; i < clipCount; i++)
            {
                float weight = playable.GetInputWeight(i);

                if (weight > 0.6f)
                {
                    var inputPlayable = (ScriptPlayable <PlayerControlBehaviour>)playable.GetInput(i);
                    var input         = inputPlayable.GetBehaviour();

                    allowInput = input.allowInput;
                }
            }
            target.ReceiveInput = allowInput;
        }
示例#29
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            //Get our inputs
            int inputCount = playable.GetInputCount();

            //Calculate blended snow power
            double blendedSnowPower = 0;
            double totalWeight      = 0;

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

                blendedSnowPower += input.snowPower * inputWeight;
                totalWeight      += inputWeight;
            }

            //We will only update world manager if we got some weights i.e. we are being affected by the timeline
            if (!Mathf.Approximately((float)totalWeight, 0f))
            {
                WorldManager.Instance.SnowPower = (float)blendedSnowPower;
            }
        }
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            int    inputCount = playable.GetInputCount();
            string stateName  = "";
            AnimatorPlayableBehaviour behaviour = null;
            int index = findActiveIndex(playable, lastIndex_);

            if (index == -1)
            {
                return;
            }
            if (lastIndex_ == index)
            {
                return;
            }
            lastIndex_ = index;
            var inputPlayable = (ScriptPlayable <AnimatorPlayableBehaviour>)playable.GetInput(index);
            var input         = inputPlayable.GetBehaviour();

            stateName = input.stateName;
            behaviour = input;

            if (string.IsNullOrEmpty(stateName))
            {
                return;
            }

            // 反映
            var binding = playerData as Animator;

            if (binding != null)
            {
                binding.Play(stateName, 0, 0f);
            }
        }