public void ApplyTerrainSettings(int val = -1) { Terrain activeTerrain = Terrain.activeTerrain; int num = (val == -1) ? QualitySettings.GetQualityLevel() : val; if (activeTerrain) { activeTerrain.heightmapPixelError = CJTools.Math.GetProportionalClamp(70f, 20f, (float)num, 0f, 4f); if (num == 0) { activeTerrain.basemapDistance = 0f; } else { activeTerrain.basemapDistance = CJTools.Math.GetProportionalClamp(10f, 25f, (float)num, 1f, 4f); } activeTerrain.castShadows = false; ReliefTerrain component = activeTerrain.gameObject.GetComponent <ReliefTerrain>(); ReliefTerrainGlobalSettingsHolder reliefTerrainGlobalSettingsHolder = (component != null) ? component.globalSettingsHolder : null; if (reliefTerrainGlobalSettingsHolder != null) { reliefTerrainGlobalSettingsHolder.DIST_STEPS = CJTools.Math.GetProportionalClamp(4f, 25f, (float)num, 0f, 4f); reliefTerrainGlobalSettingsHolder.WAVELENGTH = CJTools.Math.GetProportionalClamp(16f, 2.5f, (float)num, 0f, 4f); reliefTerrainGlobalSettingsHolder.SHADOW_STEPS = CJTools.Math.GetProportionalClamp(0f, 25f, (float)num, 0f, 4f); reliefTerrainGlobalSettingsHolder.WAVELENGTH_SHADOWS = CJTools.Math.GetProportionalClamp(16f, 0.5f, (float)num, 0f, 4f); reliefTerrainGlobalSettingsHolder.distance_start = CJTools.Math.GetProportionalClamp(5f, 15f, (float)num, 0f, 4f); reliefTerrainGlobalSettingsHolder.distance_transition = CJTools.Math.GetProportionalClamp(5f, 10f, (float)num, 0f, 4f); if (reliefTerrainGlobalSettingsHolder.distance_start_bumpglobal < reliefTerrainGlobalSettingsHolder.distance_start) { reliefTerrainGlobalSettingsHolder.distance_start_bumpglobal = reliefTerrainGlobalSettingsHolder.distance_start; } RTP_LODmanager rtp_LODmanagerScript = reliefTerrainGlobalSettingsHolder.Get_RTP_LODmanagerScript(); if (rtp_LODmanagerScript) { TerrainShaderLod rtp_LODlevel = rtp_LODmanagerScript.RTP_LODlevel; if (num == 0) { rtp_LODmanagerScript.RTP_LODlevel = TerrainShaderLod.SIMPLE; } else if (num == 1) { rtp_LODmanagerScript.RTP_LODlevel = TerrainShaderLod.PM; } else { rtp_LODmanagerScript.RTP_LODlevel = TerrainShaderLod.POM; } if (rtp_LODlevel != rtp_LODmanagerScript.RTP_LODlevel) { rtp_LODmanagerScript.RefreshLODlevel(); } } reliefTerrainGlobalSettingsHolder.RefreshAll(); } } }
private void OnGUI() { if (!this.LODmanager) { this.GetLODManager(); return; } GUILayout.Space(10f); GUILayout.BeginVertical("box", new GUILayoutOption[0]); GUILayout.Label(string.Empty + FPSmeter.fps, new GUILayoutOption[0]); if (this.panel_enabled) { this.shadows = GUILayout.Toggle(this.shadows, "disable Unity's shadows", new GUILayoutOption[0]); Light component = GameObject.Find("Directional light").GetComponent <Light>(); component.shadows = ((!this.shadows) ? LightShadows.Soft : LightShadows.None); this.forward_path = GUILayout.Toggle(this.forward_path, "forward rendering", new GUILayoutOption[0]); Camera component2 = GameObject.Find("Main Camera").GetComponent <Camera>(); component2.renderingPath = ((!this.forward_path) ? RenderingPath.DeferredLighting : RenderingPath.Forward); if (this.forward_path) { RenderSettings.ambientLight = new Color32(25, 25, 25, 0); } else { RenderSettings.ambientLight = new Color32(93, 103, 122, 0); } TerrainShaderLod rTP_LODlevel = this.LODmanager.RTP_LODlevel; TerrainShaderLod terrainShaderLod = rTP_LODlevel; switch (rTP_LODlevel) { case TerrainShaderLod.POM: if (GUILayout.Button("POM shading", new GUILayoutOption[0])) { terrainShaderLod = TerrainShaderLod.PM; } break; case TerrainShaderLod.PM: if (GUILayout.Button("PM shading", new GUILayoutOption[0])) { terrainShaderLod = TerrainShaderLod.SIMPLE; } break; case TerrainShaderLod.SIMPLE: if (GUILayout.Button("SIMPLE shading", new GUILayoutOption[0])) { terrainShaderLod = TerrainShaderLod.CLASSIC; } break; case TerrainShaderLod.CLASSIC: if (GUILayout.Button("CLASSIC shading", new GUILayoutOption[0])) { terrainShaderLod = TerrainShaderLod.POM; } break; } switch (terrainShaderLod) { case TerrainShaderLod.POM: if (terrainShaderLod != rTP_LODlevel) { GameObject gameObject = GameObject.Find("terrainMesh"); ReliefTerrain reliefTerrain = gameObject.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; reliefTerrain.globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.POM; this.LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.PM: if (terrainShaderLod != rTP_LODlevel) { GameObject gameObject2 = GameObject.Find("terrainMesh"); ReliefTerrain reliefTerrain2 = gameObject2.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; reliefTerrain2.globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.PM; this.LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.SIMPLE: if (terrainShaderLod != rTP_LODlevel) { GameObject gameObject3 = GameObject.Find("terrainMesh"); ReliefTerrain reliefTerrain3 = gameObject3.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; reliefTerrain3.globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.SIMPLE; this.LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.CLASSIC: if (terrainShaderLod != rTP_LODlevel) { GameObject gameObject4 = GameObject.Find("terrainMesh"); ReliefTerrain reliefTerrain4 = gameObject4.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; reliefTerrain4.globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.CLASSIC; this.LODmanager.RefreshLODlevel(); } break; } if (terrainShaderLod == TerrainShaderLod.POM) { this.terrain_self_shadow = this.LODmanager.RTP_SHADOWS; bool flag = GUILayout.Toggle(this.terrain_self_shadow, "self shadowing", new GUILayoutOption[0]); if (flag != this.terrain_self_shadow) { this.LODmanager.RTP_SHADOWS = flag; this.LODmanager.RefreshLODlevel(); } this.terrain_self_shadow = flag; if (this.terrain_self_shadow) { this.terrain_smooth_shadows = this.LODmanager.RTP_SOFT_SHADOWS; bool flag2 = GUILayout.Toggle(this.terrain_smooth_shadows, "smooth shadows", new GUILayoutOption[0]); if (flag2 != this.terrain_smooth_shadows) { this.LODmanager.RTP_SOFT_SHADOWS = flag2; this.LODmanager.RefreshLODlevel(); } this.terrain_smooth_shadows = flag2; } } if (this.LODmanager.RTP_SNOW_FIRST) { GameObject gameObject5 = GameObject.Find("terrainMesh"); ReliefTerrain reliefTerrain5 = gameObject5.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Snow", new GUILayoutOption[] { GUILayout.MaxWidth(40f) }); float num = GUILayout.HorizontalSlider(reliefTerrain5.globalSettingsHolder._snow_strength, 0f, 1f, new GUILayoutOption[0]); if (num != reliefTerrain5.globalSettingsHolder._snow_strength) { reliefTerrain5.globalSettingsHolder._snow_strength = num; reliefTerrain5.globalSettingsHolder.Refresh(null, null); } GUILayout.EndHorizontal(); } GUILayout.Label("Light", new GUILayoutOption[] { GUILayout.MaxWidth(40f) }); this.light_dir = GUILayout.HorizontalSlider(this.light_dir, 0f, 360f, new GUILayoutOption[0]); component.transform.rotation = Quaternion.Euler(40f, this.light_dir, 0f); if (!Application.isWebPlayer && GUILayout.Button("QUIT", new GUILayoutOption[0])) { Application.Quit(); } GUILayout.Label(" F (hold) - freeze camera", new GUILayoutOption[0]); GUILayout.Label(" ,/. - change cam position", new GUILayoutOption[0]); } else if (!Application.isWebPlayer && GUILayout.Button("QUIT", new GUILayoutOption[0])) { Application.Quit(); } GUILayout.Label(" P - toggle panel", new GUILayoutOption[0]); GUILayout.EndVertical(); }
void OnGUI() { if (!LODmanager) { GetLODManager(); return; } GUILayout.Space(10); GUILayout.BeginVertical("box"); GUILayout.Label("" + FPSmeter.fps); if (panel_enabled) { shadows = GUILayout.Toggle(shadows, "disable Unity's shadows"); Light light = GameObject.Find("Directional light").GetComponent <Light>() as Light; light.shadows = shadows ? LightShadows.None : LightShadows.Soft; forward_path = GUILayout.Toggle(forward_path, "forward rendering"); Camera cam = GameObject.Find("Main Camera").GetComponent <Camera>() as Camera; cam.renderingPath = forward_path ? RenderingPath.Forward : RenderingPath.DeferredShading; if (forward_path) { RenderSettings.ambientLight = new Color32(25, 25, 25, 0); } else { RenderSettings.ambientLight = new Color32(93, 103, 122, 0); } // water = GUILayout.Toggle(water, "show water"); //#if UNITY_3_5 // go_water.active=water; //#else // go_water.SetActive(water); //#endif TerrainShaderLod pom = LODmanager.RTP_LODlevel; TerrainShaderLod npom = pom; switch (pom) { case TerrainShaderLod.POM: if (GUILayout.Button("POM shading")) { npom = TerrainShaderLod.PM; } break; case TerrainShaderLod.PM: if (GUILayout.Button("PM shading")) { npom = TerrainShaderLod.SIMPLE; } break; case TerrainShaderLod.SIMPLE: if (GUILayout.Button("SIMPLE shading")) { npom = TerrainShaderLod.POM; //npom =TerrainShaderLod.CLASSIC; } break; //case TerrainShaderLod.CLASSIC: // if (GUILayout.Button("CLASSIC shading")) npom=TerrainShaderLod.POM; //break; } switch (npom) { case TerrainShaderLod.POM: if (npom != pom) { Terrain terrain = (GameObject.Find("Terrain").GetComponent(typeof(Terrain))) as Terrain; ReliefTerrain script = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; script.globalSettingsHolder.Refresh(); LODmanager.RTP_LODlevel = TerrainShaderLod.POM; LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.PM: if (npom != pom) { Terrain terrain = (GameObject.Find("Terrain").GetComponent(typeof(Terrain))) as Terrain; ReliefTerrain script = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; script.globalSettingsHolder.Refresh(); LODmanager.RTP_LODlevel = TerrainShaderLod.PM; LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.SIMPLE: if (npom != pom) { Terrain terrain = (GameObject.Find("Terrain").GetComponent(typeof(Terrain))) as Terrain; ReliefTerrain script = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; script.globalSettingsHolder.Refresh(); LODmanager.RTP_LODlevel = TerrainShaderLod.SIMPLE; LODmanager.RefreshLODlevel(); } break; //case TerrainShaderLod.CLASSIC: // if (npom!=pom) { // Terrain terrain=(GameObject.Find("Terrain").GetComponent (typeof(Terrain))) as Terrain; // ReliefTerrain script=terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; // script.globalSettingsHolder.Refresh(); // LODmanager.RTP_LODlevel=TerrainShaderLod.CLASSIC; // LODmanager.RefreshLODlevel(); // } //break; } pom = npom; if (pom == TerrainShaderLod.POM) { terrain_self_shadow = LODmanager.RTP_SHADOWS; bool nterrain_self_shadow = GUILayout.Toggle(terrain_self_shadow, "self shadowing"); if (nterrain_self_shadow != terrain_self_shadow) { LODmanager.RTP_SHADOWS = nterrain_self_shadow; LODmanager.RefreshLODlevel(); } terrain_self_shadow = nterrain_self_shadow; if (terrain_self_shadow) { terrain_smooth_shadows = LODmanager.RTP_SOFT_SHADOWS; bool nterrain_smooth_shadows = GUILayout.Toggle(terrain_smooth_shadows, "smooth shadows"); if (nterrain_smooth_shadows != terrain_smooth_shadows) { LODmanager.RTP_SOFT_SHADOWS = nterrain_smooth_shadows; LODmanager.RefreshLODlevel(); } terrain_smooth_shadows = nterrain_smooth_shadows; } } if (LODmanager.RTP_SNOW_FIRST) { Terrain terrain = (GameObject.Find("Terrain").GetComponent(typeof(Terrain))) as Terrain; ReliefTerrain script = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; GUILayout.BeginHorizontal(); GUILayout.Label("Snow", GUILayout.MaxWidth(40)); float nval = GUILayout.HorizontalSlider(script.globalSettingsHolder._snow_strength, 0, 1); if (nval != script.globalSettingsHolder._snow_strength) { script.globalSettingsHolder._snow_strength = nval; script.globalSettingsHolder.Refresh(); } GUILayout.EndHorizontal(); } GUILayout.Label("Light", GUILayout.MaxWidth(40)); light_dir = GUILayout.HorizontalSlider(light_dir, 0, 360); light.transform.rotation = Quaternion.Euler(40, light_dir, 0); // GUILayout.Label ("Interp", GUILayout.MaxWidth(40)); // float n_interp = GUILayout.HorizontalSlider(preset_param_interp, 0, 1); // if (n_interp!=preset_param_interp) { // preset_param_interp=n_interp; // Terrain terrain=(GameObject.Find("Terrain").GetComponent (typeof(Terrain))) as Terrain; // ReliefTerrain script=terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; // ReliefTerrainPresetHolder holderA=script.GetPresetByName("terrain stateA"); // ReliefTerrainPresetHolder holderB=script.GetPresetByName("terrain stateB"); // if (holderA!=null && holderB!=null) { // script.InterpolatePresets(holderA.PresetID, holderB.PresetID, preset_param_interp); // script.globalSettingsHolder.Refresh(); // } // } if (!Application.isWebPlayer) { if (GUILayout.Button("QUIT")) { Application.Quit(); } } GUILayout.Label(" F (hold) - freeze camera"); GUILayout.Label(" ,/. - change cam position"); } else { if (!Application.isWebPlayer) { if (GUILayout.Button("QUIT")) { Application.Quit(); } } } GUILayout.Label(" P - toggle panel"); GUILayout.EndVertical(); }
private void OnGUI() { if (!this.LODmanager) { this.GetLODManager(); return; } GUILayout.Space(10f); GUILayout.BeginVertical("box", Array.Empty <GUILayoutOption>()); GUILayout.Label(string.Concat(FPSmeter.fps), Array.Empty <GUILayoutOption>()); if (this.panel_enabled) { this.shadows = GUILayout.Toggle(this.shadows, "disable Unity's shadows", Array.Empty <GUILayoutOption>()); Light component = GameObject.Find("Directional light").GetComponent <Light>(); component.shadows = (this.shadows ? LightShadows.None : LightShadows.Soft); this.forward_path = GUILayout.Toggle(this.forward_path, "forward rendering", Array.Empty <GUILayoutOption>()); GameObject.Find("Main Camera").GetComponent <Camera>().renderingPath = (this.forward_path ? RenderingPath.Forward : RenderingPath.DeferredShading); if (this.forward_path) { RenderSettings.ambientLight = new Color32(25, 25, 25, 0); } else { RenderSettings.ambientLight = new Color32(93, 103, 122, 0); } TerrainShaderLod rtp_LODlevel = this.LODmanager.RTP_LODlevel; TerrainShaderLod terrainShaderLod = rtp_LODlevel; switch (rtp_LODlevel) { case TerrainShaderLod.POM: if (GUILayout.Button("POM shading", Array.Empty <GUILayoutOption>())) { terrainShaderLod = TerrainShaderLod.PM; } break; case TerrainShaderLod.PM: if (GUILayout.Button("PM shading", Array.Empty <GUILayoutOption>())) { terrainShaderLod = TerrainShaderLod.SIMPLE; } break; case TerrainShaderLod.SIMPLE: if (GUILayout.Button("SIMPLE shading", Array.Empty <GUILayoutOption>())) { terrainShaderLod = TerrainShaderLod.POM; } break; } switch (terrainShaderLod) { case TerrainShaderLod.POM: if (terrainShaderLod != rtp_LODlevel) { ((GameObject.Find("Terrain").GetComponent(typeof(Terrain)) as Terrain).GetComponent(typeof(ReliefTerrain)) as ReliefTerrain).globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.POM; this.LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.PM: if (terrainShaderLod != rtp_LODlevel) { ((GameObject.Find("Terrain").GetComponent(typeof(Terrain)) as Terrain).GetComponent(typeof(ReliefTerrain)) as ReliefTerrain).globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.PM; this.LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.SIMPLE: if (terrainShaderLod != rtp_LODlevel) { ((GameObject.Find("Terrain").GetComponent(typeof(Terrain)) as Terrain).GetComponent(typeof(ReliefTerrain)) as ReliefTerrain).globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.SIMPLE; this.LODmanager.RefreshLODlevel(); } break; } if (terrainShaderLod == TerrainShaderLod.POM) { this.terrain_self_shadow = this.LODmanager.RTP_SHADOWS; bool flag = GUILayout.Toggle(this.terrain_self_shadow, "self shadowing", Array.Empty <GUILayoutOption>()); if (flag != this.terrain_self_shadow) { this.LODmanager.RTP_SHADOWS = flag; this.LODmanager.RefreshLODlevel(); } this.terrain_self_shadow = flag; if (this.terrain_self_shadow) { this.terrain_smooth_shadows = this.LODmanager.RTP_SOFT_SHADOWS; bool flag2 = GUILayout.Toggle(this.terrain_smooth_shadows, "smooth shadows", Array.Empty <GUILayoutOption>()); if (flag2 != this.terrain_smooth_shadows) { this.LODmanager.RTP_SOFT_SHADOWS = flag2; this.LODmanager.RefreshLODlevel(); } this.terrain_smooth_shadows = flag2; } } if (this.LODmanager.RTP_SNOW_FIRST) { ReliefTerrain reliefTerrain = (GameObject.Find("Terrain").GetComponent(typeof(Terrain)) as Terrain).GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.Label("Snow", new GUILayoutOption[] { GUILayout.MaxWidth(40f) }); float num = GUILayout.HorizontalSlider(reliefTerrain.globalSettingsHolder._snow_strength, 0f, 1f, Array.Empty <GUILayoutOption>()); if (num != reliefTerrain.globalSettingsHolder._snow_strength) { reliefTerrain.globalSettingsHolder._snow_strength = num; reliefTerrain.globalSettingsHolder.Refresh(null, null); } GUILayout.EndHorizontal(); } GUILayout.Label("Light", new GUILayoutOption[] { GUILayout.MaxWidth(40f) }); this.light_dir = GUILayout.HorizontalSlider(this.light_dir, 0f, 360f, Array.Empty <GUILayoutOption>()); component.transform.rotation = Quaternion.Euler(40f, this.light_dir, 0f); GUILayout.Label(" F (hold) - freeze camera", Array.Empty <GUILayoutOption>()); GUILayout.Label(" ,/. - change cam position", Array.Empty <GUILayoutOption>()); } GUILayout.Label(" P - toggle panel", Array.Empty <GUILayoutOption>()); GUILayout.EndVertical(); }