Beispiel #1
0
 public void AddJob(DownloadRequest request)
 {
     requests.Enqueue(request);
     jobs++;
     if (jobs == 1)
     {
         SwarmManager.Instance.StartCoroutine(ProcessRequestsCoroutine());
     }
     //Debug.Log("jobs" + jobs);
 }
Beispiel #2
0
        private IEnumerator ProcessRequestsCoroutine()
        {
            while (requests.Count > 0)
            {
                DownloadRequest currRequest = requests.Dequeue();
                UnityWebRequest www         = UnityWebRequestTexture.GetTexture(currRequest.url);
                yield return(www.Send());

                if (www.isNetworkError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    //Texture2D newTex = DownloadHandlerTexture.GetContent(www);
                    currRequest.callbackAction.Invoke(www);
                }
                jobs--;
                //Debug.Log("jobs" + jobs);
            }
        }
Beispiel #3
0
 public void EnqueueRequest(DownloadRequest request)
 {
     operators.OrderBy(so => so.jobs).First().AddJob(request);
 }