コード例 #1
0
        protected CameraState InvokeComponentPipeline(
            ref CameraState state, Vector3 worldUp, float deltaTime)
        {
            UpdateComponentCache();

            // Extensions first
            InvokePrePipelineMutateCameraStateCallback(this, ref state, deltaTime);

            // Apply the component pipeline
            for (CinemachineCore.Stage stage = CinemachineCore.Stage.Body;
                 stage <= CinemachineCore.Stage.Finalize; ++stage)
            {
                var c = m_Components[(int)stage];
                if (c != null)
                {
                    c.PrePipelineMutateCameraState(ref state, deltaTime);
                }
            }
            CinemachineComponentBase postAimBody = null;

            for (CinemachineCore.Stage stage = CinemachineCore.Stage.Body;
                 stage <= CinemachineCore.Stage.Finalize; ++stage)
            {
                var c = m_Components[(int)stage];
                if (c != null)
                {
                    if (stage == CinemachineCore.Stage.Body && c.BodyAppliesAfterAim)
                    {
                        postAimBody = c;
                        continue; // do the body stage of the pipeline after Aim
                    }
                    c.MutateCameraState(ref state, deltaTime);
                }
                InvokePostPipelineStageCallback(this, stage, ref state, deltaTime);
                if (stage == CinemachineCore.Stage.Aim)
                {
                    if (c == null)
                    {
                        state.BlendHint |= CameraState.BlendHintValue.IgnoreLookAtTarget; // no aim
                    }
                    // If we have saved a Body for after Aim, do it now
                    if (postAimBody != null)
                    {
                        postAimBody.MutateCameraState(ref state, deltaTime);
                        InvokePostPipelineStageCallback(this, CinemachineCore.Stage.Body, ref state, deltaTime);
                    }
                }
            }

            return(state);
        }
コード例 #2
0
        protected CameraState InvokeComponentPipeline(
            ref CameraState state, Vector3 worldUp, float deltaTime)
        {
            UpdateComponentCache();

            // Extensions first
            InvokePrePipelineMutateCameraStateCallback(this, ref state, deltaTime);

            // Apply the component pipeline
            for (CinemachineCore.Stage stage = CinemachineCore.Stage.Body;
                 stage <= CinemachineCore.Stage.Finalize; ++stage)
            {
                var c = m_Components[(int)stage];
                if (c != null)
                {
                    c.PrePipelineMutateCameraState(ref state, deltaTime);
                }
            }
            CinemachineComponentBase postAimBody = null;

            for (CinemachineCore.Stage stage = CinemachineCore.Stage.Body;
                 stage <= CinemachineCore.Stage.Finalize; ++stage)
            {
                if (stage == CinemachineCore.Stage.Finalize && postAimBody != null)
                {
                    postAimBody.MutateCameraState(ref state, deltaTime);
                }

                var c = m_Components[(int)stage];
                if (c != null)
                {
                    if (stage == CinemachineCore.Stage.Body && c.BodyAppliesAfterAim)
                    {
                        postAimBody = c;
                    }
                    else
                    {
                        c.MutateCameraState(ref state, deltaTime);
                    }
                }
                else if (stage == CinemachineCore.Stage.Aim)
                {
                    state.BlendHint |= CameraState.BlendHintValue.IgnoreLookAtTarget; // no aim
                }
                InvokePostPipelineStageCallback(this, stage, ref state, deltaTime);
            }

            return(state);
        }
 static int GetCinemachineComponent(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Cinemachine.CinemachineVirtualCamera obj  = (Cinemachine.CinemachineVirtualCamera)ToLua.CheckObject <Cinemachine.CinemachineVirtualCamera>(L, 1);
         Cinemachine.CinemachineCore.Stage    arg0 = (Cinemachine.CinemachineCore.Stage)ToLua.CheckObject(L, 2, typeof(Cinemachine.CinemachineCore.Stage));
         Cinemachine.CinemachineComponentBase o    = obj.GetCinemachineComponent(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #4
0
        private CameraState CalculateNewState(Vector3 worldUp, float deltaTime)
        {
            FollowTargetAttachment = 1;
            LookAtTargetAttachment = 1;

            // Initialize the camera state, in case the game object got moved in the editor
            CameraState state = PullStateFromVirtualCamera(worldUp, ref m_Lens);

            Transform lookAtTarget = LookAt;

            if (lookAtTarget != mCachedLookAtTarget)
            {
                mCachedLookAtTarget     = lookAtTarget;
                mCachedLookAtTargetVcam = null;
                if (lookAtTarget != null)
                {
                    mCachedLookAtTargetVcam = lookAtTarget.GetComponent <CinemachineVirtualCameraBase>();
                }
            }
            if (lookAtTarget != null)
            {
                if (mCachedLookAtTargetVcam != null)
                {
                    state.ReferenceLookAt = mCachedLookAtTargetVcam.State.FinalPosition;
                }
                else
                {
                    state.ReferenceLookAt = TargetPositionCache.GetTargetPosition(lookAtTarget);
                }
            }

            // Update the state by invoking the component pipeline
            UpdateComponentPipeline(); // avoid GetComponentPipeline() here because of GC

            // Extensions first
            InvokePrePipelineMutateCameraStateCallback(this, ref state, deltaTime);

            // Then components
            if (m_ComponentPipeline == null)
            {
                state.BlendHint |= CameraState.BlendHintValue.IgnoreLookAtTarget;
                for (var stage = CinemachineCore.Stage.Body; stage <= CinemachineCore.Stage.Finalize; ++stage)
                {
                    InvokePostPipelineStageCallback(this, stage, ref state, deltaTime);
                }
            }
            else
            {
                for (int i = 0; i < m_ComponentPipeline.Length; ++i)
                {
                    m_ComponentPipeline[i].PrePipelineMutateCameraState(ref state, deltaTime);
                }

                CinemachineComponentBase postAimBody = null;
                int componentIndex = 0;
                for (var stage = CinemachineCore.Stage.Body; stage <= CinemachineCore.Stage.Finalize; ++stage)
                {
                    if (stage == CinemachineCore.Stage.Finalize && postAimBody != null)
                    {
                        postAimBody.MutateCameraState(ref state, deltaTime);
                    }

                    var c = componentIndex < m_ComponentPipeline.Length
                        ? m_ComponentPipeline[componentIndex] : null;
                    if (c != null && stage == c.Stage)
                    {
                        ++componentIndex;
                        if (stage == CinemachineCore.Stage.Body && c.BodyAppliesAfterAim)
                        {
                            postAimBody = c;
                        }
                        else
                        {
                            c.MutateCameraState(ref state, deltaTime);
                        }
                    }
                    else if (stage == CinemachineCore.Stage.Aim)
                    {
                        state.BlendHint |= CameraState.BlendHintValue.IgnoreLookAtTarget;
                    }

                    InvokePostPipelineStageCallback(this, stage, ref state, deltaTime);
                }
            }
            return(state);
        }