- Home /
The question is answered, right answer was accepted
Unity 5 UI Menus
Hi, Im new to Unity 5 and I have made these two panels. I want it the first is only visible, and when you press the register button the 2nd panel pops up and the first one disappears.
How can I do this via C#? So much has changed since the old legacy UI workflow.
Answer by Hellium · Aug 11, 2015 at 07:18 AM
A very simple way to do this is using the OnClick() delegate directly from the inspector :
Click the +
in the bottom of the box. Drag & drop the registration panel. Then chose the "Game Object > Set active) in the drop down list, and do not check the check box ! For the back button, do nearly the same with the main panel.
Answer by rajavamsidhar_gvs · Aug 11, 2015 at 05:41 AM
I'm not pretty much familiar to u5 UI.But you can use booleans with enabling and disabling for this.like
public GameObject Login;
public GameObject Register;
bool a;
bool b;
void Start(){
a=false;
b=false;
Login=GameObject.Find("Login");
Register=GameObject.Find("Register");
}
void Update(){
//button Register OnClick event
a=true;
if(a&&!b){
Login.enabled=false;
Register.enabled=true;
}
//button back OnClick event
b=true;
if(b){
Login.enabled=true;
Register.enabled=false;
a=false;
}
}
Once see this tutorial Link
This is not how you use booleans in c# Unity. Your script is full with problems.
Follow this Question
Related Questions
Cronómetro 1 Answer
Unity 5: UI button OnPointerDown not function as expected 1 Answer
Add Listeners to array of Buttons 2 Answers
Display spinning icon while some search method in progress ? 0 Answers