Depth won't work

Hello guys ! :smile:
Inventory: http://scr.hu/3tpn/1t1hy
And here is my problem:

    void OnGUI() {
        GUI.skin = dispSkin;
        if(showOptions)
        {
            GUI.depth = 3;
            GUILayout.BeginArea (new Rect (optionPos.x, optionPos.y, 80, 83));
            if(itemS.itemSettings.isDropable) {
                if(GUILayout.Button("Drop", GUILayout.Width(80), GUILayout.Height(25)))
                {
                    inv.DropItem(itemS);
                    showOptions = false;
                }
            }
            if(itemS.itemSettings.isUsable) {
                if(GUILayout.Button("Use", GUILayout.Width(80), GUILayout.Height(25)))
                {
                    Debug.Log("ItemUsed");
                    //itemT.GetComponent<ItemEffect>().UseEffect();
                    showOptions = false;
                }
            }
            GUILayout.EndArea ();
            GUI.depth = 0;
        }

        if (openUI) {
            GUI.depth = 2;
            wRect.character = GUI.Window(0, wRect.character, Character, "Character");
            wRect.inventory = GUI.Window(1, wRect.inventory, Inventory, "Inventory");
            GUI.depth = 0;
        }
    }

so, when i click on my item in inventory options will be available to use:
http://scr.hu/3tpn/e7c4d
but the problem is… options are BEHIND inventory window despite the fact that I used GUI.depth;
someone know what’s wrong ?

Yes. I did some testing on this.

Unity always renders GUI windows on top of the main GUI. It doesn’t matter what you set the depth to. I’ve even tried putting the GUI window in a separate MonoBehaviour so I can control the depth independantly, and the result is always the same… GUI window on top.

In your case, you’ve got a few options:

  • Use a window for your options popup.
  • Don’t use windows for your character and inventory windows.
  • Switch to the new GUI system included with Unity 4.6. It is a lot more powerful than OnGUI, and runs faster!

Yeah, i tried to use new UI system, but i have problem with scaling on different resolutions :confused: