Search Unity

Gui Draggable Window Script help

Discussion in 'Immediate Mode GUI (IMGUI)' started by Lazerath, Apr 28, 2011.

  1. Lazerath

    Lazerath

    Joined:
    Apr 28, 2011
    Posts:
    8
    Hello All,
    I have been attempting to use inheritencein Unity by creating a generic window, and once I get this generic window working correctly I will be using it to contruct other particular windows. My problem is this: I have the window working as a generic window contruction with various functions contained within. However I am unable to get the window to be draggable. Any help would be greatly welcomed.

    Code included below:

    testingInherit.js
    Code (csharp):
    1.  
    2. var myWindow : GenericWindow;
    3.  
    4. function OnGUI()
    5. {
    6.     myWindow = new GenericWindow(0,"A GenericWindow_WOOTS",new Rect(20,20,120,50));
    7.     myWindow.OnGUI();
    8. }
    9.  
    GenericWindow.js
    Code (csharp):
    1.  
    2. private var wID : int;
    3. private var wTitleBar : String;
    4. private var wRect : Rect;
    5. private var aWindow : Rect;
    6.  
    7. public class GenericWindow extends GUI
    8. {
    9.  
    10.     function Start()
    11.     {
    12.         aWindow = new Rect(20,20,100,100);
    13.     }
    14.    
    15.     function GenericWindow(mID : int, mTBar : String, mRect : Rect)
    16.     {
    17.         wID = mID;
    18.         wTitleBar = mTBar;
    19.         wRect = mRect;
    20.     }
    21.  
    22.     function OnGUI()
    23.     {
    24.         aWindow = this.Window(wID,wRect,DoMyWindow,wTitleBar);
    25.     }
    26.    
    27.     function DoMyWindow(w : int)
    28.     {
    29.         //Testing something
    30.         if(GUI.Button(Rect(25,25,50,30), "Window Bttn"))
    31.         {
    32.         }
    33.         GUI.DragWindow();
    34.     }  
    35.    
    36.     function Update ()
    37.     {
    38.     }
    39.    
    40.     function GetRect()
    41.     {
    42.         return wRect;
    43.     }
    44.    
    45.     function SetRect(r : Rect)
    46.     {
    47.         wRect = r;
    48.     }
    49.    
    50. }
    51.  
    Thank you for taking the time to help me with this issue

    Lazerath
     
  2. robattle

    robattle

    Joined:
    May 6, 2011
    Posts:
    22
    i've got nothing maybe you should try the scripting forms