using RootMotion; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; public class HttpTool : Singleton { public void Get(string baseUrl, string methodName, Action callback) { StartCoroutine(GetRequestErnieBot(baseUrl, methodName, callback)); } private IEnumerator GetRequestErnieBot(string baseUrl, string methodName, Action callback) { string url = baseUrl + methodName; Debug.Log(url); using (UnityWebRequest webRequest = UnityWebRequest.Get(url)) { yield return webRequest.SendWebRequest(); if (webRequest.error!=null ) { Debug.LogError(webRequest.error + "\n" + webRequest.downloadHandler.text); if (callback != null) { callback(null); } } else { if (callback != null) { callback(webRequest.downloadHandler.text); } } } } }