少年修仙传客户端基础资源
hch
2025-02-14 822513a5dff92368ef8dfe5d12a3544b67bd747a
Assets/Launch/HttpRequest/HttpRequest.cs
@@ -5,6 +5,7 @@
using System.Net;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
namespace StartAot
@@ -31,6 +32,33 @@
            HttpBehaviour.Create(_url, "GET", "", _contentType, _retry, _result);
        }
        //2024-09-26 HttpWebRequest Get CDN资源在某些节日可能无法访问 包含keepalive的设定等不同情况 改用UnityWebRequest
        //获取CDN资源不建议使用HttpWebRequest
        public void UnityWebRequestGet(string _url, int timeout = 5, Action<bool, string> _result = null)
        {
            StartCoroutine(GetDataB(_url, timeout, _result));
        }
        IEnumerator GetDataB(string remoteURL, int timeout, Action<bool, string> _result = null)
        {
            UnityWebRequest request = UnityWebRequest.Get(remoteURL);
            request.timeout = timeout;
            yield return request.SendWebRequest();
            if (request.isDone)
            {
                if (request.result == UnityWebRequest.Result.Success)
                {
                    _result(true, request.downloadHandler.text);
                }
                else
                {
                    _result(false, request.result.ToString());
                }
            }
        }
        static StringBuilder buffer = new StringBuilder();
        public static string HashtablaToString(IDictionary<string, string> parameters)
        {