Example #1
0
        /* private */
        private static void Set(UnityEngine.GameObject root, string newName, int newOrder, int deltaOrder, bool deep, int newId, bool setOrder, bool ignoreLinked)         // get newId only if newName is null
        {
            if (newName != null && newName.Equals("Default"))
            {
                Picus.Sys.Debug.Empty();
            }

            SortingLayer sortingLayer = Picus.Utils.GO.Finder.FindComponentAddIfNotExist <SortingLayer>(root);

            if (newName == null)
            {
                sortingLayer.SetDefaults(newId, newOrder, true, setOrder);
            }
            else
            {
                sortingLayer.SetDefaults(newName, newOrder, setOrder);
            }

            if (!deep)
            {
                return;
            }

            Transform transform = root.transform;
            int       count     = transform.childCount;

            for (int i = 0; i < count; i++)
            {
                Transform child = transform.GetChild(i);
                if (ignoreLinked && child.GetComponent <GO.TopInfo>() != null)
                {
                    continue;
                }
                Set(child.gameObject, newName, newOrder + deltaOrder, deltaOrder, deep, newId, setOrder, ignoreLinked);
            }
        }
Example #2
0
        // add order to existing order, keep layer
        public static void SetDeepDeltaOrder(UnityEngine.GameObject root, int deltaOrder, bool ignoreLinkedObjects)
        {
            SortingLayer sortingLayer = Picus.Utils.GO.Finder.FindComponentAddIfNotExist <SortingLayer>(root);

            sortingLayer.SetDefaults(sortingLayer.SortingLayerId, sortingLayer.SortingOrder + deltaOrder, true, true);

            Transform transform = root.transform;
            int       count     = transform.childCount;

            for (int i = 0; i < count; i++)
            {
                Transform child = transform.GetChild(i);

                if (ignoreLinkedObjects && child.GetComponent <GO.TopInfo>() != null)
                {
                    continue;
                }

                SetDeepDeltaOrder(child.gameObject, deltaOrder);
            }
        }