Skip to main content

Posts

Showing posts with the label draggable

Making Multiple Instances of Windows With Same Window Method

So when developing a small little web-player, I ran into the problem of trying to render multiple instances of the same window function. My plan was for my user interface component to iterate through all the thought components and for each thought, render its contents in a new window. The windows need to be draggable also. My first attempt of this implementation failed. Rect thoughtRect = new Rect(20, 20, 200, 100); void OnGUI(){ for (int i = 0; i < allthoughts.Length; i++){ thoughtRect = GUI.Window(0+i, thoughtRect, DoThoughtWindow, ""+allthoughts[i].GetContent()); } } void DoThoughtWindow(int windowID) { GUI.DragWindow (new Rect(0, 0, 10000, 10000)); } For those who don't see the problem with this, I'll explain. All three windows are using the same Rect  thoughtRect  so all the windows are drawn on top of eachother. You might think this won't pose a problem due to the windows be...