Create singleton class,
store your variable into it,
access from other script in any scene.
login.js
class Login
{
// This is the singleton instance that is shared with everyone.
private static var Instance : Login;
// Everything that needs to get the singleton
// instance, calls this function to get it.
public static function GetInstance() : Login
{
if (Instance == null)
// This is the first time the function was called. Need to
// construct the shared instance.
Instance = new Login();
return Instance;
}
var state : boolean ;
// Private constructor. This is what forces the class
// to be a singleton since the only way to construct it
// is via GetInstance().
// NOTE: Private constructors are not normally allowed
// in JavaScript. But it is OK in Unity.
private function Login()
{
state=false;
}
function GetState() : boolean
{
return state;
}
}
upload.js
private var control : Login;
function Start()
{
control = Login.GetInstance();
Debug.Log(control.GetState());
// The next line would cause a compile time error due to
// the constructor's protection level.
// control = new Login();
}