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.
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.
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 1