ash_05
1
I have created one window,I need to create one more window on the same scene.Here is the i have written for one window
void OnGUI()
{
GUI.Window (0, new Rect (100,200,450,300), LoginWindow, "Login and Registration system");
}
/* user interface*/
void LoginWindow(int windowID)
{
GUI.Label (new Rect (140, 40, 130, 100), "Enter the Username");
username = GUI.TextField (new Rect (25, 60, 375, 30), username);
GUI.Label (new Rect (140, 92, 130, 100), "Enter the Password");
password = GUI.TextField(new Rect (25, 115, 375, 30), password);
if (GUI.Button (new Rect (29, 160, 175, 50), "Login"))
StartCoroutine(handleLogin(username,password));
GUI.Label (new Rect (55, 222, 250, 100),output);
if(GUI.Button (new Rect (225, 160, 175, 50), "Register"))
Application.LoadLevel ("Registration");
//StartCoroutine(handleRegister(username,password));
}
How to create one more window?
Just add another call to “GUI.Window”. First parameter (ID) should be 1.
Here you can find this example:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public Rect windowRect0 = new Rect(20, 20, 120, 50);
public Rect windowRect1 = new Rect(20, 100, 120, 50);
void OnGUI() {
windowRect0 = GUI.Window(0, windowRect0, DoMyWindow, "My Window");
windowRect1 = GUI.Window(1, windowRect1, DoMyWindow, "My Window");
}
void DoMyWindow(int windowID) {
if (GUI.Button(new Rect(10, 20, 100, 20), "Hello World"))
print("Got a click in window " + windowID);
GUI.DragWindow(new Rect(0, 0, 10000, 10000));
}
}