void Awake() { //obtenemos ruta rutaArchivo = Application.persistentDataPath + "/datos.dat"; //Si es la primera vez if (variablesPersonaje == null) { //Referencia al componente que ejecuta el codigo variablesPersonaje = this; /* * Objeto que no se destruira cuando cambiamos * de escenas * */ DontDestroyOnLoad(gameObject); } else if (variablesPersonaje != this) { //Destruyo componente que tiene el script Destroy(gameObject); } }
void Awake() { //obtenemos ruta rutaArchivo = Application.persistentDataPath + "/datos.dat"; //Si es la primera vez if (variablesPersonaje == null) { //Referencia al componente que ejecuta el codigo variablesPersonaje = this; /* * Objeto que no se destruira cuando cambiamos * de escenas * */ DontDestroyOnLoad (gameObject); } else if (variablesPersonaje != this) { //Destruyo componente que tiene el script Destroy(gameObject); } }