void SaveScore() { BinaryFormatter binary = new BinaryFormatter (); FileStream file = File.Create (Application.persistentDataPath + "/score.data"); DataStored gameData = new DataStored (); gameData.scoreSave = highscore; binary.Serialize (file, gameData); file.Close (); }
void SaveCharacterData() { Debug.Log ("Guardamos info de los personajes actuales"); BinaryFormatter binary = new BinaryFormatter (); FileStream file = File.Create (Application.persistentDataPath + "/characters.data"); DataStored gameData = new DataStored (); gameData.playableCharacters = new bool[totalCharacters]; for (int i=0; i<totalCharacters; i++) { gameData.playableCharacters[i] = GameObject.Find ("MainUI").GetComponent<SelectMenuScript>().characters[i].GetComponent<Player>().playable; Debug.Log (gameData.playableCharacters[i]); } binary.Serialize (file, gameData); file.Close (); }
/// <summary> /// Event invocator for the <see cref="DataStored"/> event /// </summary> protected virtual void OnDataStored(Type dataType, IReadOnlyList <BaseData> data) { DataStored?.Invoke(this, new SecurityCacheDataStoredEventArgs(dataType, data)); }