private void Update() { if (_ops != null && _ops.Count > 0) { try { foreach (var item in _ops) { if (item.Key is AsyncOperation) { var asyncOp = item.Key as AsyncOperation; if (asyncOp.isDone) { _opsToRemove.Add(asyncOp); item.Value(); } } #if UNITY_5_4_OR_NEWER else if (item.Key is UnityWebRequest) { var asyncOp = item.Key as UnityWebRequest; if (asyncOp.isDone) { _opsToRemove.Add(asyncOp); item.Value(); } } #endif else if (item.Key is WWW) { var asyncOp = item.Key as WWW; if (asyncOp.isDone) { _opsToRemove.Add(asyncOp); item.Value(); } } } } catch (Exception e) { Debug.LogException(e, this); } foreach (var item in _opsToRemove) { _ops.Remove(item); } _opsToRemove.Clear(); } if (_updateSource != null) { try { _updateSource.OnNext(Time.deltaTime); } catch (Exception e) { Debug.LogException(e, this); } } #if NET_2_0 || NET_2_0_SUBSET if (_actionQueue.Count > 0) { lock (_actionQueue) { while (_actionQueue.Count > 0) { var asyncResult = _actionQueue.Dequeue(); try { asyncResult.Start(); asyncResult.SetCompleted(); } catch (Exception e) { asyncResult.SetException(e); Debug.LogException(e, this); } } } } #else InvokeResult invokeResult = null; while (_actionQueue.TryDequeue(out invokeResult)) { try { invokeResult.Start(); invokeResult.SetCompleted(); } catch (Exception e) { invokeResult.SetException(e); Debug.LogException(e, this); } } #endif }