public void SceneLoad(SCENE scene) { GameObject CreateScene = null; for (int i = 0; i < SceneLoadList.Count; i++) { if (SceneLoadList[i].name.Equals(scene.ToString())) { CreateScene = SceneLoadList[i]; break; } } if (CreateScene == null) { CreateScene = Resources.Load("Scene/Scene" + scene.ToString()) as GameObject; if (CreateScene == null) { DebugLog.Error(DebugLog.LOG_TYPE.SCENE, scene.ToString() + " not find"); return; } SceneLoadList.Add(CreateScene); } StartCoroutine(SceneLoadCorountine(CreateScene)); }
IEnumerator Load() { operation = SceneManager.LoadSceneAsync(sceneToLoad.ToString()); if (!loadAutomaticallyWhenReady) //if we do not want to load the level automatically when it is ready.... { operation.allowSceneActivation = false; //When this is false, the new scene will not load automatically when its ready. If it is true, then the second the new scene is fully ready, it will open. } //The image fill amount is set to 0 starting off. This loop will run each frame until the fill amount is full. It while (image.fillAmount <= 0.9f) //if you dont want to use the image to display progress, change this to 'while(operation.progress <=0.9f)' { float progress = Mathf.Clamp01(operation.progress / 0.9f); //Will explain this change further percentageComplete.text = (progress * 100).ToString(); //Displays the load progress (* by 100 as the value is 0-1) image.fillAmount = progress; //Set the image fillAmount to the progress amount Debug.Log("Progress is : " + operation.progress); yield return(null); } if (!loadAutomaticallyWhenReady) //If we dont load the new level automatically when ready, we display a button that the user can then press if they want to progress { loadButton.SetActive(true); } yield return(null); }
public IEnumerator LoadScene(SCENE scene, int wait = 0) { string name = scene.ToString().CapitalizeFirst(); Debug.Log(name); if (wait != 0) { yield return(new WaitForSeconds(wait)); } SceneManager.LoadScene(name); }
public void StartGame() { SceneManager.LoadScene(nextScene.ToString()); }