public string GetConfigJson(string configName) { string url; if (configName.Equals(typeof(AppConfigData).Name)) { url = BaseSettings.Instance.EndPoints.ConfigEndPoint; } else if (configName.Equals(typeof(ConfigInfo).Name)) { url = BaseSettings.Instance.EndPoints.VersionEndPoint; } else { url = SaveData.MainConfigData[configName].Value <string>(); } if (FileManager.IsFileDownloaded(url)) { Debug.Log("Config URL: " + url); return(PiUtilities.LoadJsonData(url.GetUniqueId(), Path.Combine(PiUtilities.SavePath, FileManager.GetFileType(url).ToString()), "." + FileManager.GetFileFormat(url))); } return(string.Empty); }
public void GetData(Action <List <string> > onComplete, UnityEngine.Object owner, Action onFail = null, Action <float> onProgress = null, bool needDataOnComplete = true, params string[] urls) { if (GetFile(owner, onComplete, onFail, onProgress, needDataOnComplete, urls)) { onProgress.SafeInvoke(100); onComplete.SafeInvoke(needDataOnComplete ? urls.Select(x => PiUtilities.LoadJsonData(x.GetUniqueId(), Path.Combine(PiUtilities.SavePath, GetFileType(x).ToString()), "." + GetFileFormat(x))).ToList() : null); } }
public LocalSaveData Load() { var data = PiUtilities.LoadJsonData <LocalSaveData>(BaseConstants.SAVE_DATA_KEY); if (data == default(LocalSaveData)) { return(null); } return(data); }
void OnBatchComplete(UnityWebRequest www) { FileManager.SaveToCache(www); if (IsBatchDownloadOver()) { Coroutines.ForEach(x => FileManager.Instance.StopCoroutine(x)); Coroutines.Clear(); ProgressCallback.SafeInvoke(100f); var url = www.url.Split('?')[0]; for (int i = 0; i < Urls.Count; i++) { Urls[i] = Urls[i].Split('?')[0]; } switch (FileManager.GetFileType(url)) { case EFileType.Audio: { var audioClips = new List <AudioClip>(); if (NeedDataOnComplete) { Urls.ForEach((x) => { FileManager.Instance.StartCoroutine(FileManager.LoadAudioFromCache(FileManager.GetFilePath(x), (y) => { audioClips.Add(y); if (audioClips.Count == Urls.Count) { if (OnCompleteCallback != null) { ((Action <List <AudioClip> >)OnCompleteCallback).SafeInvoke(audioClips); } OnDownloadComplete.SafeInvoke(this); } })); }); } else { if (OnCompleteCallback != null) { ((Action <List <AudioClip> >)OnCompleteCallback).SafeInvoke(audioClips); } OnDownloadComplete.SafeInvoke(this); } break; } case EFileType.Video: { if (NeedDataOnComplete) { var videoUrls = Urls.Select(x => "file://" + FileManager.GetFilePath(x)).ToList(); if (OnCompleteCallback != null) { ((Action <List <string> >)OnCompleteCallback).SafeInvoke(videoUrls); } } else { if (OnCompleteCallback != null) { ((Action <List <string> >)OnCompleteCallback).SafeInvoke(new List <string>()); } } OnDownloadComplete.SafeInvoke(this); break; } case EFileType.Image: { if (NeedDataOnComplete) { var images = Urls.Select(FileManager.LoadImageFromCache).ToList(); if (OnCompleteCallback != null) { ((Action <List <Texture2D> >)OnCompleteCallback).SafeInvoke(images); } } else { if (OnCompleteCallback != null) { ((Action <List <Texture2D> >)OnCompleteCallback).SafeInvoke(new List <Texture2D>()); } } OnDownloadComplete.SafeInvoke(this); break; } case EFileType.Data: { if (NeedDataOnComplete) { var allData = Urls.Select(x => { var json = PiUtilities.LoadJsonData(x.GetUniqueId(), Path.Combine(PiUtilities.SavePath, FileManager.GetFileType(x).ToString()), "." + FileManager.GetFileFormat(x)); return(json); }).ToList(); if (OnCompleteCallback != null) { ((Action <List <string> >)OnCompleteCallback).SafeInvoke(allData); } } else { if (OnCompleteCallback != null) { ((Action <List <string> >)OnCompleteCallback).SafeInvoke(new List <string>()); } } OnDownloadComplete.SafeInvoke(this); break; } } } }