public void GetAudioClip(HttpData data, AudioType audioType, Http.FinishedDelegate finish = null) { data.method = Http.kHttpVerbAudioClip; data.audioType = audioType; Request(data, finish); }
/// <summary> /// POST request the specified data. /// </summary> /// <param name="data">HttpData.</param> public void Post(HttpData data, Http.FinishedDelegate finish = null) { #if UNITY_5_4_OR_NEWER data.method = UnityWebRequest.kHttpVerbPOST; #else data.post = true; #endif Request(data, finish); }
public void GetTexture(HttpData data, Http.FinishedDelegate finish = null) { data.method = Http.kHttpVerbTexture; Request(data, finish); }
/// <summary> /// Request the specified data and post. /// </summary> /// <param name="data">HttpData.</param> /// <param name="post">If set to <c>true</c> post.</param> public void Request(HttpData data, Http.FinishedDelegate finish = null) { time = Time.time; Action innerRequest = () => { if (preReuqest != null) { data = preReuqest(data); } this.data = data; Http http; #if UNITY_5_4_OR_NEWER if (data.method == UnityWebRequest.kHttpVerbPOST) { #else if (data.post) { #endif http = new Http(this, data.url); http.AddRangeData(data.datas); } else { http = new Http(this, data.url, data.datas); } #if UNITY_5_4_OR_NEWER http.method = data.method; http.audioType = data.audioType; http.OnFail = (UnityWebRequest www) => { this.www = www; OnFail(); }; http.OnDisposed = (UnityWebRequest www) => { this.www = www; OnDisposed(); }; http.OnDone = (UnityWebRequest www) => { this.www = www; OnDone(); }; #else http.OnFail = (WWW www) => { this.www = www; OnFail(); }; http.OnDisposed = (WWW www) => { this.www = www; OnDisposed(); }; http.OnDone = (WWW www) => { this.www = www; OnDone(); }; #endif // set headers http.Headers = data.headers; // set timeout time http.Timeout = data.timeout; http.Request(); }; if (finish != null) { data.finishedDelegate = finish; } if (data.popUp) { if (SceneManager.Instance.DefaultLoadingJobSceneName != "") { if (SceneManager.Instance.IsLoadingJob) { HDebug.LogWarning("Now loading scene active"); } SceneManager.Instance.PopUp(SceneManager.Instance.DefaultLoadingJobSceneName, null, delegate(SSceneController ctrl) { popUp = ctrl; innerRequest(); }); } else { HDebug.LogWarning("The default loading scene is not set"); } } else { innerRequest(); } }