public void Load() { if (File.Exists(this.JsonPath)) { string jsonStr = FileReference.Read(this.JsonPath); this._data = JsonUtility.FromJson <VersionData>(jsonStr); } else { this._data = new VersionData(); this.Save(); } }
/************************************************************************ * Coroutine Declaration * ************************************************************************/ private IEnumerator CoroutineVersionLoad() { this._http = new UnityWebRequest(URL); this._http.SetRequestHeader("Content-Type", "application/json"); this._http.SetRequestHeader("Accepted", "application/json"); this._http.downloadHandler = new DownloadHandlerBuffer(); yield return(this._http.SendWebRequest()); do { yield return(null); }while (!this._http.isDone); bool isSuccess = false; if (string.IsNullOrEmpty(this._http.error) || (this._http.responseCode < 300 && this._http.responseCode >= 200)) { //Check version try { VersionData data = JsonUtility.FromJson <VersionData>(this._http.downloadHandler.text); EditorPrefs.SetString(StoreCheckedDate, this.GetToday()); EditorPrefs.SetString(StoreLastVersion, data.version); if (!IsDownloading) { this._listener(data.version); } isSuccess = true; } catch (System.Exception e) { Debug.Log(e.Message); this._listener("error"); } } this._http.Dispose(); if (!isSuccess) { this._listener("error"); } this.IsChecking = false; if (this._packageLoad != null) { this._packageLoad(); } }