Access gameobject from a different scene...
Hey, Im a beginner at unity, so sorry if there is a very simple answer to this XD I have two scenes so far in my game, my main scene and main menu scene, In my main menu scene I have created a InputField and added a script I made, which is:
var username : String;
var inputField : UnityEngine.UI.InputField;
var nameDisplay : UnityEngine.GUIText;
function NameInput () {
username = inputField.text;
nameDisplay.text = username;
inputField.enabled = false;
}
The 'Username' gameobject is in the main game scene, however the script is assigned to a InputField in my main menu... So is there any way to reference my 'Username' gameobject (in my main scene) to my InputField (In my main menu)? Thanks! ;)
Answer by dousi96 · May 19, 2016 at 10:16 PM
It's impossible! U have to save or serialize that value before changing scene and load it in the scene where you need it
So how would I have an imput field in one scene and then the text from the input field in another? Thanks ;)
You can save the values from the input field in a string with PlayerPrefs class. and get it in the other scene