Beispiel #1
0
        /// <summary>
        /// Configures the objects showed in Hierarchy to be shown or hidden
        /// </summary>
        public void SetupHideInHierarchy()
        {
            //Get all objects
            UpdateParentObjects();

            //Proceed if objects exist
            if (m_visibilityEntries != null)
            {
                foreach (Transform t in transform)
                {
                    GaiaHierarchyVisibility ghv = m_visibilityEntries.Find(x => x.m_name == t.name);
                    if (ghv == null || ghv.m_isVisible)
                    {
                        foreach (Transform child in t)
                        {
                            child.gameObject.hideFlags = HideFlags.None;
                        }
                    }
                    else
                    {
                        foreach (Transform child in t)
                        {
                            child.gameObject.hideFlags = HideFlags.HideInHierarchy;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Update the visibility state for all parent objects that hold game objects
        /// </summary>
        /// <returns></returns>
        public void UpdateParentObjects()
        {
            //Build up a new list that keeps the existing settings, this will take care of sorting if the hierarchy has changed as well.
            List <GaiaHierarchyVisibility> newList = new List <GaiaHierarchyVisibility>();

            foreach (Transform t in transform)
            {
                GaiaHierarchyVisibility ghv = m_visibilityEntries.Find(x => x.m_name == t.name);
                if (ghv == null || ghv.m_isVisible)
                {
                    newList.Add(new GaiaHierarchyVisibility()
                    {
                        m_name = t.name, m_isVisible = true
                    });
                }
                else
                {
                    newList.Add(new GaiaHierarchyVisibility()
                    {
                        m_name = t.name, m_isVisible = false
                    });
                }
            }
            //Add all remaining entries to carry over settings for objects which are currently not spawned in the hierarchy
            foreach (GaiaHierarchyVisibility ghv in m_visibilityEntries.Where(x => !newList.Exists(y => y.m_name == x.m_name)))
            {
                newList.Add(ghv);
            }

            m_visibilityEntries = newList;
        }