I have this script that I allow a player to select his character. It’s ChooseAnimal.js:
var animal = "Animal";
function OnGUI() {
if (GUI.Button(new Rect(Screen.width/2-60, 100, 100, 30), "Dog")) {
animal = "Dog";
Application.LoadLevel("JunkYard");}
if (GUI.Button(new Rect(Screen.width/2-60, 140, 100, 30), "Cat")) {
animal = "Cat";
Application.LoadLevel("House");}
if (GUI.Button(new Rect(Screen.width/2-60, 180, 100, 30), "Mouse")) {
animal = "Mouse";
Application.LoadLevel("Sewer");}
}
Then I have this script which exists in the scene that will be used to instantiate that animal on the next screen as well as do some other stuff. It’s called character.js:
var animal = "Animal";
var skill = "Skill";
var street = "Street";
function Awake () {
DontDestroyOnLoad (transform.gameObject);
}
How do I get the Character.js to use the variable “animal” in ChooseAnimal.js?