Inheritance: PlayableBehaviour
コード例 #1
0
        public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
        {
            var playable = ScriptPlayable <CMDollyCartBehaviour> .Create(graph, template);

            CMDollyCartBehaviour clone = playable.GetBehaviour();

            // clone.dollyCart = dollyCart.Resolve(graph.GetResolver());
            return(playable);
        }
コード例 #2
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            dollyCart = playerData as CinemachineDollyCart;
            // float finalSpeed = 0f;
            // float finalWeight = 0f;

            if (!dollyCart)
            {
                return;
            }

            CacheStartState();

            int inputCount = playable.GetInputCount(); //get the number of all clips on this track


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

                // finalWeight += inputWeight;

                // Use the above variables to process each frame of this playable.
                // finalSpeed += input.GetSpeed() * inputWeight;
                if (inputWeight == 1)
                {
                    // var maxTime = Mathf.Min((float)inputPlayable.GetTime(), (float)inputPlayable.GetDuration());
                    dollyCart.m_Speed = 0;

                    switch (input.positionMode)
                    {
                    case CMDollyCartBehaviour.PositionMode.BaseOnOriginal:
                        dollyCart.m_Position = m_DefaultPosition + (float)(inputPlayable.GetTime() * input.speed);
                        break;

                    case CMDollyCartBehaviour.PositionMode.CustomStart:
                        dollyCart.m_Position = input.customStart + (float)(inputPlayable.GetTime() * input.speed);
                        break;

                    case CMDollyCartBehaviour.PositionMode.DeltaTime:
                        dollyCart.m_Position += (float)(info.deltaTime * input.speed);
                        break;
                    }
                }
            }

            // Debug.Log(finalWeight);

            // dollyCart.m_Speed = 0;

            // if (finalWeight > 0)
            //     dollyCart.m_Position = m_DefaultPosition + (float)(playable.GetTime() * finalSpeed);
        }