Esempio n. 1
0
        protected void RemoveElementsRecursively(GameObject gameObject, bool isRootObject, bool callOnDestroy)
        {
            string name = gameObject.name;

            if (this.elements.ContainsKey(name))
            {
                UXElement uXElement = this.elements[name];
                uXElement.InternalDestroyComponent();
                if (callOnDestroy && !isRootObject)
                {
                    uXElement.OnDestroyElement();
                    uXElement.Visible = uXElement.OrigVisible;
                }
                this.elements.Remove(name);
            }
            else
            {
                this.RemoveDuplicateNameIfPresent(name);
            }
            Transform transform  = gameObject.transform;
            int       i          = 0;
            int       childCount = transform.childCount;

            while (i < childCount)
            {
                this.RemoveElementsRecursively(transform.GetChild(i).gameObject, false, callOnDestroy);
                i++;
            }
        }
Esempio n. 2
0
 private void DestroyElement(UXElement element, bool destroyGameObjects)
 {
     if (element != null)
     {
         element.OnDestroyElement();
         GameObject root = element.Root;
         if (root != null)
         {
             this.RemoveElementsRecursively(root, true, true);
             if (destroyGameObjects)
             {
                 UnityEngine.Object.Destroy(root);
             }
         }
     }
 }