private void Refresh() { LightsInit(); RendererSetup.SetupProbes(); RenderSettings.ambientMode = AmbientMode.Skybox; EnvironmentUpdateFlag = true; }
IEnumerator LoadScene(FolderAssist.FileInfo file, bool unloadOldScene = false, int variant = 0) { IsLoading = true; //DisableLightMap(true); if (StudioMode) { var scene = Studio.Scene.Instance; while (true) { Console.WriteLine("Added scene name: " + scene.addSceneName); if (scene.addSceneName == string.Empty) { break; } scene.UnLoad(); } } deferredShading.InitDeferredShading(Camera.main); AssetBundle AB; if (asyncLoad) { AssetBundleCreateRequest assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(file.FullPath); yield return(assetBundleCreateRequest); AB = assetBundleCreateRequest.assetBundle; } else { AB = AssetBundle.LoadFromFile(file.FullPath); } scenePaths = AB.GetAllScenePaths(); SceneVariant = 0; if (!unloadOldScene) { RootGOs = SceneManager.GetActiveScene().GetRootGameObjects(); foreach (var GO in RootGOs) { Console.WriteLine("Root Gameobject: " + GO.name); DontDestroyOnLoad(GO); //SceneManager.MoveGameObjectToScene(GO, newscene); } } if (asyncLoad) { var asyncOperation = SceneManager.LoadSceneAsync(scenePaths[variant], LoadSceneMode.Single); asyncOperation.allowSceneActivation = false; while (!asyncOperation.isDone) { yield return(null); if (asyncOperation.progress > 0.899f && !asyncOperation.allowSceneActivation) { if (SceneManager.GetActiveScene().buildIndex != -1) { foreach (var l in defaultLights) { if (l.name == "CharaLight_back") { l.GetComponent <AlloyAreaLight>().Intensity = 0f; } else { l.enabled = false; } } var map = FindObjectOfType <Map>(); if (null != map) { GlobalData.showMap = false; map.ChangeShow(); } } asyncOperation.allowSceneActivation = true; } } } else { if (SceneManager.GetActiveScene().buildIndex != -1) { foreach (var l in defaultLights) { if (l.name == "CharaLight_back") { l.GetComponent <AlloyAreaLight>().Intensity = 0f; } else { l.enabled = false; } } } SceneManager.LoadScene(scenePaths[variant], LoadSceneMode.Single); var map = FindObjectOfType <Map>(); if (null != map) { GlobalData.showMap = false; map.ChangeShow(); } SceneManager.SetActiveScene(SceneManager.GetSceneByPath(scenePaths[variant])); } if (unloadOldScene) { Scenebundle.Unload(true); } Scenebundle = AB; if (StudioMode) { var bg = FindObjectOfType <Studio.BackgroundCtrl>(); bg.isVisible = false; bg.enabled = false; Camera.main.clearFlags = CameraClearFlags.Skybox; } Camera.main.GetOrAddComponent <FlareLayer>().enabled = true; Camera.main.GetComponent <Skybox>().enabled = false; probeComponent.enabled = false; RendererSetup.SetupProbes(); //EnvironmentUpdateFlag = true; Resources.UnloadUnusedAssets(); IsLoading = false; PPCtrl.enableFog = RenderSettings.fog; CloneSceneRenderSettings(); LightsInit(); ReflectionProbeChangeMode(rpRate); yield break; }