- Home /
Click button, Send data to text field in another scene
There are two scenes. Scene one has one button and one typable text field. Scene two has one button.
From Scene one, the button is used to go to scene two. In scene two, the button is pressed and sends back a variable, eg "A string", into the typable text field in scene one and then goes back to scene one, where the typable text field will now be displaying "A String".
How do I write the button in javascript to return it?
Thanks,
Answer by Jake-L · Mar 29, 2011 at 06:26 AM
Use DontDestroyOnLoads to make an object (that holds your information, string, whatever) persistent during scene changes.
Answer by marinl · Mar 30, 2013 at 01:27 PM
You can create an object in first scene, attach a sript to it and sen value of variable in this script. For example if you want to send user login script attachet to game object that will survife after second scene load should be:
// User login:
public var userLogin : String;
function Awake() {
// Do not destroy this game object:
DontDestroyOnLoad(this);
}
Set userLogin in first scene and read in second.
Complete example can be found in my blog http://unity-tutorials.blogspot.com/. Listing 20 and 21.
Your answer

Follow this Question
Related Questions
How send data to other Unity app in same PC? 1 Answer
Sending bulk data via rpc 1 Answer
Unable to save game 0 Answers
Best way to store NPC data and how to do it? 1 Answer
How to Send Message to other GameObject 3 Answers