Hello! I’m new at this question asking thing. But I have problem that requires a solution.
I’m trying to create a panel with a input-field and a button that is used to enter a players name that will once be added into a highscore list. It looks something like this at the moment:
I then disable the input-field, the panel and the button with the following code:
public class DisableDatSh1t : MonoBehaviour {
void Start () {
this.gameObject.SetActive(false);
}
}
I then put in the script under the three objects, which makes them inactive when the game starts. My question is, how do i enable them once I’ve disabled them? I want them to be enabled once I enter a little portal I created at the end. I have tried this solution, but I don’t know how to call for the objects that has been disabled correctly.
void OnTriggerEnter (Collider other)
{
if(other.gameObject.tag == "Player")
{
other.gameObject.SetActive(false); //This disables the ball on entry, to allow the player to input a name into the field without the ball moving.
panel.gameObject.SetActive(true); //This is where the input-field, panel and button should be activated again.
}
}
}
Also, how do I save the value the player enters into the input-field to a variable or some sort of storage to be accesed from another scene?