static void SetupLitmap(SceneDataLitAsset dstScene, SceneDataLitAsset srcScene, SceneAssetSet srcSceneSet, int startIndex = 0 ) { if (dstScene.lightMapData == null || dstScene.lightMapData.Length < 1 || srcScene.lightMapData == null || srcScene.lightMapData.Length < 1 ) { return; } var lmDatas = LightmapSettings.lightmaps; if (lmDatas.Length < startIndex + srcSceneSet.lightMapData.Length) { return; } var datas = LightmapDatas(srcSceneSet); for (int i = 0; i < datas.Length; i++) { lmDatas[startIndex + i] = datas[i]; } LightmapSettings.lightmaps = lmDatas; }
public static void SwitchSceneLit( SceneDataLitAsset dstScene, SceneDataLitAsset srcScene, SceneAssetSet srcSceneSet ) { if (dstScene == null || srcScene == null || srcSceneSet == null) { return; } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); //find node in scene var sceneName = GetSceneNameFromAsset(dstScene); var sceneRoot = FindSceneRoot(sceneName); if (sceneRoot == null || srcSceneSet.sceneRoot == null) { return; } //setup litmpa data SetupLitmap(dstScene, srcScene, srcSceneSet); //Setup Materials Transform envRoot = sceneRoot.transform.Find(SceneDataAsset.EnvRootName); if (envRoot != null) { var srcEnvRoot = srcSceneSet.sceneRoot.transform.Find(SceneDataAsset.EnvRootName); CloneEnvRootInfo(srcEnvRoot, envRoot); } //Setup Lit and Shadows Transform sunRoot = sceneRoot.transform.Find(SceneDataAsset.SunRootName); if (sunRoot != null) { var srcSunRoot = srcSceneSet.sceneRoot.transform.Find(SceneDataAsset.SunRootName); CloneLitInfo(srcSunRoot, sunRoot, srcSceneSet); } QualitySetting.GraphicQualityConfigManager.Instance.ApplyPostProcessingConfig(); Shader.SetGlobalFloat("_FogStrengthYStart", srcScene.fogHeight); Shader.SetGlobalFloat("_FogStrengthYParam", srcScene.fogTransition); Shader.SetGlobalFloat("_windStr", srcScene.windStrength); ApplyRenderSetting(srcScene, srcSceneSet); if (srcScene.charEnvColor.maxColorComponent > 0f) { Shader.EnableKeyword(SceneDataAsset.CharEnvLitKeyword); Shader.SetGlobalColor(SceneDataAsset.charEnvColorPropId, srcScene.charEnvColor); } else { Shader.DisableKeyword(SceneDataAsset.CharEnvLitKeyword); } sw.Stop(); Debug.Log("use time:" + sw.ElapsedMilliseconds); }