Posts Tagged ‘ C# ’

GUI.Window Wrapper

So, I wanted to make windows that you could close and open, and you could minimize (move to the bottom of the screen), so I made this wrapper.

To download, go here.

Copy and paste that into a new C# script, called “GUIWindow.cs”.

How it works isn’t hard. Make a list of GUIWindow.

private readonly List _windows = new List();

and then, in start, you just add new windows to it, like this:

_windows.Add(new GUIWindow(new Rect(350, 5, Screen.width - 700, 70), 0, "Toolbar") { Minimizable = true, Closable = false, Opened = true, WindowBody = ToolbarPanel });

and in OnGUI() you just loop through all windows, and call their UpdateWindow() method.

Do note: WindowBody = ToolbarPanel means that WindowBody is asking for a function that returns void, and takes 0 parameters.