public static MappingsAPIData GetSceneMappingsData(ApiEnvironment environment, string sceneCid) { string url = GetMappingsAPIUrl(environment, sceneCid); UnityWebRequest w = UnityWebRequest.Get(url); w.SendWebRequest(); while (w.isDone == false) { } if (!w.WebRequestSucceded()) { throw new Exception($"Request error! mappings couldn't be fetched for scene {sceneCid}! -- {w.error}"); } MappingsAPIData parcelInfoApiData = JsonUtility.FromJson <MappingsAPIData>(w.downloadHandler.text); if (parcelInfoApiData.data.Length == 0 || parcelInfoApiData.data == null) { throw new Exception("MappingsAPIData is null?"); } return(parcelInfoApiData); }
public static MappingsAPIData GetSceneMappingsData(IWebRequest webRequest, ApiTLD tld, string sceneCid) { string url = GetMappingsAPIUrl(tld, sceneCid); DownloadHandler downloadHandler = null; try { downloadHandler = webRequest.Get(url); } catch (HttpRequestException e) { throw new Exception($"Request error! mappings couldn't be fetched for scene {sceneCid}! -- {e.Message}"); } MappingsAPIData parcelInfoApiData = JsonUtility.FromJson <MappingsAPIData>(downloadHandler.text); downloadHandler.Dispose(); if (parcelInfoApiData.data.Length == 0 || parcelInfoApiData.data == null) { throw new Exception("MappingsAPIData is null?"); } return(parcelInfoApiData); }