question regarding importing variable to another scene

here in my code i have text field. I just want to know to to pass the typed name to another scene when i hit enter…

here’s my code…

var stringToEdit = “Player1”;
var userHasHitOk : boolean = false;

function OnGUI () {
if (userHasHitOk) { GUI.Label (Rect (10, 10, 100, 30), "Hello " + stringToEdit);

} else {
if (GUI.Button(Rect (0,Screen.height - 50,80, 40), “Enter”))

userHasHitOk = true;
}

//this code that i want to import to another scene when i hit enter

GUI.Label (Rect (10, 10, 100, 30), “Enter Name:”);
stringToEdit = GUI.TextField (Rect (90, 10, 200, 25), stringToEdit, 40);
}

// end

static var stringToEdit = “Player1”;
fetch it with ‘scriptname.stringToEdit’
scriptname being the script where the stringToEdit lives

i didn’t get it sir… do you have a sample? i have two scene how can i import the name that i enter from the first scene to the second scene… ? sorry sir im not good at scripting.

If you mark the stringToEdit variable as static, it means it will keep its value between scenes unless you deliberately change it. You can access a static variable from any other script by qualifying it with the script name. For example, suppose the script you posted above was in a file called PlayerName.js. You can access the variable by using:-

var name = PlayerName.stringToEdit;