/// <summary>Add a component to the cinemachine pipeline.</summary> public T AddCinemachineComponent <T>() where T : CinemachineComponentBase { // Get the existing components Transform owner = GetComponentOwner(); CinemachineComponentBase[] components = owner.GetComponents <CinemachineComponentBase>(); T component = owner.gameObject.AddComponent <T>(); if (component != null && components != null) { // Remove the existing components at that stage CinemachineCore.Stage stage = component.Stage; for (int i = components.Length - 1; i >= 0; --i) { if (components[i].Stage == stage) { components[i].enabled = false; RuntimeUtility.DestroyObject(components[i]); } } } InvalidateComponentPipeline(); return(component); }
static void OnUndoRedoPerformed() { if (sCanvasesAndTheirOwners != null) { List <UnityEngine.Object> toDestroy = null; foreach (var v in sCanvasesAndTheirOwners) { if (v.Value == null) { if (toDestroy == null) { toDestroy = new List <UnityEngine.Object>(); } toDestroy.Add(v.Key); } } if (toDestroy != null) { foreach (var o in toDestroy) { RemoveCanvas(o); RuntimeUtility.DestroyObject(o); } } } }
static void DestroyCollider() { if (mCameraColliderGameObject != null) { mCameraColliderGameObject.SetActive(false); RuntimeUtility.DestroyObject(mCameraColliderGameObject.GetComponent <Rigidbody>()); } RuntimeUtility.DestroyObject(mCameraCollider); RuntimeUtility.DestroyObject(mCameraColliderGameObject); mCameraColliderGameObject = null; mCameraCollider = null; }
/// <summary>Add a component to the cinemachine pipeline.</summary> public T AddCinemachineComponent <T>() where T : CinemachineComponentBase { T c = gameObject.AddComponent <T>(); var components = ComponentCache; var oldC = components[(int)c.Stage]; if (oldC != null) { oldC.enabled = false; RuntimeUtility.DestroyObject(oldC); } InvalidateComponentCache(); return(c); }
/// <summary>Remove a component from the cinemachine pipeline.</summary> public void DestroyCinemachineComponent <T>() where T : CinemachineComponentBase { var components = ComponentCache; foreach (var c in components) { if (c is T) { c.enabled = false; RuntimeUtility.DestroyObject(c); InvalidateComponentCache(); return; } } }
/// <summary>Remove a component from the cinemachine pipeline.</summary> public void DestroyCinemachineComponent <T>() where T : CinemachineComponentBase { CinemachineComponentBase[] components = GetComponentPipeline(); if (components != null) { foreach (var c in components) { if (c is T) { c.enabled = false; RuntimeUtility.DestroyObject(c); InvalidateComponentPipeline(); } } } }
void DestroyCanvas() { int numBrains = CinemachineCore.Instance.BrainCount; for (int i = 0; i < numBrains; ++i) { LocateMyCanvas(CinemachineCore.Instance.GetActiveBrain(i), false); if (mCanvas != null) { RuntimeUtility.DestroyObject(mCanvas); #if UNITY_EDITOR // Workaround for Unity bug case Case 1004117 CanvasesAndTheirOwners.RemoveCanvas(mCanvas); #endif } mCanvas = null; } }
void DestroyCanvas() { int numBrains = CinemachineCore.Instance.BrainCount; for (int i = 0; i < numBrains; ++i) { var parent = CinemachineCore.Instance.GetActiveBrain(i); int numChildren = parent.transform.childCount; for (int j = 0; j < numChildren; ++j) { RectTransform child = parent.transform.GetChild(j) as RectTransform; if (child != null && child.name == CanvasName) { var canvas = child.gameObject; RuntimeUtility.DestroyObject(canvas); #if UNITY_EDITOR // Workaround for Unity bug case Case 1004117 CanvasesAndTheirOwners.RemoveCanvas(canvas); #endif } } } mCanvasInfo.Clear(); }
private void CleanupCameraCollider() { RuntimeUtility.DestroyObject(mCameraColliderGameObject); mCameraColliderGameObject = null; mCameraCollider = null; }