Exemple #1
0
        internal static void SetLock(GameObject go, bool value, string undoName, h2_ChildrenAction childrenAction)
        {
            var components = go.GetComponents <Component>();
            var h          = HideFlags.NotEditable | HideFlags.HideInHierarchy;

            // NOTE : Undo not working for HideFlags
            // LOCK components first but Unlock GameObject first (don't know if this really matters)

            if (value)
            {
                foreach (var c in components)
                {
                    if (c == null)
                    {
                        continue;
                    }
                    if (c is Transform)
                    {
                        continue;
                    }
                    c.hideFlags |= h;
                }
                go.hideFlags |= HideFlags.NotEditable;
            }
            else // Unlock : Unlock GameObject first
            {
                go.hideFlags &= ~HideFlags.NotEditable;
                foreach (var c in components)
                {
                    if (c == null)
                    {
                        continue;
                    }
                    if (c is Transform)
                    {
                        continue;
                    }
                    c.hideFlags &= ~h;
                }
            }

            if (childrenAction == h2_ChildrenAction.None)
            {
                return;
            }
            var pValue = childrenAction == h2_ChildrenAction.Set;

            var t = go.transform;

            foreach (Transform c in t)
            {
                if (c == t)
                {
                    continue;
                }
                SetLock(c.gameObject, pValue, undoName, childrenAction);
            }

            h2_Utils.DelayRepaintInspector();
        }
Exemple #2
0
        // ------------------------------ UTILS -----------------------------------

        internal static void SetStatic(GameObject go, bool value, string undoName, h2_ChildrenAction childrenAction)
        {
            if (go.isStatic != value)
            {
                Undo.RecordObject(go, undoName);
                go.isStatic = value;
            }

            if (childrenAction == h2_ChildrenAction.None)
            {
                return;
            }
            var pValue = childrenAction == h2_ChildrenAction.Set;

            var t = go.transform;

            foreach (Transform c in t)
            {
                if (c == t)
                {
                    continue;
                }
                SetStatic(c.gameObject, pValue, undoName, childrenAction);
            }
        }
Exemple #3
0
 internal static void SetLockArray(bool v, GameObject[] goList, string undoName, h2_ChildrenAction action,
                                   GameObject exclude = null)
 {
     for (var i = 0; i < goList.Length; i++)
     {
         var item = goList[i];
         if (item == exclude)
         {
             continue;
         }
         SetLock(item, v, undoName, action);
     }
 }