- Home /
Creating and destroying password stage between scenes
Hi! I am building an app in Unity that requires a password to be entered to gain access to restricted content.
Once this password is entered it loads the scene required containing this content. or alternatively the password script can be attached to a camera in said scene and destroyed once the password is entered correctly. along with a plane that can be destroyed/deactivated to reveal content.
However I want this password to only be entered once and then be destroyed, and I am having trouble working out how to keep this script disabled/destroyed as users navigate between scenes.
The password script is as such:
using UnityEngine;
using System.Collections;
public class password2 : MonoBehaviour {
public string passwordToEdit = "";
void OnGUI() {
passwordToEdit = GUI.PasswordField(new Rect(Screen.width / 32, Screen.height / 2, 500, 80), passwordToEdit, "*"[0], 25);
if (passwordToEdit == "example") {
Destroy(GetComponent<password2>());
}
}
}
(thats the example used on the cam within the restricted content scene - it could also Loadlevel instead)
Im sure its simple, I just cant get my head around it, I have been finding options such as OnLevelWasLoaded but am not quite sure how to apply this in the context described.
Thankyou!!
(one note - i know I could create alternative levels without this password script applied that users navigate from then on, but as it is an App I am trying to keen the size down as much as possible!)
I would suggest learning Unity's new UI system, the old GUI. system is horrible and outdated.
Your answer
Follow this Question
Related Questions
Client player cannot see MasterClient player after scene change 0 Answers
results screen using destroyed objects as score 1 Answer
Password for launching app? 1 Answer
Is it possible to build an app that downloads specific scenes depending on the user login 0 Answers
Can I utilize LoadLevelAdditive for immersive game? 2 Answers