SetLayerRecursively() public static method

public static SetLayerRecursively ( GameObject go, int layer ) : void
go GameObject
layer int
return void
コード例 #1
0
    // Scans all child objects looking for IUIObjects and other panels
    public void ScanChildren()
    {
        uiObjs.Clear();

        // Reuse for IUIObjects:
        IUIObject obj;

        Component[] objs = transform.GetComponentsInChildren(typeof(IUIObject), true);

        for (int i = 0; i < objs.Length; ++i)
        {
            // Don't add ourselves as children:
            if (objs[i] == this || objs[i].gameObject == gameObject)
            {
                continue;
            }

#if AUTO_SET_LAYER
            // Only reset the child object layers if we're in-line
            // with the UIManager:
            if (gameObject.layer == UIManager.instance.gameObject.layer)
        #if SET_LAYERS_RECURSIVELY
            { UIPanelManager.SetLayerRecursively(objs[i].gameObject, gameObject.layer); }
        #else
            { objs[i].gameObject.layer = gameObject.layer; }
        #endif
#endif
            obj = (IUIObject)objs[i];
            uiObjs.Add(new EZLinkedListNode <IUIObject>(obj));
            obj.RequestContainership(this);
        }


        // Reuse for UIPanelBase objects:
        UIPanelBase panel;
        objs = transform.GetComponentsInChildren(typeof(UIPanelBase), true);

        for (int i = 0; i < objs.Length; ++i)
        {
            // Don't add ourselves as children:
            if (objs[i] == this || objs[i].gameObject == gameObject)
            {
                continue;
            }

#if AUTO_SET_LAYER
            // Only reset the child object layers if we're in-line
            // with the UIManager:
            if (gameObject.layer == UIManager.instance.gameObject.layer)
        #if SET_LAYERS_RECURSIVELY
            { UIPanelManager.SetLayerRecursively(objs[i].gameObject, gameObject.layer); }
        #else
            { objs[i].gameObject.layer = gameObject.layer; }
        #endif
#endif
            panel = (UIPanelBase)objs[i];
            childPanels.Add(new EZLinkedListNode <UIPanelBase>(panel));
            panel.RequestContainership(this);
        }
    }
コード例 #2
0
 public void ScanChildren()
 {
     this.uiObjs.Clear();
     Component[] componentsInChildren = base.transform.GetComponentsInChildren(typeof(IUIObject), true);
     for (int i = 0; i < componentsInChildren.Length; i++)
     {
         if (!(componentsInChildren[i] == this))
         {
             if (base.gameObject.layer == NrTSingleton <UIManager> .Instance.rayMask)
             {
                 UIPanelManager.SetLayerRecursively(componentsInChildren[i].gameObject, base.gameObject.layer);
             }
             IUIObject iUIObject = (IUIObject)componentsInChildren[i];
             if (!this.uiObjs.ContainsKey(componentsInChildren[i].GetHashCode()))
             {
                 this.uiObjs.Add(componentsInChildren[i].GetHashCode(), (IUIObject)componentsInChildren[i]);
             }
             iUIObject.RequestContainership(this);
         }
     }
     componentsInChildren = base.transform.GetComponentsInChildren(typeof(UIPanelBase), true);
     for (int j = 0; j < componentsInChildren.Length; j++)
     {
         if (!(componentsInChildren[j] == this))
         {
             if (base.gameObject.layer == NrTSingleton <UIManager> .Instance.rayMask)
             {
                 UIPanelManager.SetLayerRecursively(componentsInChildren[j].gameObject, base.gameObject.layer);
             }
             UIPanelBase uIPanelBase = (UIPanelBase)componentsInChildren[j];
             this.childPanels.Add(new EZLinkedListNode <UIPanelBase>(uIPanelBase));
             uIPanelBase.RequestContainership(this);
         }
     }
 }
コード例 #3
0
    // Scans all child objects looking for SpriteRoot and SpriteText objects
    public void ScanChildren()
    {
        uiObjs.Clear();

        SpriteRoot obj;

        Component[] objs = transform.GetComponentsInChildren(typeof(SpriteRoot), true);

        for (int i = 0; i < objs.Length; ++i)
        {
            // Don't add ourselves as children:
            if (objs[i] == this)
            {
                continue;
            }

#if AUTO_SET_LAYER
            // Only reset the child object layers if we're in-line
            // with the UIManager:
            if (gameObject.layer == UIManager.instance.gameObject.layer)
        #if SET_LAYERS_RECURSIVELY
            { UIPanelManager.SetLayerRecursively(objs[i].gameObject, gameObject.layer); }
        #else
            { objs[i].gameObject.layer = gameObject.layer; }
        #endif
#endif
            obj = (SpriteRoot)objs[i];
            if (obj is AutoSpriteControlBase)
            {
                if (((AutoSpriteControlBase)obj).RequestContainership(this))
                {
                    uiObjs.Add(obj);
                }
            }
            else             // Just add it:
            {
                uiObjs.Add(obj);
            }

            // Add the object as a subject of our container:
            if (container != null)
            {
                container.AddSubject(obj.gameObject);
            }

            // See if we need to pass on our render camera:
            if (renderCamera != null)
            {
                obj.renderCamera = renderCamera;
            }
        }


        // Again for all ControlBase implementers:
        objs = transform.GetComponentsInChildren(typeof(ControlBase), true);

        for (int i = 0; i < objs.Length; ++i)
        {
#if AUTO_SET_LAYER
            // Only reset the child object layers if we're in-line
            // with the UIManager:
            if (gameObject.layer == UIManager.instance.gameObject.layer)
        #if SET_LAYERS_RECURSIVELY
            { UIPanelManager.SetLayerRecursively(objs[i].gameObject, gameObject.layer); }
        #else
            { objs[i].gameObject.layer = gameObject.layer; }
        #endif
#endif
            // Contain it, but don't add it to our list, since
            // that list is used for sprite-specific things like
            // clipping.
            ((ControlBase)objs[i]).RequestContainership(this);

            // Add the object as a subject of our container:
            if (container != null)
            {
                container.AddSubject(objs[i].gameObject);
            }
        }

        //----------------------------------------------------
        // Again for SpriteText:
        //----------------------------------------------------

        textObjs.Clear();

        SpriteText  txt;
        Component[] txts = transform.GetComponentsInChildren(typeof(SpriteText), true);

        for (int i = 0; i < txts.Length; ++i)
        {
            // Don't add ourselves as children:
            if (txts[i] == this)
            {
                continue;
            }

            // Only process text objects that aren't already associated
            // with controls:
            txt = (SpriteText)txts[i];

            if (txt.Parent != null)
            {
                continue;
            }

#if AUTO_SET_LAYER
            // Only reset the child object layers if we're in-line
            // with the UIManager:
            if (gameObject.layer == UIManager.instance.gameObject.layer)
#if SET_LAYERS_RECURSIVELY
            { UIPanelManager.SetLayerRecursively(txt.gameObject, gameObject.layer); }
#else
            { txt.gameObject.layer = gameObject.layer; }
#endif
#endif
            textObjs.Add(txt);

            // Add the object as a subject of our container:
            if (container != null)
            {
                container.AddSubject(txt.gameObject);
            }

            // See if we need to pass on our render camera:
            if (renderCamera != null)
            {
                txt.renderCamera = renderCamera;
            }
        }
    }