Пример #1
0
        private void UpdateRigCache()
        {
            //UnityEngine.Profiling.Profiler.BeginSample("CinemachineFreeLook.UpdateRigCache");
            if (mIsDestroyed)
            {
                //UnityEngine.Profiling.Profiler.EndSample();
                return;
            }

            // Special condition: Did we just get copy/pasted?
            if (m_Rigs != null && m_Rigs.Length == 3 && m_Rigs[0] != null && m_Rigs[0].transform.parent != transform)
            {
                DestroyRigs();
                m_Rigs = CreateRigs(m_Rigs);
            }

            // Early out if we're up to date
            if (mOrbitals != null && mOrbitals.Length == 3)
            {
                //UnityEngine.Profiling.Profiler.EndSample();
                return;
            }

            // Locate existing rigs, and recreate them if any are missing
            if (LocateExistingRigs(RigNames, false) != 3)
            {
                DestroyRigs();
                m_Rigs = CreateRigs(null);
                LocateExistingRigs(RigNames, true);
            }

            foreach (var rig in m_Rigs)
            {
                // Configure the UI
                rig.m_ExcludedPropertiesInInspector = m_CommonLens
                    ? new string[] { "m_Script", "Header", "Extensions", "m_Priority", "m_Follow", "m_Lens" }
                    : new string[] { "m_Script", "Header", "Extensions", "m_Priority", "m_Follow" };
                rig.m_LockStageInInspector = new CinemachineCore.Stage[] { CinemachineCore.Stage.Body };
            }

            // Create the blend objects
            mBlendA = new CinemachineBlend(m_Rigs[1], m_Rigs[0], AnimationCurve.Linear(0, 0, 1, 1), 1, 0);
            mBlendB = new CinemachineBlend(m_Rigs[2], m_Rigs[1], AnimationCurve.Linear(0, 0, 1, 1), 1, 0);

            // Horizontal rotation clamped to [0,360] (with wraparound)
            m_XAxis.SetThresholds(0f, 360f, true);

            // Vertical rotation cleamped to [0,1] as it is a t-value for the
            // catmull-rom spline going through the 3 points on the rig
            m_YAxis.SetThresholds(0f, 1f, false);
            //UnityEngine.Profiling.Profiler.EndSample();
        }
Пример #2
0
 private void OnEnable()
 {
     m_HorizontalAxis.SetThresholds(-180f, 180f, true);
     m_VerticalAxis.SetThresholds(-90, 90, false);
 }