public static void GetItemInfo(string fileName, OnMapGetEvent callback) { if (BoardProxy.instance != null) { BoardProxy.instance.StartCoroutine(LoadInfo(fileName, callback)); } else { instance.StartCoroutine(LoadInfo(fileName, callback)); } }
static IEnumerator LoadInfo(string fileName, OnMapGetEvent callback) { Debug.Log("Platform: " + Application.platform.ToString()); if (RuntimePlatform.Android == Application.platform) { string cmbFile = "Maps/" + fileName + ".json"; Dictionary <string, string> localizedText = new Dictionary <string, string> (); string filePath; filePath = Path.Combine(Application.streamingAssetsPath + "/", cmbFile); Debug.Log("filePath: " + filePath); string dataAsJson; if (filePath.Contains("://") || filePath.Contains(":///")) { Debug.Log("Network Shit"); UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath); yield return(www.SendWebRequest()); dataAsJson = www.downloadHandler.text; } else { Debug.Log("Local"); dataAsJson = File.ReadAllText(filePath); } Debug.Log("File: " + cmbFile + " dataAsJson: " + dataAsJson); callback(JsonUtility.FromJson <BoardEditMeta>(dataAsJson)); } else { string path = FILE_BASE + "/Maps/" + fileName + ".json"; Debug.Log("Loading: " + path); if (System.IO.File.Exists(path)) { Debug.Log("File exists"); StreamReader reader = new StreamReader(path); string fInfo = reader.ReadToEnd(); Debug.Log("fInfo: " + fInfo); reader.Close(); if (fInfo.Length > 0) { callback(JsonUtility.FromJson <BoardEditMeta>(fInfo)); } } else { callback(null); } } }