IEnumerator loadMicrogameAsync(MicrogameLoadOperation operation) { AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(operation.microgame.name, LoadSceneMode.Additive); while (!asyncOperation.isDone) { yield return(null); } operation.finished = true; for (int i = 0; i < operationQueue.Count; i++) { if (!operationQueue[i].finished) { yield return(null); if (loadResourcesAsync) { StartCoroutine(loadScene(operationQueue[i])); } else { StartCoroutine(loadMicrogameAsync(operationQueue[i])); } i = operationQueue.Count; } } yield return(null); }
IEnumerator loadAssetsAsync(MicrogameLoadOperation operation) { Debug.Log(operation.resourceQueue.Count); yield return(null); ResourceRequest request = null; for (int i = 0; i < operation.resourceQueue.Count; i++) { switch (operation.resourceQueue[i].type) { case (ResourceType.Texture2D): request = Resources.LoadAsync <Texture2D>(operation.resourceQueue[i].path); break; default: break; } while (!request.isDone) { Debug.Log((lastTime - System.DateTime.Now).Milliseconds); yield return(null); } Debug.Log("Done: " + (lastTime - System.DateTime.Now).Milliseconds); yield return(null); operation.requests.Add(request); } StartCoroutine(loadMicrogameAsync(operation)); yield return(null); }
IEnumerator loadScene(MicrogameLoadOperation operation) { string resourcePath = "", path = ""; //Application.dataPath + "/Resources/", //path = "Microgames/" + (operation.microgame.unfinished ? "" : "_Finished/") + operation.microgame.name + "/";///Resources/"; /// //int offset = ("Assets/Resources/").Length; //path = path.Substring(offset, path.Length - offset); lastTime = System.DateTime.Now; doneQueueing = false; StartCoroutine(queueResources(operation.resourceQueue, resourcePath, path, true)); while (!doneQueueing) { yield return(null); } StartCoroutine(loadAssetsAsync(operation)); }
public void queueMicrogame(ScenarioController.Microgame microgame) { MicrogameLoadOperation newOperation = new MicrogameLoadOperation(microgame); operationQueue.Add(newOperation); for (int i = 0; i < operationQueue.Count - 1; i++) { if (!operationQueue[i].finished) { return; } } if (loadResourcesAsync) { StartCoroutine(loadScene(newOperation)); } else { StartCoroutine(loadMicrogameAsync(newOperation)); } }