private void DeserializeScore() { if (File.Exists(m_saveFilePath)) { m_lastGameScore = JsonUtility.FromJson <SerializableScores>(File.ReadAllText(m_saveFilePath)); } }
public SerializableScores AsSerializable() { SerializableScores ss = new SerializableScores(); ss.scoresArray = this.ScoresList.ToArray(); return(ss); }
private void SerializeScore() { SerializableScores s = new SerializableScores(); s.m_score = m_currentGameScore; s.m_elapsedTime = m_elapsedTime; s.m_shotNumber = m_shotNumber; string jsonScore = JsonUtility.ToJson(s); if (!File.Exists(m_saveFilePath)) { File.Create(m_saveFilePath).Dispose(); } File.WriteAllText(m_saveFilePath, jsonScore); }
private void Awake() { if (m_instance == null) //first opening of menu { m_instance = this; DontDestroyOnLoad(this); } else //another scene is loaded { if (m_instance != this) //we only want to keep the original object { DestroyImmediate(this.gameObject); } } //lazy init here m_saveFilePath = Application.dataPath + "/lastGameSave.json"; m_lastGameScore = null; }
public void Set(SerializableScores ss) { this.ScoresList = new List <float>(ss.scoresArray); }
public Scores(SerializableScores ss) { Set(ss); }
public Scores(int numScores) { SerializableScores ss = new SerializableScores(numScores); Set(ss); }