예제 #1
0
        IEnumerator WebRequestGet <T>(string _uri, int _timeOut, WebRequestCallBack _timeOutCallBack) where T : WebRequestResult
        {
            _timeOutCallBack("");
            UnityWebRequest request = UnityWebRequest.Get(_uri);

            AsyncOperation res = request.SendWebRequest();

            int cnt = 0;

            while (!res.isDone)
            {
                cnt++;
                if (cnt > _timeOut)
                {
                    _timeOutCallBack(TIME_OUT);
                    yield break;
                }

                yield return(new WaitForSecondsRealtime(0.2f));
            }

            if (!request.isNetworkError)
            {
                string html = request.downloadHandler.text;
                DebugLogMain.hLog(html);
                result = JsonUtility.FromJson <T>(html);
            }
            else
            {
            }


            _timeOutCallBack(request.downloadHandler.text);
        }
예제 #2
0
 // Use this for initialization
 void Start()
 {
     DebugLogMain.InitDebugLog(dLog);
 }