I am going to create two pages. In one page I create a textfield and a button. In text field I am going to write something. After click it on the button the next page will appear. I can move page from one page to another by using Application.Loadlevel()
. In the second page, I have only one text field. I want to show the previous textfield value on the next text field, whi开发者_高级运维ch is located in another page. But I can't do that thing. Please help.
This is one solution: You can access fields (variables) in one script file which are present in another script file, this can be done my making that variable global, this way you can access it in another javascript file. You need to make the text in the textfield global, so that you can access it in another script file (javascript in your case).
Global can be declared like this:
// The static variable in a script named 'TheScriptName.js'
static var someGlobal = 5;
// You can access it from inside the script like normal variables:
print(someGlobal);
someGlobal = 1;
And it can be accessed in another javascript like this: TheScriptName.someGlobal = 10;
Link to Global in Unity Script Reference
精彩评论