Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Trouble with GUI.Window

Discussion in 'Immediate Mode GUI (IMGUI)' started by monark, Jul 29, 2008.

  1. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    I'm having trouble getting GUI.Window to work properly.

    I want to have a draggable window but when I do this the GUI.Window ignores the initial position on the screen.


    Code (csharp):
    1.  
    2. var windowRect : Rect = Rect (300, 400, 100, 100);
    3.  
    4. function OnGUI () {
    5.    
    6.     windowRect = GUI.Window (0, windowRect, WindowFunction, "Navigation");
    7.    
    8. }
    9.  
    10. function WindowFunction (windowID : int) {
    11.     // Draw any Controls inside the window here
    12.    
    13.     // Make the windows be draggable.
    14.     GUI.DragWindow (Rect (0,0,10000,20));
    15. }
    16.  
    17.  
    No matter what I set the initial windowRect values to be the window always appears in the same spot on the screen.

    If I change to this


    Code (csharp):
    1.  
    2. var windowRect : Rect = Rect (300, 400, 100, 100);
    3.  
    4. function OnGUI () {
    5.    
    6.     windowRect = GUI.Window (0, Rect (300, 400, 100, 100), WindowFunction, "Navigation");
    7.    
    8. }
    9.  
    10. function WindowFunction (windowID : int) {
    11.     // Draw any Controls inside the window here
    12.    
    13.     // Make the windows be draggable.
    14.     GUI.DragWindow (Rect (0,0,10000,20));
    15. }
    16.  
    It comes up in the right place but then of course it isn't draggable any more. Is this a bug? or am I setting it up wrong?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    When you use public variables, the values in the Inspector override what you have in the code.

    --Eric
     
  3. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    That does it. Thank you once again. I'll have to start paying you soon :D