void Awake() { if (_instance == null) { _instance = this; SetPosition(); AudioListener listener = GetComponent <AudioListener>(); if (listener != null) { listener.enabled = true; } } else if (_instance != this && destroyDuplicates) { Debug.LogWarning("Instance of CameraController already exists. Destroying duplicate."); GameObjectUtils.Destroy(gameObject); } else if (_instance != this && !destroyDuplicates) { AudioListener listener = GetComponent <AudioListener>(); if (listener != null) { listener.enabled = false; } } }
protected virtual void ResetTarget() { if (doNotResetHighlightedObjectOnComplete) { return; } if (_targetCloneGO != null) { GameObjectUtils.Destroy(_targetCloneGO); } if (_targetParentTF != null && !putCloneToTutorialPanelInstead) { targetTF.SetParent(_targetParentTF, true); RectTransform targetRT = targetTF.GetComponent <RectTransform>(); if (targetRT != null) { targetRT.SetSiblingIndex(_targetSiblingIndex); // Reset target can catch raycast to original state Graphic targetGraphic = targetRT.GetComponent <Graphic>(); if (targetGraphic) { targetGraphic.raycastTarget = _cachedRaycastTarget; } } } foreach (Button b in _disableButtons) { if (b != null) { b.interactable = true; } } }
public static void DestroyChildrenAfter(this Transform t, int index) { for (int i = t.childCount - 1; i >= index; i--) { GameObject child = t.GetChild(i).gameObject; GameObjectUtils.Destroy(child); } }
public static void DestroyComponents <T> (this GameObject go) where T : Component { T[] components = go.GetComponents <T>(); for (int i = 0; i < components.Length; i++) { T component = components[i]; GameObjectUtils.Destroy(component); } }
public static void DestroyComponent <T> (this GameObject go) where T : Component { T component = go.GetComponent <T>(); if (component != null) { GameObjectUtils.Destroy(component); } }
void Awake() { if (instance != null) { GameObjectUtils.Destroy(gameObject); } else { instance = this; CreateParticleSystemPool(); } }
void Awake() { if (_instance == null) { _instance = this; SetPosition(); } else { Debug.LogWarning("Instance of CameraController already exists. Destroying duplicate."); GameObjectUtils.Destroy(gameObject); } }
private static void RemoveCachedSprite(CachedSprite cachedSprite) { spriteCache.Remove(cachedSprite.Source); // Destoying the texture is important to free the memory. if (cachedSprite.Sprite != null) { if (cachedSprite.Sprite.texture != null) { GameObjectUtils.Destroy(cachedSprite.Sprite.texture); } GameObjectUtils.Destroy(cachedSprite.Sprite); } }