Screens overlap
When I try to navigate from one one screen to another in my Unity3D sample project, the previous screen remains in the background.
$$anonymous$$y Code is :
void OnGUI() { if (Current$$anonymous$$enu == "Login") { LoginGUI(); } else if (Current$$anonymous$$enu == "ResetPassword" && ExitCurrentFunction == false) { ResetPasswordGUI(); } else if (Current$$anonymous$$enu == "NeedSomeHelp") { NeedSomeHelp(); } else if (Current$$anonymous$$enu == "LoginCheck") { LoginCheck(); } }
void LoginGUI() {
GUI.Box(new Rect(210, 10, (Screen.width / 4)+90, (Screen.height / 4)+180), "Login");
//Create 2 buttons on Home Page
if (GUI.Button(new Rect(310,180,120,25), "Submit"))
{
Current$$anonymous$$enu = "LoginCheck";
}
if (GUI.Button(new Rect(310, 210, 120, 25), "Reset Password"))
{
Current$$anonymous$$enu = "ResetPassword";
}
if (GUI.Button(new Rect(310, 240, 120, 25), "Need Some Help?"))
{
Current$$anonymous$$enu = "NeedSomeHelp";
}
//End
GUI.Label(new Rect(240, 50, 100, 25), "User Name");
Email = GUI.TextField(new Rect(240, 80, 250, 25), Email);
//Create Password Label and TextFields
GUI.Label(new Rect(240, 110, 100, 25), "Password");
Password = GUI.PasswordField(new Rect(240, 140, 250, 25), Password,'*');
}
void ResetPasswordGUI() { ExitCurrentFunction = true; GUI.Box(new Rect(210, 10, (Screen.width / 4) + 90, (Screen.height / 4) + 180), "Forgot Password");
if (GUI.Button(new Rect(230, 200, 100, 25), "Send $$anonymous$$ail"))
{
Current$$anonymous$$enu = "SendPasswordResetEmail";
}
if (GUI.Button(new Rect(420, 200, 75, 25), "Back"))
{
Current$$anonymous$$enu = "Login";
}
GUI.Label(new Rect(230, 110, 100, 25), "Email");
Email = GUI.TextField(new Rect(300, 110, 210, 25), Email);
//Add Help $$anonymous$$essage below
var centeredStyle = GUI.skin.GetStyle("Label");
centeredStyle.alignment = TextAnchor.UpperLeft;
GUI.Label(new Rect(230, 50, (Screen.width / 4) + 50, (Screen.height / 4) + 50), "In Order to receive your access code by email, please enter the address you entered during registration process.", centeredStyle);
}
Unformatted code is hard to read. From what I can see, there's nothing wrong with the script. $$anonymous$$aybe the script is in the scene twice?
Is this all occurring in one scene, or are you transitioning between scenes? If it's one scene, you probably just need to manually hide or destroy the elements you no longer want to show. You can do this in several ways, from Canvas Groups to Camera Layers to simply disabling the component or destroying the object. If, however, you're transitioning between scenes, any GUI elements should be destroyed automatically, and I can't say for sure why that might not be happening, except that you probably told them not to be, somewhere along the line.