- Home /
Unique id numbers for GUI.Window
Hallo, community. Is there any simple way to generate for sure unique id numbers for GUI windows? MonoBehavior Instantiate ID is not suitable here, because I have to call several windows for one object.
Answer by Cherno · Apr 26, 2014 at 02:43 AM
I'm not sure I understand your question right.
How about just using a list of ints? If you want to generate a new ID, check if the list contains that one, and if yes, generate another one.
Answer by Bunny83 · Apr 26, 2014 at 02:58 AM
The easiest way is to use a "windowID manager" like this:
// C#
public static class WindowIdManager
{
private static int m_NextId = 2222; // I just start a bit higher to keep space for hardcoded window ids.
public static int GetWindowId()
{
return m_NextId++;
}
}
In all your scripts where you need a window ID you just declare a member variable for each window you need like this:
// C#
public class SomeScript : MonoBehaviour
{
private int m_WindowId1 = WindowIdManager.GetWindowId();
private int m_WindowId2 = WindowIdManager.GetWindowId();
}
Answer by VirtualSUN · May 24, 2018 at 03:06 PM
GUIUtility.GetControlID(FocusType.Passive)
Rect WindowRect = GUI.Window(GUIUtility.GetControlID(FocusType.Passive), WindowRect, Window, " ");
Your answer
Follow this Question
Related Questions
How to get the ID of the topmost window? 0 Answers
How I can obtein a Int whith the Network ID in Unet? 1 Answer
How to set component ID when adding it to the inspector? 0 Answers
Minimize GUI Windows 1 Answer
Dragging and Locking Buttons. 1 Answer