internal void PushTo(CinemachineComposer c)
 {
     c.m_TrackedObjectOffset = m_LookAtOffset;
     c.m_HorizontalDamping   = m_HorizontalDamping;
     c.m_VerticalDamping     = m_VerticalDamping;
     c.m_ScreenX             = m_ScreenX;
     c.m_ScreenY             = m_ScreenY;
     c.m_DeadZoneWidth       = m_DeadZoneWidth;
     c.m_DeadZoneHeight      = m_DeadZoneHeight;
     c.m_SoftZoneWidth       = m_SoftZoneWidth;
     c.m_SoftZoneHeight      = m_SoftZoneHeight;
     c.m_BiasX = m_BiasX;
     c.m_BiasY = m_BiasY;
 }
 internal void PullFrom(CinemachineComposer c)
 {
     m_LookAtOffset      = c.m_TrackedObjectOffset;
     m_HorizontalDamping = c.m_HorizontalDamping;
     m_VerticalDamping   = c.m_VerticalDamping;
     m_ScreenX           = c.m_ScreenX;
     m_ScreenY           = c.m_ScreenY;
     m_DeadZoneWidth     = c.m_DeadZoneWidth;
     m_DeadZoneHeight    = c.m_DeadZoneHeight;
     m_SoftZoneWidth     = c.m_SoftZoneWidth;
     m_SoftZoneHeight    = c.m_SoftZoneHeight;
     m_BiasX             = c.m_BiasX;
     m_BiasY             = c.m_BiasY;
 }
 internal void Lerp(CinemachineComposer c, float t)
 {
     c.m_TrackedObjectOffset = Vector3.Lerp(c.m_TrackedObjectOffset, m_LookAtOffset, t);
     c.m_HorizontalDamping   = Mathf.Lerp(c.m_HorizontalDamping, m_HorizontalDamping, t);
     c.m_VerticalDamping     = Mathf.Lerp(c.m_VerticalDamping, m_VerticalDamping, t);
     c.m_ScreenX             = Mathf.Lerp(c.m_ScreenX, m_ScreenX, t);
     c.m_ScreenY             = Mathf.Lerp(c.m_ScreenY, m_ScreenY, t);
     c.m_DeadZoneWidth       = Mathf.Lerp(c.m_DeadZoneWidth, m_DeadZoneWidth, t);
     c.m_DeadZoneHeight      = Mathf.Lerp(c.m_DeadZoneHeight, m_DeadZoneHeight, t);
     c.m_SoftZoneWidth       = Mathf.Lerp(c.m_SoftZoneWidth, m_SoftZoneWidth, t);
     c.m_SoftZoneHeight      = Mathf.Lerp(c.m_SoftZoneHeight, m_SoftZoneHeight, t);
     c.m_BiasX = Mathf.Lerp(c.m_BiasX, m_BiasX, t);
     c.m_BiasY = Mathf.Lerp(c.m_BiasY, m_BiasY, t);
 }
示例#4
0
        private CinemachineVirtualCamera[] CreateRigs(CinemachineVirtualCamera[] copyFrom)
        {
            // Invalidate the cache
            mOrbitals = null;
            float[] softCenterDefaultsV        = new float[] { 0.5f, 0.55f, 0.6f };
            CinemachineVirtualCamera[] newRigs = new CinemachineVirtualCamera[3];
            for (int i = 0; i < RigNames.Length; ++i)
            {
                CinemachineVirtualCamera src = null;
                if (copyFrom != null && copyFrom.Length > i)
                {
                    src = copyFrom[i];
                }

                if (CreateRigOverride != null)
                {
                    newRigs[i] = CreateRigOverride(this, RigNames[i], src);
                }
                else
                {
                    // Create a new rig with default components
                    GameObject go = new GameObject(RigNames[i]);
                    go.transform.parent = transform;
                    newRigs[i]          = go.AddComponent <CinemachineVirtualCamera>();
                    if (src != null)
                    {
                        ReflectionHelpers.CopyFields(src, newRigs[i]);
                    }
                    else
                    {
                        go = newRigs[i].GetComponentOwner().gameObject;
                        go.AddComponent <CinemachineOrbitalTransposer>();
                        go.AddComponent <CinemachineComposer>();
                    }
                }

                // Set up the defaults
                newRigs[i].InvalidateComponentPipeline();
                CinemachineOrbitalTransposer orbital = newRigs[i].GetCinemachineComponent <CinemachineOrbitalTransposer>();
                if (orbital == null)
                {
                    orbital = newRigs[i].AddCinemachineComponent <CinemachineOrbitalTransposer>(); // should not happen
                }
                if (src == null)
                {
                    // Only set defaults if not copying
                    orbital.m_YawDamping = 0;
                    CinemachineComposer composer = newRigs[i].GetCinemachineComponent <CinemachineComposer>();
                    if (composer != null)
                    {
                        composer.m_HorizontalDamping = composer.m_VerticalDamping = 0;
                        composer.m_ScreenX           = 0.5f;
                        composer.m_ScreenY           = softCenterDefaultsV[i];
                        composer.m_DeadZoneWidth     = composer.m_DeadZoneHeight = 0.1f;
                        composer.m_SoftZoneWidth     = composer.m_SoftZoneHeight = 0.8f;
                        composer.m_BiasX             = composer.m_BiasY = 0;
                    }
                }
            }
            return(newRigs);
        }
示例#5
0
 private CinemachineVirtualCamera[] CreateRigs(CinemachineVirtualCamera[] copyFrom)
 {
     this.mOrbitals = null;
     float[] array = new float[]
     {
         0.5f,
         0.55f,
         0.6f
     };
     CinemachineVirtualCamera[] array2 = new CinemachineVirtualCamera[3];
     for (int i = 0; i < CinemachineFreeLook.RigNames.Length; i++)
     {
         CinemachineVirtualCamera cinemachineVirtualCamera = null;
         if (copyFrom != null && copyFrom.Length > i)
         {
             cinemachineVirtualCamera = copyFrom[i];
         }
         if (CinemachineFreeLook.CreateRigOverride != null)
         {
             array2[i] = CinemachineFreeLook.CreateRigOverride(this, CinemachineFreeLook.RigNames[i], cinemachineVirtualCamera);
         }
         else
         {
             array2[i] = new GameObject(CinemachineFreeLook.RigNames[i])
             {
                 transform =
                 {
                     parent = base.transform
                 }
             }.AddComponent <CinemachineVirtualCamera>();
             if (cinemachineVirtualCamera != null)
             {
                 ReflectionHelpers.CopyFields(cinemachineVirtualCamera, array2[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
             }
             else
             {
                 GameObject gameObject = array2[i].GetComponentOwner().gameObject;
                 gameObject.AddComponent <CinemachineOrbitalTransposer>();
                 gameObject.AddComponent <CinemachineComposer>();
             }
         }
         array2[i].InvalidateComponentPipeline();
         CinemachineOrbitalTransposer cinemachineOrbitalTransposer = array2[i].GetCinemachineComponent <CinemachineOrbitalTransposer>();
         if (cinemachineOrbitalTransposer == null)
         {
             cinemachineOrbitalTransposer = array2[i].AddCinemachineComponent <CinemachineOrbitalTransposer>();
         }
         if (cinemachineVirtualCamera == null)
         {
             cinemachineOrbitalTransposer.m_YawDamping = 0f;
             CinemachineComposer cinemachineComponent = array2[i].GetCinemachineComponent <CinemachineComposer>();
             if (cinemachineComponent != null)
             {
                 cinemachineComponent.m_HorizontalDamping = (cinemachineComponent.m_VerticalDamping = 0f);
                 cinemachineComponent.m_ScreenX           = 0.5f;
                 cinemachineComponent.m_ScreenY           = array[i];
                 cinemachineComponent.m_DeadZoneWidth     = (cinemachineComponent.m_DeadZoneHeight = 0.1f);
                 cinemachineComponent.m_SoftZoneWidth     = (cinemachineComponent.m_SoftZoneHeight = 0.8f);
                 cinemachineComponent.m_BiasX             = (cinemachineComponent.m_BiasY = 0f);
             }
         }
     }
     return(array2);
 }
示例#6
0
        private void CreateRigs(CinemachineVirtualCamera[] copyFrom)
        {
            // Invalidate the cache
            m_Rigs     = null;
            mOribitals = null;

            string[] rigNames            = RigNames;
            float[]  softCenterDefaultsV = new float[] { 0.5f, 0.55f, 0.6f };
            for (int i = 0; i < rigNames.Length; ++i)
            {
                CinemachineVirtualCamera src = null;
                if (copyFrom != null && copyFrom.Length > i)
                {
                    src = copyFrom[i];
                }

                CinemachineVirtualCamera rig = null;
                if (CreateRigOverride != null)
                {
                    rig = CreateRigOverride(this, rigNames[i], src);
                }
                else
                {
                    // If there is an existing rig with this name, delete it
                    List <Transform> list = new List <Transform>();
                    foreach (Transform child in transform)
                    {
                        if (child.GetComponent <CinemachineVirtualCamera>() != null &&
                            child.gameObject.name == rigNames[i])
                        {
                            list.Add(child);
                        }
                    }
                    foreach (Transform child in list)
                    {
                        DestroyImmediate(child.gameObject);
                    }

                    // Create a new rig with default components
                    GameObject go = new GameObject(rigNames[i]);
                    go.transform.parent = transform;
                    rig = go.AddComponent <CinemachineVirtualCamera>();
                    if (src != null)
                    {
                        ReflectionHelpers.CopyFields(src, rig);
                    }
                    else
                    {
                        go = rig.GetComponentOwner().gameObject;
                        go.AddComponent <CinemachineOrbitalTransposer>();
                        go.AddComponent <CinemachineComposer>();
                    }
                }

                // Set up the defaults
                rig.InvalidateComponentPipeline();
                CinemachineOrbitalTransposer orbital = rig.GetCinemachineComponent <CinemachineOrbitalTransposer>();
                if (orbital == null)
                {
                    orbital = rig.AddCinemachineComponent <CinemachineOrbitalTransposer>(); // should not happen
                }
                if (src == null)
                {
                    // Only set defaults if not copying
                    orbital.m_Radius       = DefaultRadius[i];
                    orbital.m_HeightOffset = DefaultHeight[i];
                    CinemachineComposer composer = rig.GetCinemachineComponent <CinemachineComposer>();
                    if (composer != null)
                    {
                        composer.m_HorizontalDamping = composer.m_VerticalDamping = 0;
                        composer.m_ScreenX           = 0.5f;
                        composer.m_ScreenY           = softCenterDefaultsV[i];
                        composer.m_DeadZoneWidth     = composer.m_DeadZoneHeight = 0;
                        composer.m_SoftZoneWidth     = composer.m_SoftZoneHeight = 0.8f;
                        composer.m_BiasX             = composer.m_BiasY = 0;
                    }
                }
            }
        }