- Home /
GUI.DragWindow() doesnt work - cant figure out why
Window works fine, but I cant drag it. I have tried clicking every where on it, and of course I am not clicking on the buttons. What am I doing wrong? I havent had trouble with this before.
Thanks!
Here I call the window in OnGUI
void OnGUI()
{
//Heads up Display Tool Bar
GUI.Window(hudWindowID, HudWindowRect, HudWindowFunction, "ToolBar1");
}
ANd here is the window:
private void HudWindowFunction(int id)
{
GUILayout.BeginHorizontal();
if(GUILayout.Button ("Ability 1", GUILayout.Width(60), GUILayout.Height(60)))
{
//ability 1
}
if(GUILayout.Button ("Ability 2", GUILayout.Width(60), GUILayout.Height(60)))
{
//ability 2
}
if(GUILayout.Button ("Ability 3", GUILayout.Width(60), GUILayout.Height(60)))
{
//ability 3
}
if(GUILayout.Button ("Ability 4", GUILayout.Width(60), GUILayout.Height(60)))
{
//ability 4
}
GUILayout.EndHorizontal();
GUI.DragWindow();
}
Answer by Bunny83 · Jun 20, 2013 at 06:28 AM
It's very simple ;)
Instead of
GUI.Window(hudWindowID, HudWindowRect, .....
you need :
HudWindowRect = GUI.Window(hudWindowID, HudWindowRect, .....
HudWindowRect is the position and size of your window. Since this parameter is not a ref-parameter it can't be changed by the window function. That's why it returns the new position
Well its official I have been coding too late at night.. Lol thanks for the re$$anonymous$$der on that :)
Your answer
Follow this Question
Related Questions
GUI.Window only shows for one frame under all circumstances 2 Answers
GUI Window Problem 2 Answers
[ERROR!] GUI.WindowFunction with multiple parameters 0 Answers
Mouse trailing 0 Answers
Clickable GUI.Window 1 Answer