Пример #1
0
    /// <summary>
    /// <see cref="RequestChangeCM(CMType)"/>
    /// </summary>
    private void DoLateUpdate_ChangeCM(float deltaTime)
    {
        m_ChangingCMBlendReaminTime = Mathf.Max(0.0f, m_ChangingCMBlendReaminTime - deltaTime);
        if (m_ChangingCMBlendReaminTime > 0 ||
            m_ChangingCMs.Count == 0 ||
            CinemachineCore.Instance.BrainCount > 1)
        {
            return;
        }

        CMType cmType = m_ChangingCMs.Dequeue();

        if (m_LastCMType == cmType)
        {
            Leyoutech.Utility.DebugUtility.LogWarning(CameraManager.LOG_TAG, "Repeat change CM to " + cmType);
            return;
        }

        if (!m_MainCMBrain.enabled)
        {
            m_MainCMBrain.enabled = true;
        }

        CinemachineBlendDefinition cinemachineBlendDefinition = m_MainCMBrain.m_CustomBlends.GetBlendForVirtualCameras(m_LastCMType.ToString(), cmType.ToString(), m_MainCMBrain.m_DefaultBlend);

        Leyoutech.Utility.DebugUtility.Log(CameraManager.LOG_TAG
                                           , string.Format("Change CM form {0} to {1} use blend definition Style:{2} Time:{3}"
                                                           , m_LastCMType
                                                           , cmType
                                                           , cinemachineBlendDefinition.m_Style
                                                           , cinemachineBlendDefinition.m_Time));

        try
        {
            Leyoutech.Utility.DebugUtility.Log(CameraManager.LOG_TAG, "Begin invoke CM Changed");
            _OnCMChanged?.Invoke(m_LastCMType, cmType);
            Leyoutech.Utility.DebugUtility.Log(CameraManager.LOG_TAG, "End invoke CM Changed");
        }
        catch (Exception e)
        {
            Leyoutech.Utility.DebugUtility.LogError(CameraManager.LOG_TAG, "Invoke CM Changed Exception:\n" + e.ToString());
        }

        m_ChangingCMBlendReaminTime = cinemachineBlendDefinition.m_Time;

        TransitionBlendDefinition transitionBlendDefinition = m_MainCameraTransitionBlenderSettings.FindBlend(m_LastCMType.ToString(), cmType.ToString());

        m_CMs[(int)cmType].ApplyTransitionBlendDefinition(transitionBlendDefinition);
        m_CMs[(int)cmType].SetEnable(true);

        if (m_LastCMType != CMType.Notset)
        {
            m_CMs[(int)m_LastCMType].SetEnable(false);
        }

        m_LastCMType = cmType;
    }
Пример #2
0
    private void DoGUICM(Config config)
    {
        config.BeginToolbarHorizontal();
        if (config.ToolbarButton(m_MainCMBrain.enabled, "Brain"))
        {
            m_MainCMBrain.enabled = !m_MainCMBrain.enabled;
        }
        for (int iCM = 0; iCM < m_CMs.Length; iCM++)
        {
            CMType cmType = (CMType)iCM;
            if (config.ToolbarButton(m_CMs[iCM].IsLive(), cmType.ToString()))
            {
                RequestChangeCM(cmType);
            }
        }
        config.EndHorizontal();

        if (!_ForDebug.DisplayDetail)
        {
            return;
        }

        for (int iCM = 0; iCM < m_CMs.Length; iCM++)
        {
            if (!m_CMs[iCM].IsLive())
            {
                continue;
            }

            CinemachineVirtualCameraBase iterCM = m_CMs[iCM].GetCM_VirtualCameraBase();
            GUILayout.Label(((CMType)iCM).ToString()
                            , (int)m_LastCMType == iCM
                                        ? config.ImportantLabelStyle
                                        : config.LabelStyle);

            GUILayout.Box(string.Format("Priority:{0} Follow:({1}) LookAt:({2})"
                                        , iterCM.Priority
                                        , iterCM.Follow != null
                                                ? iterCM.Follow.name
                                                : "None"
                                        , iterCM.LookAt != null
                                                ? iterCM.LookAt.name
                                                : "None")
                          , config.BoxStyle);

            TransitionBlendDefinition transitionBlendDefinition = m_CMs[iCM].GetTransitionBlendDefinition();
            GUILayout.Box(string.Format("Transition: BlendHint({0}) InheritPosition({1})"
                                        , transitionBlendDefinition.BlendHint
                                        , transitionBlendDefinition.InheritPosition)
                          , config.BoxStyle);

            if (iterCM.Follow)
            {
                Vector3 cameraToFollow = iterCM.Follow.position - GetCamera().transform.position;
                GUILayout.Box(string.Format("To Follow Distance:{0:F2} - Height:{1:F2} - Horizontal:{2:F2}"
                                            , cameraToFollow.magnitude
                                            , cameraToFollow.y
                                            , new Vector2(cameraToFollow.x, cameraToFollow.z).magnitude)
                              , config.BoxStyle);
            }

            if (iterCM is CinemachineFreeLook)
            {
                CinemachineFreeLook iterFreeLookCM = iterCM as CinemachineFreeLook;
                GUILayout.Box(string.Format("Axis: Value({0}) MaxSpeed({1})"
                                            , new Vector2(iterFreeLookCM.m_XAxis.Value, iterFreeLookCM.m_YAxis.Value)
                                            , new Vector2(iterFreeLookCM.m_XAxis.m_MaxSpeed, iterFreeLookCM.m_YAxis.m_MaxSpeed))
                              , config.BoxStyle);
            }
        }
    }