void Awake() { string Save_Path = Application.persistentDataPath; text = gameObject.transform.parent.GetComponent <Text>(); d = new Debug_Log(text, Save_Path); //Initialising the local cache in awake due to constructor d.DUI = SystemInfo.deviceUniqueIdentifier; d.Log(true, "Unique Client ID: " + d.DUI, true); store.d.Clone(d); leaderboard.d.Clone(d); GameState.d.Clone(d); FileStream file; if (!File.Exists(Save_Path + "/" + store.File_Name)) { file = new FileStream(Save_Path + "/" + store.File_Name, FileMode.OpenOrCreate); file.Close(); } if (!File.Exists(Save_Path + "/" + leaderboard.File_Name)) { file = new FileStream(Save_Path + "/" + leaderboard.File_Name, FileMode.OpenOrCreate); file.Close(); } if (!File.Exists(Save_Path + "/" + GameState.File_Name)) { file = new FileStream(Save_Path + "/" + GameState.File_Name, FileMode.OpenOrCreate); file.Close(); } leaderboard.Load(); store.Load(); GameState.Load(); }
internal void Get_Modified_Date() { if (!File.Exists(d.path + "/" + File_Name)) { try { File.Create(d.path + "/" + File_Name); } catch (Exception e) { d.Log(false, "Creating new file for path: " + d.path + "/" + File_Name + " failed! > " + e.Message, true); } finally { if (file != null) { file.Close(); } } } else { d.Log(true, "Attempting to get Modified date from local cache file.", false); try { file = new FileStream(d.path + "/" + File_Name, FileMode.OpenOrCreate); BinaryReader br = new BinaryReader(file); Modified = Convert.ToDateTime(br.ReadString()); br.Close(); file.Close(); } catch (Exception e) { d.Log(false, "Reading Modified date from .dat file failed > " + e.Message, true); } finally { if (file != null) { file.Close(); } } d.Log(true, "Successfully read Modified date from local cache file.", false); } }