/// <summary>Destroy any existing pipeline container.</summary> private void DestroyPipeline() { List <Transform> oldPipeline = new List <Transform>(); foreach (Transform child in transform) { if (child.GetComponent <CinemachinePipeline>() != null) { oldPipeline.Add(child); } } if (!RuntimeUtility.IsPrefab(gameObject)) { foreach (Transform child in oldPipeline) { if (DestroyPipelineOverride != null) { DestroyPipelineOverride(child.gameObject); } else { Destroy(child.gameObject); } } m_ComponentOwner = null; } PreviousStateIsValid = false; }
private void UpdateRigCache() { if (mIsDestroyed) { return; } bool isPrefab = RuntimeUtility.IsPrefab(gameObject); #if UNITY_EDITOR // 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) { if (!isPrefab) // can't paste to a prefab { var copyFrom = m_Rigs; DestroyRigs(); m_Rigs = CreateRigs(copyFrom); } } #endif // Early out if we're up to date if (mOrbitals != null && mOrbitals.Length == 3) { return; } // Locate existing rigs, and recreate them if any are missing if (LocateExistingRigs(RigNames, false) != 3 && !isPrefab) { DestroyRigs(); m_Rigs = CreateRigs(null); LocateExistingRigs(RigNames, true); } #if UNITY_EDITOR foreach (var rig in m_Rigs) { // Configure the UI if (rig == null) { continue; } rig.m_ExcludedPropertiesInInspector = m_CommonLens ? new string[] { "m_Script", "Header", "Extensions", "m_Priority", "m_Transitions", "m_Follow", "m_StandbyUpdate", "m_Lens" } : new string[] { "m_Script", "Header", "Extensions", "m_Priority", "m_Transitions", "m_Follow", "m_StandbyUpdate" }; rig.m_LockStageInInspector = new CinemachineCore.Stage[] { CinemachineCore.Stage.Body }; } #endif // 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); }
void Reset() { #if UNITY_EDITOR if (RuntimeUtility.IsPrefab(gameObject)) { Debug.Log("You cannot reset a prefab instance. " + "First disconnect this instance from the prefab, or enter Prefab Edit mode"); return; } #endif DestroyRigs(); }
[SerializeField][HideInInspector] private Transform m_ComponentOwner = null; // serialized to handle copy/paste void UpdateComponentPipeline() { bool isPrefab = RuntimeUtility.IsPrefab(gameObject); #if UNITY_EDITOR // Did we just get copy/pasted? if (m_ComponentOwner != null && m_ComponentOwner.parent != transform) { if (!isPrefab) // can't paste to a prefab { CinemachineVirtualCamera copyFrom = (m_ComponentOwner.parent != null) ? m_ComponentOwner.parent.gameObject.GetComponent <CinemachineVirtualCamera>() : null; DestroyPipeline(); m_ComponentOwner = CreatePipeline(copyFrom); } } if (m_ComponentOwner != null) { SetFlagsForHiddenChild(m_ComponentOwner.gameObject); } #endif // Early out if we're up-to-date if (m_ComponentOwner != null && m_ComponentPipeline != null) { return; } m_ComponentOwner = null; List <CinemachineComponentBase> list = new List <CinemachineComponentBase>(); foreach (Transform child in transform) { if (child.GetComponent <CinemachinePipeline>() != null) { m_ComponentOwner = child; CinemachineComponentBase[] components = child.GetComponents <CinemachineComponentBase>(); foreach (CinemachineComponentBase c in components) { if (c.enabled) { list.Add(c); } } } } // Make sure we have a pipeline owner if (m_ComponentOwner == null && !isPrefab) { m_ComponentOwner = CreatePipeline(null); } // Make sure the pipeline stays hidden, even through prefab if (m_ComponentOwner != null) { SetFlagsForHiddenChild(m_ComponentOwner.gameObject); } if (m_ComponentOwner != null && m_ComponentOwner.gameObject != null) { // Sort the pipeline list.Sort((c1, c2) => (int)c1.Stage - (int)c2.Stage); m_ComponentPipeline = list.ToArray(); } }