Пример #1
0
        private IEnumerator GetDataCR <T>(string endpoint, Action <T> callback) where T : LoLAPI_JsonObject
        {
            string url = "http://ddragon.leagueoflegends.com/cdn/6.24.1/data/en_US/" + endpoint;

            using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
            {
                yield return(webRequest.SendWebRequest());

                if (webRequest.isNetworkError)
                {
                    Debug.LogError("[LoLAPI] - " + webRequest.error);
                }
                else
                {
                    if (callback != null)
                    {
                        callback.Invoke(LoLAPI_Json.ToObject <T>(webRequest.downloadHandler.text));
                    }
                }
            }
        }
Пример #2
0
        private IEnumerator GetRequestCR <T>(string endpoint, Action <T> callback) where T : LoLAPI_JsonObject
        {
            string url = "https://na1.api.riotgames.com" + endpoint + "?api_key=" + LoLAPI_Settings.API_KEY;

            using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
            {
                yield return(webRequest.SendWebRequest());

                if (webRequest.isNetworkError)
                {
                    Debug.LogError("[LoLAPI] - " + webRequest.error);
                }
                else
                {
                    if (callback != null)
                    {
                        callback.Invoke(LoLAPI_Json.ToObject <T>(webRequest.downloadHandler.text));
                    }
                }
            }
        }