Trying to enable an input-field, once disabled.

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?

It looks like you’re just turning your panel back on. Assuming the input field and button are children, if you turn off all three and then turn the panel back on, it doesn’t recursively set the children as active as well. Another way to solve this is leave the button and input field active, and only turn off the root object (your panel).

As for the storage, you can use PlayerPrefs to use data between scenes. Set the key in that scene, then get the key in the next.