Beispiel #1
0
        public static WebRequestQueueOperation QueueRequest(UnityWebRequest request)
        {
            WebRequestQueueOperation queueOperation = new WebRequestQueueOperation(request);

            if (s_ActiveRequests.Count < s_MaxRequest)
            {
                UnityWebRequestAsyncOperation webRequestAsyncOp = null;
                try
                {
                    webRequestAsyncOp = request.SendWebRequest();
                    s_ActiveRequests.Add(webRequestAsyncOp);

                    if (webRequestAsyncOp.isDone)
                    {
                        OnWebAsyncOpComplete(webRequestAsyncOp);
                    }
                    else
                    {
                        webRequestAsyncOp.completed += OnWebAsyncOpComplete;
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError(e.Message);
                }

                queueOperation.Complete(webRequestAsyncOp);
            }
            else
            {
                s_QueuedOperations.Enqueue(queueOperation);
            }

            return(queueOperation);
        }
        public static WebRequestQueueOperation QueueRequest(UnityWebRequest request)
        {
            WebRequestQueueOperation queueOperation = new WebRequestQueueOperation(request);

            if (s_ActiveRequests.Count < s_MaxRequest)
            {
                var webRequestAsyncOp = request.SendWebRequest();
                s_ActiveRequests.Add(webRequestAsyncOp);

                if (webRequestAsyncOp.isDone)
                {
                    OnWebAsyncOpComplete(webRequestAsyncOp);
                }
                else
                {
                    webRequestAsyncOp.completed += OnWebAsyncOpComplete;
                }

                queueOperation.Complete(webRequestAsyncOp);
            }
            else
            {
                s_QueuedOperations.Enqueue(queueOperation);
            }

            return(queueOperation);
        }