Search Unity

[SOLVED] How to disable click-to-focus feature of GUILayout Windows

Discussion in 'Immediate Mode GUI (IMGUI)' started by Mangiang, Mar 15, 2017.

  1. Mangiang

    Mangiang

    Joined:
    Nov 19, 2014
    Posts:
    4
    Hi,

    I draw multiple GUILayout Windows inside a EditorWindow.BeginWindows in OnGUI.

    Now, I want to implement my own depth system but I can't because of the " feature click-to-focus" of the windows (according to Unity's documentation https://docs.unity3d.com/ScriptReference/GUI.Window.html) - it always brings the selected window to front.

    I used windows because I need to be able to drag the windows around (GUI.DragWindow).

    I tryed :
    • Drawing them in different order in OnGUI (it doesn't do anything)
    • Using GUI.Depth in OnGUI (it doesn't do anything)
    • Using GUI.Depth in the DrawWindow function of each window (it doesn't do anything)
    • Using GUI.unfocusWindow (I'm not able to drag them around anymore and it doesn't solve the problem)
    • Using GUI.BringWindowToBack / GUI.BringWindowToFront (I want values between front and back)
    What I have (the numbers represent their depth):

    Capture.JPG

    What I want (the numbers representtheir depth):

    Capture2.JPG

    Thanks.
     
  2. PsyKaw

    PsyKaw

    Joined:
    Aug 16, 2012
    Posts:
    102
    Have you try something like that:

    foreach(var window in windowsList)
    {
    GUI.BringWindowToFront(window.id);
    }

    So you force the depth each call of OnGUI()
     
    Nexer8 and Mangiang like this.
  3. Mangiang

    Mangiang

    Joined:
    Nov 19, 2014
    Posts:
    4
    How silly of me !!

    Thank you for you reply.

    I already tried that but it was before I drew them in different orders ....
    Changing their order in the list according to their depth AND using GUI.BringWindowToFront made the trick !