Hi, this is my problem: Before I make the draggable window, "GUI.Window"
on OnGUI is running, but after I make the draggable window and cut the code inside OnGUI into the function that parameter on "GUI.Window"
requires a function (in this case: DraggableWindowFunction), the function inside GUI.Window is not running, while before that, the code is perfectly running.
Here is the code:
void OnGUI()
{
// If GUIHolder opened variable is true
if (GUIHolder.opened) // When tab button on keyboard was pressed, the variable opened is true
{
// Set the User draggableWindow to active window
User.draggableWindow = GUI.Window(0, User.draggableWindow, DraggableWindowFunction, GUIContent.none);
}
}
void DraggableWindowFunction(int windowID)
{
Event e = Event.current; // For locating the current mouse position
// If GUIHolder opened variable is true
if (GUIHolder.opened)
{
// Draw the texture
GUI.DrawTexture(User.backgroundRect, User.imageBackground);
// Call the DrawBoxes method
DrawBoxes(); // Drawing some boxes into screen
// Set the window to be draggable window
GUI.DragWindow(new Rect(0, 0, 450, 20));
}
While the code inside DraggableWindowFunction
is on OnGUI
, the code inside still running, but after I move out the code from OnGUI
to DraggableWindowFunction
, the code is not running, only the GUI.Window
itself on the OnGUI
function, and the GUI.DragWindow
on DraggableWindowFunction
.
Your answer much appreciated!
Thank you