/*! \cond PRIVATE */ using UnityEngine; using System.Collections.Generic; // ReSharper disable once CheckNamespace namespace DarkTonic.MasterAudio { // ReSharper disable once CheckNamespace public static class DTMonoHelper { public static Transform GetChildTransform(this Transform transParent, string childName) { return transParent.Find(childName); } /// /// This is a cross-Unity-version method to tell you if a GameObject is active in the Scene. /// /// The GameObject you're asking about. /// True or false public static bool IsActive(GameObject go) { return go.activeInHierarchy; } /// /// This is a cross-Unity-version method to set a GameObject to active in the Scene. /// /// The GameObject you're setting to active or inactive /// True to set the object to active, false to set it to inactive. public static void SetActive(GameObject go, bool isActive) { go.SetActive(isActive); } public static void DestroyAllChildren(this Transform tran) { var children = new List(); for (var i = 0; i < tran.childCount; i++) { children.Add(tran.GetChild(i).gameObject); } var failsafe = 0; while (children.Count > 0 && failsafe < 200) { var child = children[0]; GameObject.Destroy(child); if (children[0] == child) { children.RemoveAt(0); } failsafe++; } } } } /*! \endcond */