public void Init() { if (IsLoading == true || isCancel == true) { Cancel(); return; } IsLoading = true; persistentStore = new PersistentDataStorage(Game.None); cacheDirectory = persistentStore.GetPersistentDataPath(""); cache = new Dictionary <string, double>(); if (persistentStore.FileExists(CacheName)) { string tempOldCache = persistentStore.LoadText(CacheName); Log.Debug("old cache text = " + tempOldCache, Log.LogChannel.Download); string[] tempOldCacheLines = tempOldCache.Split('\n'); for (int i = 0; i < tempOldCacheLines.Length; i++) { if (!string.IsNullOrEmpty(tempOldCacheLines[i])) { string rawLine = tempOldCacheLines[i]; string[] rawLineComponents = rawLine.Split(':'); cache[rawLineComponents[0]] = double.Parse(rawLineComponents[1]); } } } downloads = new List <string>(); cloudStorageAPI = new CloudStorageAPI(monoBehaviour); progress = new Progress(); progress.StartingFileCount = 1; progress.FileRemainingCount = 1; #if RC_BUILD progress.Sections = 2; progress.CurrentSection = 1; UpdateProgress(); cloudStorageAPI.GetContentList(OnContentList, ""); #else progress.Sections = 3; progress.CurrentSection = 1; UpdateProgress(); cloudStorageAPI.AuthenticateWithGAE(OnAuthResponse, (downloadPercent) => { progress.PercentOfCurrentLoadingFileDownloaded = downloadPercent; UpdateProgress(); }); #endif }
/// <summary> /// Gets the manifest verison. /// If multiple entries appear in the string[], then each manifest file has been loaded but its contents not completely downlaoded, in the order that they were downloaded. /// </summary> /// <returns>The manifest verison.</returns> public static string[] GetManifestVersion() { PersistentDataStorage persistentDataStorage = new PersistentDataStorage(Game.None); if (persistentDataStorage.FileExists(ManifestVersionFile)) { string existingVersion = persistentDataStorage.LoadText(ManifestVersionFile); return(existingVersion.Split(',')); } return(new string[1] { "1" }); }
public Quality GetQuality() { int storeadQuality = (int)Enum.GetValues(typeof(Quality)).Cast<Quality>().Last(); if (storage.FileExists(QualitySettingsFileName) == true) { storeadQuality = int.Parse(storage.LoadText(QualitySettingsFileName)); Log.Debug("loading quality from file. quality = " + storeadQuality); } else { Device device = sdk.Settings.CurrentDevice; if (device != null) { Log.Debug("getting qaultiy on first run based on device."); storeadQuality = device.Quality; } Log.Debug("saving first time run quality. quality = " + storeadQuality); SaveQuality(storeadQuality); } return (Quality)storeadQuality; }
/// <summary> /// Appends the manifest version. /// </summary> /// <param name="version">Version.</param> public static void AppendManifestVersion(string version) { PersistentDataStorage persistentDataStorage = new PersistentDataStorage(Game.None); if (persistentDataStorage.FileExists(ManifestVersionFile)) { version = version.Replace("\"", ""); version = version.TrimStart('0'); string existingVersion = persistentDataStorage.LoadText(ManifestVersionFile); if (existingVersion != version) { string[] parts = existingVersion.Split(','); existingVersion = parts[0]; persistentDataStorage.SaveText(ManifestVersionFile, existingVersion + "," + version, false); } } else { WriteManifestVersion(version); } }
private string LoadFromCdnOrSdkResources(string fileName) { string path = System.IO.Path.Combine("Profiles", fileName); // first try the OTA versions if (persistentDataStorage.FileExists(path)) { Log.Debug("load settings from persistent : " + persistentDataStorage.GetPersistentDataPath(path)); string text = persistentDataStorage.LoadText(path); if (text != null) { return(text); } } // fallback to load from Resources path = path.Replace(".json", "").Replace(".txt", ""); //Log.Debug("attempt to load Resource from " + path); TextAsset textAsset = Resources.Load <TextAsset>(path); return(textAsset != null ? textAsset.text : null); }
/// <summary> /// Purges the cpipe cache. /// Called when app starts and runs if the app version on disk is older then the app verison. /// The purge will delete any english or non loc specific files and update the cache with all of the latest version from the embedded manifest. /// </summary> public static void PurgeCpipeCache() { bool doPurge = false; Dictionary <string, string> cache = new Dictionary <string, string>(); PersistentDataStorage persistentDataStorage = new PersistentDataStorage(Game.None); StreamingAssetsStorage streamingAssetsStorage = new StreamingAssetsStorage(Game.None, null); //if app version has increased, do purge AppVersion appVersion = new AppVersion(Application.version); if (persistentDataStorage.FileExists(appVerisonFile)) { AppVersion storedVersion = new AppVersion(persistentDataStorage.LoadText(appVerisonFile)); if (storedVersion.Major > appVersion.Major) { doPurge = true; } else if (storedVersion.Major >= appVersion.Major && storedVersion.Minor > appVersion.Minor) { doPurge = true; } else if (storedVersion.Major >= appVersion.Major && storedVersion.Minor >= appVersion.Minor && storedVersion.Revision > appVersion.Revision) { doPurge = true; } } else { doPurge = true; } Log.Debug("dopurge " + doPurge, Log.LogChannel.General); if (doPurge == false) { return; } string oldCache = ""; if (persistentDataStorage.FileExists(CacheName)) { oldCache = persistentDataStorage.LoadText(CacheName); string[] tempOldCacheLines = oldCache.Split('\n'); for (int i = 0; i < tempOldCacheLines.Length; i++) { if (!string.IsNullOrEmpty(tempOldCacheLines[i])) { string rawLine = tempOldCacheLines[i]; string[] rawLineComponents = rawLine.Split(':'); cache[rawLineComponents[0]] = rawLineComponents[1]; } } } Log.Debug("load manifest from streaming at " + Application.streamingAssetsPath + "/" + Game.ForceVision + "/" + EmbeddedCpipeManifestFile, Log.LogChannel.General); //load streaming assets manifest and write cache file of embedded content streamingAssetsStorage.LoadStreamingAssetsText(Game.ForceVision + "/" + EmbeddedCpipeManifestFile, (error, text) => { if (string.IsNullOrEmpty(error)) { try { JSONObject manifest = new JSONObject(text); WriteManifestVersion(manifest["version"].ToString()); JSONObject paths = manifest["paths"]; string newCacheString = ""; for (int i = 0; i < paths.keys.Count; i++) { string folder = paths.keys[i]; string v = paths[i]["v"].ToString(); //update english only bool isEnglishFile = true; foreach (string languageFolder in Localizer.LanguageFolders) { if (folder.Contains("GeneratedSoundBanks") && folder.Contains("/" + languageFolder + "/") && languageFolder != Localizer.LanguageFolders[0]) { isEnglishFile = false; Log.Debug("non english file found. path = " + folder, Log.LogChannel.Download); } } if (isEnglishFile) { if (cache.ContainsKey(folder)) { //if in cache already then update to local version and delete local file if (persistentDataStorage.FileExists(folder)) { persistentDataStorage.DeleteFile(folder); Log.Debug("deleteing file in " + folder, Log.LogChannel.Download); } } newCacheString += folder + ":" + v + "\n"; } else { if (cache.ContainsKey(folder)) { newCacheString += folder + ":" + v + "\n"; } } } persistentDataStorage.SaveText(CacheName, newCacheString, false); persistentDataStorage.SaveText(appVerisonFile, Application.version, false); } catch (System.Exception e) { Log.Exception(e); } } else { #if !UNITY_EDITOR Log.Error("error loading manifest from streamingassets. " + error); #endif } }, true); }