/// <summary> /// HttpWebRequest:Post /// </summary> /// <param name="url"></param> /// <param name="data"></param> public static void SendRequest1(string postData, string url, HttpRequestCallback callback = null) { if (url == null || url.Equals("")) { App.logManager.Info("--- httpHelper url is null ---"); return; } if (postData == null) { postData = ""; } if (callback == null) { PostAsyn(url, postData); } else { CoroutineTask task = App.objectPoolManager.GetObject <CoroutineTask>(); task.routine = PostSyn(url, postData, callback); task.Start(); task.callback = (t) => { App.objectPoolManager.ReleaseObject(t); }; } }
/// <summary> /// 销毁 /// </summary> public void Dispose() { Stop(); // 销毁协程 if (_task != null) { App.objectPoolManager.ReleaseObject(_task); _task = null; } audioAsset = null; // 销毁音频源 if (_audioSource != null) { _audioSource.clip = null; UnityEngine.Object.DestroyImmediate(_audioSource, true); _audioSource = null; } _completeCallback = null; _state = AudioState.UNLOAD; }
/// <summary> /// 播放 /// </summary> public void Play() { // 音频资源不存在则加载资源 if (_audioAsset == null) { AudioAsset asset = App.assetManager.GetAsset <AudioAsset>(_url); if (asset != null) { audioAsset = asset; } if (_audioAsset == null) { if (_state == AudioState.LOADING) { return; } // 音频资源未正在加载则开始加载资源 _state = AudioState.LOADING; Load(); return; } } // 音频资源存在,开启协程播放音频 _state = AudioState.PLAY; if (_task == null) { _task = App.objectPoolManager.GetObject <CoroutineTask>(); } _task.routine = StartPlay(); _task.Start(); }
/// <summary> /// 开始加载 /// </summary> public virtual void Start() { if (_state != LoadState.STOPED) { Stop(); } _state = LoadState.STARTED; _stats.Start(); if (_task == null) { _task = App.objectPoolManager.GetObject <CoroutineTask>(); } _task.routine = InvokeLoading(); _task.Start(); if (_startCallback != null) { _startCallback.Invoke(this); } }
/// <summary> /// 销毁 /// </summary> public virtual void Dispose() { Stop(); onDispose(); if (_task != null) { App.objectPoolManager.ReleaseObject(_task); _task = null; } _loadParams = null; _stats = null; _state = LoadState.STOPED; _data = null; _asset = null; _startCallback = null; _stopCallback = null; _completeCallback = null; _errorCallback = null; _progressCallback = null; }