public override void OnInspectorGUI() { m_editorUtils.Initialize(); // Do not remove this! m_spawnerSettings = (SpawnerSettings)target; string message = m_editorUtils.GetTextValue("Intro");; EditorGUILayout.HelpBox(message, MessageType.Info, true); if (GUILayout.Button(m_editorUtils.GetContent("AddToScene"))) { m_spawnerSettings.CreateSpawner(); } GUILayout.Label(m_editorUtils.GetContent("SpawnRulePreview"), m_editorUtils.Styles.heading); GaiaResource resource = m_spawnerSettings.m_resources;// (GaiaResource)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_spawnerSettings.m_resourcesGUID), typeof(GaiaResource)); foreach (SpawnRule rule in m_spawnerSettings.m_spawnerRules) { m_editorUtils.LabelField("Name", new GUIContent(rule.m_name)); m_editorUtils.LabelField("Type", new GUIContent(rule.m_resourceType.ToString())); Texture2D resourceTexture = SpawnerEditor.GetSpawnRulePreviewTexture(rule, resource); if (resourceTexture != null) { m_editorUtils.Image(resourceTexture, 100, 100); } } }
private void DrawStopwatchEvent(GaiaStopWatchEvent stopWatchEvent) { int id = m_gaiastopwatchDataset.m_events.FindIndex(x => x == stopWatchEvent); m_unfoldedStates[id] = m_editorUtils.Foldout(m_unfoldedStates[id], new GUIContent(stopWatchEvent.m_name)); if (m_unfoldedStates[id]) { EditorGUI.indentLevel++; m_editorUtils.LabelField("FirstStart", new GUIContent(stopWatchEvent.m_firstStartTimeStamp.ToString())); m_editorUtils.LabelField("TotalDuration", new GUIContent(stopWatchEvent.m_accumulatedTime.ToString())); m_editorUtils.LabelField("Calls", new GUIContent(stopWatchEvent.m_callCount.ToString())); m_editorUtils.LabelField("DurationPerCall", new GUIContent(stopWatchEvent.m_durationPerCall.ToString())); List <GaiaStopWatchEvent> relevantEvents; if (m_orderbyDescending) { relevantEvents = m_gaiastopwatchDataset.m_events.FindAll(x => x.m_parent == stopWatchEvent.m_name).OrderByDescending(m_orderByLambda).ToList(); } else { relevantEvents = m_gaiastopwatchDataset.m_events.FindAll(x => x.m_parent == stopWatchEvent.m_name).OrderBy(m_orderByLambda).ToList(); } foreach (GaiaStopWatchEvent subEvent in relevantEvents) { DrawStopwatchEvent(subEvent); } EditorGUI.indentLevel--; } }
private void LightingProfileSettingsEnabled(bool helpEnabled) { //Building up a value array of incrementing ints of the size of the lighting profile values array, this array will then match the displayed string selection in the popup int[] lightingProfileValuesIndices = Enumerable .Repeat(0, (int)((m_profile.m_lightingProfiles.Count - 1) / 1) + 1) .Select((tr, ti) => tr + (1 * ti)) .ToArray(); string[] profileNames = m_profile.m_lightingProfiles.Select(x => x.m_typeOfLighting).ToArray(); //Injecting the "None" option lightingProfileValuesIndices = GaiaUtils.AddElementToArray(lightingProfileValuesIndices, -99); profileNames = GaiaUtils.AddElementToArray(profileNames, "None"); EditorGUILayout.BeginHorizontal(); if (m_profile.m_renamingProfile) { m_profileValues.m_profileRename = m_editorUtils.TextField("NewProfileName", m_profileValues.m_profileRename); } else { m_profile.m_selectedLightingProfileValuesIndex = EditorGUILayout.IntPopup("Lighting Profile", m_profile.m_selectedLightingProfileValuesIndex, profileNames, lightingProfileValuesIndices); } #if !GAIA_PRO_PRESENT bool currentGUIState = GUI.enabled; if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky) { GUI.enabled = false; } #endif if (m_profile.m_selectedLightingProfileValuesIndex != -99) { m_profileValues = m_profile.m_lightingProfiles[m_profile.m_selectedLightingProfileValuesIndex]; m_profileValues.m_ambientMode = RenderSettings.ambientMode; } if (m_profileValues.m_userCustomProfile) { if (m_profile.m_renamingProfile) { if (m_editorUtils.Button("Save", GUILayout.MaxWidth(55f))) { m_profileValues.m_typeOfLighting = m_profileValues.m_profileRename; m_profile.m_renamingProfile = false; } } else { if (m_editorUtils.Button("Rename", GUILayout.MaxWidth(55f))) { m_profile.m_renamingProfile = true; m_profileValues.m_profileRename = m_profileValues.m_typeOfLighting; } } if (m_editorUtils.Button("Remove", GUILayout.MaxWidth(30f))) { m_profile.m_renamingProfile = false; m_profile.m_lightingProfiles.RemoveAt(m_profile.m_selectedLightingProfileValuesIndex); m_profile.m_selectedLightingProfileValuesIndex--; } } if (m_editorUtils.Button("MakeCopy", GUILayout.MaxWidth(30f))) { AddNewCustomProfile(); } EditorGUILayout.EndHorizontal(); if (m_profile.m_selectedLightingProfileValuesIndex == -99) { EditorGUILayout.HelpBox("No Profile selected. Select another profile that is not 'None' to view settings to edit", MessageType.Info); } else { if (!m_profileValues.m_userCustomProfile) { m_profile.m_renamingProfile = false; EditorGUILayout.HelpBox("This is one of the default Gaia lighting profiles. To create your own please press the '+' button to create a copy from the current selected profile.", MessageType.Info); GUI.enabled = false; } if (m_profile.m_editSettings) { GUI.enabled = true; } if (m_renderPipeline != GaiaConstants.EnvironmentRenderer.HighDefinition) { if (m_profile.m_enablePostProcessing) { m_editorUtils.Heading("PostProcessingSettings"); if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.Universal) { #if UPPipeline m_profileValues.PostProcessProfileURP = (VolumeProfile)m_editorUtils.ObjectField("PostProcessingProfile", m_profileValues.PostProcessProfileURP, typeof(VolumeProfile), false); #endif } else { #if UNITY_POST_PROCESSING_STACK_V2 m_profileValues.PostProcessProfileBuiltIn = (PostProcessProfile)m_editorUtils.ObjectField("PostProcessingProfile", m_profileValues.PostProcessProfileBuiltIn, typeof(PostProcessProfile), false); m_profileValues.m_directToCamera = m_editorUtils.Toggle("DirectToCamera", m_profileValues.m_directToCamera); #else EditorGUILayout.HelpBox("Post Processing is not installed. Install it from the package manager to use the post processing setup features.", MessageType.Info); #endif } GUILayout.Space(20f); } if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky) { //m_profileValues.m_sunRotation = m_editorUtils.Slider("SunRotation", m_profileValues.m_sunRotation, 0f, 90f); } if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky) { m_editorUtils.Heading("SunSettings"); m_profileValues.m_sunRotation = m_editorUtils.Slider("SunRotation", m_profileValues.m_sunRotation, 0f, 360f); m_profileValues.m_sunPitch = m_editorUtils.Slider("SunPitch", m_profileValues.m_sunPitch, 0f, 360f); if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.BuiltIn) { m_profileValues.m_sunColor = m_editorUtils.ColorField("SunColor", m_profileValues.m_sunColor); m_profileValues.m_sunIntensity = m_editorUtils.FloatField("SunIntensity", m_profileValues.m_sunIntensity); } else { m_profileValues.m_lWSunColor = m_editorUtils.ColorField("SunColor", m_profileValues.m_lWSunColor); m_profileValues.m_lWSunIntensity = m_editorUtils.FloatField("SunIntensity", m_profileValues.m_lWSunIntensity); } GUILayout.Space(20f); } m_editorUtils.Heading("ShadowSettings"); m_profileValues.m_shadowCastingMode = (LightShadows)EditorGUILayout.EnumPopup("Sun Shadow Casting Mode", m_profileValues.m_shadowCastingMode); if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky) { m_profileValues.m_shadowStrength = m_editorUtils.Slider("SunShadowStrength", m_profileValues.m_shadowStrength, 0f, 1f, helpEnabled); } m_profileValues.m_shadowDistance = m_editorUtils.Slider("ShadowDistance", m_profileValues.m_shadowDistance, 0f, 10000f, helpEnabled); m_profileValues.m_sunShadowResolution = (LightShadowResolution)EditorGUILayout.EnumPopup("Sun Shadow Resolution", m_profileValues.m_sunShadowResolution); GUILayout.Space(20f); m_editorUtils.Heading("SkyboxSettings"); #if !GAIA_PRO_PRESENT if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky && m_profileValues.m_userCustomProfile) { GUI.enabled = true; } #endif m_profileValues.m_profileType = (GaiaConstants.GaiaLightingProfileType)m_editorUtils.EnumPopup("SkyboxType", m_profileValues.m_profileType, helpEnabled); #if !GAIA_PRO_PRESENT if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky) { GUI.enabled = true; EditorGUILayout.HelpBox("The 'Procedural Worlds Sky' profile sky type is available in Gaia Pro only, please choose a different profile type.", MessageType.Info); GUI.enabled = false; } #endif if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.Procedural) { m_profileValues.m_sunSize = m_editorUtils.Slider("SunSize", m_profileValues.m_sunSize, 0f, 1f); m_profileValues.m_sunConvergence = m_editorUtils.Slider("SunConvergence", m_profileValues.m_sunConvergence, 0f, 10f); m_profileValues.m_atmosphereThickness = m_editorUtils.Slider("AtmosphereThickness", m_profileValues.m_atmosphereThickness, 0f, 5f); m_profileValues.m_skyboxExposure = m_editorUtils.Slider("SkyboxExposure", m_profileValues.m_skyboxExposure, 0f, 8f); m_profileValues.m_skyboxTint = m_editorUtils.ColorField("SkyboxTint", m_profileValues.m_skyboxTint); m_profileValues.m_groundColor = m_editorUtils.ColorField("GroundColor", m_profileValues.m_groundColor); } else if (m_profileValues.m_profileType == GaiaConstants.GaiaLightingProfileType.HDRI) { m_profileValues.m_skyboxHDRI = (Cubemap)m_editorUtils.ObjectField("HDRISkybox", m_profileValues.m_skyboxHDRI, typeof(Cubemap), false, GUILayout.Height(16f)); m_profileValues.m_skyboxTint = m_editorUtils.ColorField("SkyboxTint", m_profileValues.m_skyboxTint); m_profileValues.m_skyboxExposure = m_editorUtils.Slider("SkyboxExposure", m_profileValues.m_skyboxExposure, 0f, 8f); } GUILayout.Space(20f); //m_profileValues.m_ambientMode = (AmbientMode)EditorGUILayout.EnumPopup("Ambient Mode", m_profileValues.m_ambientMode); if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky) { m_editorUtils.Heading("AmbientSettings"); m_profileValues.m_ambientMode = (AmbientMode)m_editorUtils.EnumPopup("AmbientMode", m_profileValues.m_ambientMode, helpEnabled); if (RenderSettings.ambientMode == AmbientMode.Skybox) { m_profileValues.m_ambientIntensity = m_editorUtils.Slider("AmbientIntensity", m_profileValues.m_ambientIntensity, 0f, 10f); } else if (RenderSettings.ambientMode == AmbientMode.Flat) { m_profileValues.m_skyAmbient = m_editorUtils.ColorField("SkyAmbient", m_profileValues.m_skyAmbient); } else if (RenderSettings.ambientMode == AmbientMode.Trilight) { m_profileValues.m_skyAmbient = m_editorUtils.ColorField("SkyAmbient", m_profileValues.m_skyAmbient); m_profileValues.m_equatorAmbient = m_editorUtils.ColorField("EquatorAmbient", m_profileValues.m_equatorAmbient); m_profileValues.m_groundAmbient = m_editorUtils.ColorField("GroundAmbient", m_profileValues.m_groundAmbient); } GUILayout.Space(20f); } if (m_profile.m_enableFog) { m_editorUtils.Heading("FogSettings"); m_profileValues.m_fogMode = (FogMode)EditorGUILayout.EnumPopup("Fog Mode", m_profileValues.m_fogMode); if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky) { if (m_profileValues.m_fogMode == FogMode.Linear) { m_profileValues.m_fogColor = m_editorUtils.ColorField("FogColor", m_profileValues.m_fogColor); m_profileValues.m_fogStartDistance = m_editorUtils.FloatField("FogStartDistance", m_profileValues.m_fogStartDistance); m_profileValues.m_fogEndDistance = m_editorUtils.FloatField("FogEndDistance", m_profileValues.m_fogEndDistance); } else { m_profileValues.m_fogColor = m_editorUtils.ColorField("FogColor", m_profileValues.m_fogColor); m_profileValues.m_fogDensity = m_editorUtils.Slider("FogDensity", m_profileValues.m_fogDensity, 0f, 1f); } } } } else { m_profileValues.m_profileType = (GaiaConstants.GaiaLightingProfileType)m_editorUtils.EnumPopup("SkyboxType", m_profileValues.m_profileType, helpEnabled); if (m_profile.m_enablePostProcessing) { m_editorUtils.Heading("PostProcessingSettings"); EditorGUI.indentLevel++; #if HDPipeline m_profileValues.PostProcessProfileHDRP = (VolumeProfile)m_editorUtils.ObjectField("PostProcessingProfile", m_profileValues.PostProcessProfileHDRP, typeof(VolumeProfile), false); #endif EditorGUI.indentLevel--; GUILayout.Space(20f); } #if GAIA_PRO_PRESENT if (m_profile.m_enableAmbientAudio) { m_editorUtils.Heading("AmbientAudioSettings"); EditorGUI.indentLevel++; m_profileValues.m_ambientVolume = m_editorUtils.Slider("AmbientAudioVolume", m_profileValues.m_ambientVolume, 0f, 1f, helpEnabled); m_profileValues.m_ambientAudio = (AudioClip)m_editorUtils.ObjectField("AmbientAudioClip", m_profileValues.m_ambientAudio, typeof(AudioClip), false, helpEnabled); EditorGUI.indentLevel--; GUILayout.Space(20f); } #endif if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky) { m_editorUtils.Heading("SunSettings"); EditorGUI.indentLevel++; m_profileValues.m_sunRotation = m_editorUtils.Slider("SunRotation", m_profileValues.m_sunRotation, 0f, 360f); m_profileValues.m_sunPitch = m_editorUtils.Slider("SunPitch", m_profileValues.m_sunPitch, 0f, 360f); m_profileValues.m_hDSunColor = m_editorUtils.ColorField("SunColor", m_profileValues.m_hDSunColor); m_profileValues.m_hDSunIntensity = m_editorUtils.FloatField("SunIntensity", m_profileValues.m_hDSunIntensity); EditorGUI.indentLevel--; GUILayout.Space(20f); } m_editorUtils.Heading("ShadowSettings"); EditorGUI.indentLevel++; m_profileValues.m_hDShadowDistance = m_editorUtils.Slider("ShadowDistance", m_profileValues.m_hDShadowDistance, 0f, 10000f); m_profileValues.m_hDShadowResolution = (GaiaConstants.HDShadowResolution)m_editorUtils.EnumPopup("HDShadowResolution", m_profileValues.m_hDShadowResolution); m_profileValues.m_hDContactShadows = m_editorUtils.Toggle("ContactShadows", m_profileValues.m_hDContactShadows); if (m_profileValues.m_hDContactShadows) { EditorGUI.indentLevel++; m_profileValues.m_hDContactShadowsDistance = m_editorUtils.Slider("ContactShadowsDistance", m_profileValues.m_hDContactShadowsDistance, 1f, 2000f); m_profileValues.m_hDContactShadowQuality = (GaiaConstants.ContactShadowsQuality)m_editorUtils.EnumPopup("ContactShadowsQuality", m_profileValues.m_hDContactShadowQuality); if (m_profileValues.m_hDContactShadowQuality == GaiaConstants.ContactShadowsQuality.Custom) { EditorGUI.indentLevel++; m_profileValues.m_hDContactShadowCustomQuality = m_editorUtils.IntSlider("ContactShadowsSampleCount", m_profileValues.m_hDContactShadowCustomQuality, 4, 64); EditorGUI.indentLevel--; } m_profileValues.m_hDContactShadowOpacity = m_editorUtils.Slider("ContactShadowOpacity", m_profileValues.m_hDContactShadowOpacity, 0f, 1f); EditorGUI.indentLevel--; } m_profileValues.m_hDMicroShadows = m_editorUtils.Toggle("MicroShadows", m_profileValues.m_hDMicroShadows); if (m_profileValues.m_hDMicroShadows) { EditorGUI.indentLevel++; m_profileValues.m_hDMicroShadowOpacity = m_editorUtils.Slider("MicroShadowOpacity", m_profileValues.m_hDMicroShadowOpacity, 0f, 1f); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; GUILayout.Space(20f); if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky) { m_editorUtils.Heading("SkyboxSettings"); EditorGUI.indentLevel++; m_profileValues.m_hDSkyType = (GaiaConstants.HDSkyType)EditorGUILayout.EnumPopup("Sky Type", m_profileValues.m_hDSkyType); if (m_profileValues.m_hDSkyType == GaiaConstants.HDSkyType.HDRI) { m_profileValues.m_hDHDRISkybox = (Cubemap)m_editorUtils.ObjectField("HDRISkybox", m_profileValues.m_hDHDRISkybox, typeof(Cubemap), false, GUILayout.Height(16f)); m_profileValues.m_hDHDRIExposure = m_editorUtils.FloatField("SkyboxExposure", m_profileValues.m_hDHDRIExposure); m_profileValues.m_hDHDRIMultiplier = m_editorUtils.FloatField("SkyboxMultiplier", m_profileValues.m_hDHDRIMultiplier); } else if (m_profileValues.m_hDSkyType == GaiaConstants.HDSkyType.Procedural) { EditorGUILayout.Space(); m_editorUtils.LabelField("GeometrySettings", EditorStyles.boldLabel); m_profileValues.m_hDPBSPlanetaryRadius = m_editorUtils.FloatField("PBSPlanetaryRadius", m_profileValues.m_hDPBSPlanetaryRadius, helpEnabled); m_profileValues.m_hDPBSPlantetCenterPosition = m_editorUtils.Vector3Field("PBSPlanetCenterPosition", m_profileValues.m_hDPBSPlantetCenterPosition, helpEnabled); EditorGUILayout.Space(); m_editorUtils.LabelField("AirSettings", EditorStyles.boldLabel); m_profileValues.m_hDPBSAirOpacity = m_editorUtils.ColorField("PBSAirOpacity", m_profileValues.m_hDPBSAirOpacity, helpEnabled); m_profileValues.m_hDPBSAirAlbedo = m_editorUtils.ColorField("PBSAirAlbedo", m_profileValues.m_hDPBSAirAlbedo, helpEnabled); m_profileValues.m_hDPBSAirMaximumAltitude = m_editorUtils.FloatField("PBSAirMaximumAltitude", m_profileValues.m_hDPBSAirMaximumAltitude, helpEnabled); EditorGUILayout.Space(); m_editorUtils.LabelField("AerosolsSettings", EditorStyles.boldLabel); m_profileValues.m_hDPBSAerosolDensity = m_editorUtils.Slider("PBSAerosolOpacity", m_profileValues.m_hDPBSAerosolDensity, -1f, 1f, helpEnabled); m_profileValues.m_hDPBSAerosolAlbedo = m_editorUtils.ColorField("PBSAerosolAlbedo", m_profileValues.m_hDPBSAerosolAlbedo, helpEnabled); m_profileValues.m_hDPBSAerosolMaximumAltitude = m_editorUtils.FloatField("PBSAerosolMaximumAltitude", m_profileValues.m_hDPBSAerosolMaximumAltitude, helpEnabled); m_profileValues.m_hDPBSAerosolAnisotropy = m_editorUtils.Slider("PBSAerosolAnisotropy", m_profileValues.m_hDPBSAerosolAnisotropy, -1f, 1f, helpEnabled); EditorGUILayout.Space(); m_editorUtils.LabelField("PlanetSettings", EditorStyles.boldLabel); m_profileValues.m_hDPBSPlanetRotation = m_editorUtils.Vector3Field("PBSPlanetRotation", m_profileValues.m_hDPBSPlanetRotation, helpEnabled); m_profileValues.m_hDPBSGroundTint = m_editorUtils.ColorField("PBSGroundColor", m_profileValues.m_hDPBSGroundTint); m_profileValues.m_hDPBSGroundAlbedoTexture = (Cubemap)m_editorUtils.ObjectField("PBSGroundAlbedoTexture", m_profileValues.m_hDPBSGroundAlbedoTexture, typeof(Cubemap), false, helpEnabled, GUILayout.Height(16f)); m_profileValues.m_hDPBSGroundEmissionTexture = (Cubemap)m_editorUtils.ObjectField("PBSGroundEmissionTexture", m_profileValues.m_hDPBSGroundEmissionTexture, typeof(Cubemap), false, helpEnabled, GUILayout.Height(16f)); EditorGUILayout.Space(); m_editorUtils.LabelField("SpaceSettings", EditorStyles.boldLabel); m_profileValues.m_hDPBSSpaceRotation = m_editorUtils.Vector3Field("PBSSpaceRotation", m_profileValues.m_hDPBSSpaceRotation, helpEnabled); m_profileValues.m_hDPBSSpaceEmissionTexture = (Cubemap)m_editorUtils.ObjectField("PBSSpaceEmissionTexture", m_profileValues.m_hDPBSSpaceEmissionTexture, typeof(Cubemap), false, helpEnabled, GUILayout.Height(16f)); EditorGUILayout.Space(); m_editorUtils.LabelField("ArtisticOverrides", EditorStyles.boldLabel); m_profileValues.m_hDPBSColorSaturation = m_editorUtils.Slider("PBSColorSaturation", m_profileValues.m_hDPBSColorSaturation, 0f, 1f, helpEnabled); m_profileValues.m_hDPBSAlphaSaturation = m_editorUtils.Slider("PBSAlphaSaturation", m_profileValues.m_hDPBSAlphaSaturation, 0f, 1f, helpEnabled); m_profileValues.m_hDPBSAlphaMultiplier = m_editorUtils.Slider("PBSAlphaMultiplier", m_profileValues.m_hDPBSAlphaMultiplier, 0f, 1f, helpEnabled); m_profileValues.m_hDPBSHorizonTint = m_editorUtils.ColorField("PBSHorizonTint", m_profileValues.m_hDPBSHorizonTint, helpEnabled); m_profileValues.m_hDPBSHorizonZenithShift = m_editorUtils.Slider("PBSHorizonZenithShift", m_profileValues.m_hDPBSHorizonZenithShift, -1f, 1f, helpEnabled); m_profileValues.m_hDPBSZenithTint = m_editorUtils.ColorField("PBSZenithTint", m_profileValues.m_hDPBSZenithTint, helpEnabled); EditorGUILayout.Space(); m_editorUtils.LabelField("MiscellaneousSettings", EditorStyles.boldLabel); m_profileValues.m_hDPBSNumberOfBounces = m_editorUtils.IntSlider("PBSNumberOfBounces", m_profileValues.m_hDPBSNumberOfBounces, 1, 10, helpEnabled); m_profileValues.m_hDPBSIntensityMode = (GaiaConstants.HDIntensityMode)m_editorUtils.EnumPopup("PBSIntensityMode", m_profileValues.m_hDPBSIntensityMode, helpEnabled); if (m_profileValues.m_hDPBSIntensityMode == GaiaConstants.HDIntensityMode.Exposure) { m_profileValues.m_hDPBSExposure = m_editorUtils.FloatField("PBSExposure", m_profileValues.m_hDPBSExposure, helpEnabled); } else { m_profileValues.m_hDPBSMultiplier = m_editorUtils.FloatField("PBSMultiplier", m_profileValues.m_hDPBSMultiplier, helpEnabled); } m_profileValues.m_hDPBSIncludeSunInBaking = m_editorUtils.Toggle("PBSIncludeSunInBaking", m_profileValues.m_hDPBSIncludeSunInBaking, helpEnabled); } else { m_profileValues.m_hDGradientTopColor = m_editorUtils.ColorField("TopColor", m_profileValues.m_hDGradientTopColor); m_profileValues.m_hDGradientMiddleColor = m_editorUtils.ColorField("MiddleColor", m_profileValues.m_hDGradientMiddleColor); m_profileValues.m_hDGradientBottomColor = m_editorUtils.ColorField("BottomColor", m_profileValues.m_hDGradientBottomColor); m_profileValues.m_hDGradientDiffusion = m_editorUtils.FloatField("Diffusion", m_profileValues.m_hDGradientDiffusion); m_profileValues.m_hDGradientExposure = m_editorUtils.FloatField("Exposure", m_profileValues.m_hDGradientExposure); m_profileValues.m_hDGradientMultiplier = m_editorUtils.FloatField("Multiplier", m_profileValues.m_hDGradientMultiplier); } EditorGUI.indentLevel--; GUILayout.Space(20f); } m_editorUtils.Heading("AmbientSettings"); EditorGUI.indentLevel++; m_profileValues.m_hDAmbientMode = (GaiaConstants.HDAmbientMode)EditorGUILayout.EnumPopup("Ambient Mode", m_profileValues.m_hDAmbientMode); #if !UNITY_2019_3_OR_NEWER m_profileValues.m_hDAmbientDiffuseIntensity = m_editorUtils.FloatField("DiffuseIntensity", m_profileValues.m_hDAmbientDiffuseIntensity); m_profileValues.m_hDAmbientSpecularIntensity = m_editorUtils.FloatField("SpecularIntensity", m_profileValues.m_hDAmbientSpecularIntensity); #else if (m_profileValues.m_hDAmbientMode == GaiaConstants.HDAmbientMode.Static) { EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("HDRP2019_3AmbientMode"), MessageType.Info); } #endif EditorGUI.indentLevel--; GUILayout.Space(20f); if (m_profileValues.m_profileType != GaiaConstants.GaiaLightingProfileType.ProceduralWorldsSky) { m_editorUtils.Heading("FogSettings"); EditorGUI.indentLevel++; m_profileValues.m_hDFogType2019_3 = (GaiaConstants.HDFogType2019_3)EditorGUILayout.EnumPopup("Fog Mode", m_profileValues.m_hDFogType2019_3); if (m_profileValues.m_hDFogType2019_3 == GaiaConstants.HDFogType2019_3.None) { EditorGUILayout.HelpBox("No fog mode selected. If you want to use fog please select a different mode", MessageType.Info); } else { m_profileValues.m_hDVolumetricFogScatterColor = m_editorUtils.ColorField("ScatterColor", m_profileValues.m_hDVolumetricFogScatterColor); m_profileValues.m_hDVolumetricFogDistance = m_editorUtils.FloatField("FogDistance", m_profileValues.m_hDVolumetricFogDistance); if (m_profileValues.m_hDVolumetricFogDistance < 0f) { m_profileValues.m_hDVolumetricFogDistance = 0f; } m_profileValues.m_hDVolumetricFogBaseHeight = m_editorUtils.FloatField("FogBaseHeight", m_profileValues.m_hDVolumetricFogBaseHeight); if (m_profileValues.m_hDVolumetricFogBaseHeight < 0f) { m_profileValues.m_hDVolumetricFogBaseHeight = 0f; } m_profileValues.m_hDVolumetricFogMeanHeight = m_editorUtils.FloatField("FogMeanHeight", m_profileValues.m_hDVolumetricFogMeanHeight); if (m_profileValues.m_hDVolumetricFogMeanHeight < 0f) { m_profileValues.m_hDVolumetricFogMeanHeight = 0f; } m_profileValues.m_hDVolumetricFogAnisotropy = m_editorUtils.Slider("FogAnisotropy", m_profileValues.m_hDVolumetricFogAnisotropy, 0f, 1f); m_profileValues.m_hDVolumetricFogProbeDimmer = m_editorUtils.Slider("FogProbeDimmer", m_profileValues.m_hDVolumetricFogProbeDimmer, 0f, 1f); m_profileValues.m_hDVolumetricFogMaxDistance = m_editorUtils.FloatField("MaxFogDistance", m_profileValues.m_hDVolumetricFogMaxDistance); if (m_profileValues.m_hDVolumetricFogMaxDistance < 0f) { m_profileValues.m_hDVolumetricFogMaxDistance = 0f; } m_profileValues.m_hDVolumetricFogDepthExtent = m_editorUtils.FloatField("FogDepthExtent", m_profileValues.m_hDVolumetricFogDepthExtent); if (m_profileValues.m_hDVolumetricFogDepthExtent < 0f) { m_profileValues.m_hDVolumetricFogDepthExtent = 0f; } m_profileValues.m_hDVolumetricFogSliceDistribution = m_editorUtils.Slider("FogSliceDistribution", m_profileValues.m_hDVolumetricFogSliceDistribution, 0f, 1f); } EditorGUI.indentLevel--; } } GUI.enabled = true; } #if !GAIA_PRO_PRESENT GUI.enabled = currentGUIState; #endif }
/// <summary> /// Draws the data fields for each operation /// </summary> /// <param name="op"></param> public static void DrawOperationFields(GaiaOperation op, EditorUtils editorUtils, GaiaSessionManager sessionManager, bool helpEnabled, int currentIndex) { //shared default fields first //op.m_isActive = m_editorUtils.Toggle("Active", op.m_isActive, helpEnabled); bool currentGUIState = GUI.enabled; GUI.enabled = op.m_isActive; op.m_description = editorUtils.TextField("Description", op.m_description, helpEnabled); editorUtils.LabelField("DateTime", new GUIContent(op.m_operationDateTime), helpEnabled); EditorGUI.indentLevel++; op.m_terrainsFoldedOut = editorUtils.Foldout(op.m_terrainsFoldedOut, "AffectedTerrains", helpEnabled); if (op.m_terrainsFoldedOut) { foreach (string name in op.m_affectedTerrainNames) { EditorGUILayout.LabelField(name); } } EditorGUI.indentLevel--; //type specific fields, switch by op type to draw additional fields suitable for the op type switch (op.m_operationType) { case GaiaOperation.OperationType.CreateWorld: editorUtils.LabelField("xTiles", new GUIContent(op.WorldCreationSettings.m_xTiles.ToString()), helpEnabled); editorUtils.LabelField("zTiles", new GUIContent(op.WorldCreationSettings.m_zTiles.ToString()), helpEnabled); editorUtils.LabelField("TileSize", new GUIContent(op.WorldCreationSettings.m_tileSize.ToString()), helpEnabled); break; case GaiaOperation.OperationType.Spawn: editorUtils.LabelField("NumberOfSpawners", new GUIContent(op.SpawnOperationSettings.m_spawnerSettingsList.Count.ToString()), helpEnabled); float size = (float)Mathd.Max(op.SpawnOperationSettings.m_spawnArea.size.x, op.SpawnOperationSettings.m_spawnArea.size.z); editorUtils.LabelField("SpawnSize", new GUIContent(size.ToString()), helpEnabled); break; } GUI.enabled = currentGUIState; //Button controls EditorGUILayout.BeginHorizontal(); GUILayout.Space(20); if (editorUtils.Button("Delete")) { if (EditorUtility.DisplayDialog(editorUtils.GetTextValue("PopupDeleteTitle"), editorUtils.GetTextValue("PopupDeleteText"), editorUtils.GetTextValue("OK"), editorUtils.GetTextValue("Cancel"))) { try { if (!String.IsNullOrEmpty(op.scriptableObjectAssetGUID)) { AssetDatabase.DeleteAsset(AssetDatabase.GUIDToAssetPath(op.scriptableObjectAssetGUID)); } } catch (Exception ex) { Debug.LogError("Error while deleting one of the operation data files: " + ex.Message + " Stack Trace:" + ex.StackTrace); } sessionManager.RemoveOperation(currentIndex); EditorGUIUtility.ExitGUI(); } } GUI.enabled = op.m_isActive; if (editorUtils.Button("Play")) { if (EditorUtility.DisplayDialog(editorUtils.GetTextValue("PopupPlayTitle"), editorUtils.GetTextValue("PopupPlayText"), editorUtils.GetTextValue("OK"), editorUtils.GetTextValue("Cancel"))) { GaiaSessionManager.ExecuteOperation(op); //Destroy all temporary tools used while executing //not if it is a spawn operation since that is asynchronous if (op.m_operationType != GaiaOperation.OperationType.Spawn) { GaiaSessionManager.DestroyTempSessionTools(); } } } GUI.enabled = currentGUIState; //EditorGUILayout.EndHorizontal(); //EditorGUILayout.BeginHorizontal(); //GUILayout.Space(20); if (editorUtils.Button("ViewData")) { switch (op.m_operationType) { case GaiaOperation.OperationType.CreateWorld: Selection.activeObject = op.WorldCreationSettings; break; case GaiaOperation.OperationType.Stamp: Selection.activeObject = op.StamperSettings; break; case GaiaOperation.OperationType.Spawn: Selection.activeObject = op.SpawnOperationSettings; break; case GaiaOperation.OperationType.FlattenTerrain: Selection.activeObject = op.FlattenOperationSettings; break; case GaiaOperation.OperationType.StampUndo: Selection.activeObject = op.UndoRedoOperationSettings; break; case GaiaOperation.OperationType.StampRedo: Selection.activeObject = op.UndoRedoOperationSettings; break; case GaiaOperation.OperationType.ClearSpawns: Selection.activeObject = op.ClearOperationSettings; break; case GaiaOperation.OperationType.RemoveNonBiomeResources: Selection.activeObject = op.RemoveNonBiomeResourcesSettings; break; case GaiaOperation.OperationType.MaskMapExport: Selection.activeObject = op.ExportMaskMapOperationSettings; break; } EditorGUIUtility.PingObject(Selection.activeObject); } switch (op.m_operationType) { case GaiaOperation.OperationType.Stamp: if (editorUtils.Button("PreviewInStamper")) { Stamper stamper = GaiaSessionManager.GetOrCreateSessionStamper(); stamper.LoadSettings(op.StamperSettings); #if GAIA_PRO_PRESENT if (GaiaUtils.HasDynamicLoadedTerrains()) { //We got placeholders, activate terrain loading stamper.m_loadTerrainMode = LoadMode.EditorSelected; } #endif Selection.activeObject = stamper.gameObject; } break; case GaiaOperation.OperationType.Spawn: if (editorUtils.Button("PreviewInSpawner")) { BiomeController bmc = null; List <Spawner> spawnerList = null; Selection.activeObject = GaiaSessionManager.GetOrCreateSessionSpawners(op.SpawnOperationSettings, ref bmc, ref spawnerList); } break; case GaiaOperation.OperationType.MaskMapExport: #if GAIA_PRO_PRESENT if (editorUtils.Button("PreviewInExport")) { MaskMapExport mme = null; Selection.activeObject = GaiaSessionManager.GetOrCreateMaskMapExporter(op.ExportMaskMapOperationSettings.m_maskMapExportSettings, ref mme); } #endif break; } EditorGUILayout.EndHorizontal(); }
private void DrawSummary(bool helpEnabled) { m_manager.m_session = (GaiaSession)m_editorUtils.ObjectField("SessionData", m_manager.m_session, typeof(GaiaSession), helpEnabled); m_editorUtils.InlineHelp("SessionData", helpEnabled); if (m_manager.m_session == null) { if (m_editorUtils.Button("CreateSessionButton")) { m_manager.CreateSession(); } } if (m_manager.m_session == null) { return; } EditorGUI.BeginChangeCheck(); m_manager.m_session.m_name = m_editorUtils.DelayedTextField("Name", m_manager.m_session.m_name, helpEnabled); if (EditorGUI.EndChangeCheck()) { //Get the old path string oldSessionDataPath = GaiaDirectories.GetSessionSubFolderPath(m_manager.m_session); //Rename the session asset AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(m_manager.m_session), m_manager.m_session.m_name + ".asset"); //rename the session data path as well string newSessionDataPath = GaiaDirectories.GetSessionSubFolderPath(m_manager.m_session, false); AssetDatabase.MoveAsset(oldSessionDataPath, newSessionDataPath); //if we have terrain scenes stored in the Terrain Loader, we need to update the paths in there as well foreach (TerrainScene terrainScene in TerrainLoaderManager.TerrainScenes) { terrainScene.m_scenePath = terrainScene.m_scenePath.Replace(oldSessionDataPath, newSessionDataPath); terrainScene.m_impostorScenePath = terrainScene.m_impostorScenePath.Replace(oldSessionDataPath, newSessionDataPath); terrainScene.m_backupScenePath = terrainScene.m_backupScenePath.Replace(oldSessionDataPath, newSessionDataPath); terrainScene.m_colliderScenePath = terrainScene.m_colliderScenePath.Replace(oldSessionDataPath, newSessionDataPath); } TerrainLoaderManager.Instance.SaveStorageData(); AssetDatabase.DeleteAsset(oldSessionDataPath); AssetDatabase.SaveAssets(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(m_editorUtils.GetContent("Description"), GUILayout.MaxWidth(EditorGUIUtility.labelWidth)); m_manager.m_session.m_description = EditorGUILayout.TextArea(m_manager.m_session.m_description, GUILayout.MinHeight(100)); EditorGUILayout.EndHorizontal(); m_editorUtils.InlineHelp("Description", helpEnabled); m_manager.m_session.m_previewImage = (Texture2D)m_editorUtils.ObjectField("PreviewImage", m_manager.m_session.m_previewImage, typeof(Texture2D), helpEnabled); GUILayout.BeginHorizontal(); Rect rect = EditorGUILayout.GetControlRect(); GUILayout.Space(rect.width - 20); if (GUILayout.Button("Generate Image")) { string textureFileName = GaiaDirectories.GetSessionSubFolderPath(m_manager.m_session) + Path.DirectorySeparatorChar + m_manager.m_session + "_Preview"; var originalLODBias = QualitySettings.lodBias; QualitySettings.lodBias = 100; OrthographicBake.BakeTerrain(Terrain.activeTerrain, 2048, 2048, Camera.main.cullingMask, textureFileName); OrthographicBake.RemoveOrthoCam(); QualitySettings.lodBias = originalLODBias; textureFileName += ".png"; AssetDatabase.ImportAsset(textureFileName); var importer = AssetImporter.GetAtPath(textureFileName) as TextureImporter; if (importer != null) { importer.sRGBTexture = false; importer.alphaIsTransparency = false; importer.alphaSource = TextureImporterAlphaSource.None; importer.mipmapEnabled = false; } AssetDatabase.ImportAsset(textureFileName); m_manager.m_session.m_previewImage = (Texture2D)AssetDatabase.LoadAssetAtPath(textureFileName, typeof(Texture2D)); } GUILayout.EndHorizontal(); m_editorUtils.InlineHelp("PreviewImage", helpEnabled); m_editorUtils.LabelField("Created", new GUIContent(m_manager.m_session.m_dateCreated), helpEnabled); m_manager.m_session.m_isLocked = m_editorUtils.Toggle("Locked", m_manager.m_session.m_isLocked, helpEnabled); float maxSeaLevel = 2000f; if (Terrain.activeTerrain != null) { maxSeaLevel = Terrain.activeTerrain.terrainData.size.y + Terrain.activeTerrain.transform.position.y; } else { maxSeaLevel = m_manager.GetSeaLevel(false) + 500f; } float oldSeaLevel = m_manager.GetSeaLevel(false); float newSeaLEvel = oldSeaLevel; newSeaLEvel = m_editorUtils.Slider("SeaLevel", newSeaLEvel, 0, maxSeaLevel, helpEnabled); if (newSeaLEvel != oldSeaLevel) { //Do we have a water instance? If yes, update it & it will update the sea level in the session as well if (PWS_WaterSystem.Instance != null) { PWS_WaterSystem.Instance.SeaLevel = newSeaLEvel; } else { //no water instance yet, just update the sea level in the session m_manager.SetSeaLevel(newSeaLEvel, false); SceneView.RepaintAll(); } } m_manager.m_session.m_spawnDensity = m_editorUtils.FloatField("SpawnDensity", Mathf.Max(0.01f, m_manager.m_session.m_spawnDensity), helpEnabled); GUILayout.BeginHorizontal(); if (m_editorUtils.Button("DeleteAllOperations")) { if (EditorUtility.DisplayDialog(m_editorUtils.GetTextValue("PopupDeleteAllTitle"), m_editorUtils.GetTextValue("PopupDeleteAllMessage"), m_editorUtils.GetTextValue("Continue"), m_editorUtils.GetTextValue("Cancel"))) { foreach (GaiaOperation op in m_manager.m_session.m_operations) { try { if (!String.IsNullOrEmpty(op.scriptableObjectAssetGUID)) { AssetDatabase.DeleteAsset(AssetDatabase.GUIDToAssetPath(op.scriptableObjectAssetGUID)); } } catch (Exception ex) { Debug.LogError("Error while deleting one of the operation data files: " + ex.Message + " Stack Trace:" + ex.StackTrace); } } m_manager.m_session.m_operations.Clear(); } } if (m_editorUtils.Button("PlaySession")) { GaiaLighting.SetDefaultAmbientLight(GaiaUtils.GetGaiaSettings().m_gaiaLightingProfile); GaiaSessionManager.PlaySession(); } GUILayout.EndHorizontal(); }
private void DrawGeneralSettings(bool helpEnabled) { m_terrainLoaderManager.TerrainSceneStorage = (TerrainSceneStorage)m_editorUtils.ObjectField("TerrainSceneStorage", m_terrainLoaderManager.TerrainSceneStorage, typeof(TerrainSceneStorage), false, helpEnabled); bool oldLoadingEnabled = m_terrainLoaderManager.TerrainSceneStorage.m_terrainLoadingEnabled; m_terrainLoaderManager.TerrainSceneStorage.m_terrainLoadingEnabled = m_editorUtils.Toggle("TerrainLoadingEnabled", m_terrainLoaderManager.TerrainSceneStorage.m_terrainLoadingEnabled, helpEnabled); if (!oldLoadingEnabled && m_terrainLoaderManager.TerrainSceneStorage.m_terrainLoadingEnabled) { //User re-enabled the loaders m_terrainLoaderManager.UpdateTerrainLoadState(); } if (oldLoadingEnabled != m_terrainLoaderManager.TerrainSceneStorage.m_terrainLoadingEnabled) { //Value was changed, dirty the object to make sure the value is being saved EditorUtility.SetDirty(m_terrainLoaderManager.TerrainSceneStorage); } bool originalGUIState = GUI.enabled; m_terrainLoaderManager.m_terrainLoadingTresholdMS = m_editorUtils.IntField("LoadingTimeTreshold", m_terrainLoaderManager.m_terrainLoadingTresholdMS, helpEnabled); m_terrainLoaderManager.m_trackLoadingProgressTimeOut = m_editorUtils.LongField("LoadingProgressTimeout", m_terrainLoaderManager.m_trackLoadingProgressTimeOut, helpEnabled); GUILayout.Space(10); m_editorUtils.Heading("SceneViewLoading"); m_terrainLoaderManager.CenterSceneViewLoadingOn = (CenterSceneViewLoadingOn)m_editorUtils.EnumPopup("CenterSceneViewLoadingOn", m_terrainLoaderManager.CenterSceneViewLoadingOn, helpEnabled); double loadingRange = m_editorUtils.DoubleField("SceneViewLoadingRange", m_terrainLoaderManager.GetLoadingRange(), helpEnabled); double impostorLoadingRange = m_terrainLoaderManager.GetImpostorLoadingRange(); if (GaiaUtils.HasImpostorTerrains()) { impostorLoadingRange = m_editorUtils.DoubleField("SceneViewImpostorLoadingRange", m_terrainLoaderManager.GetImpostorLoadingRange(), helpEnabled); } else { EditorGUILayout.BeginHorizontal(); m_editorUtils.Label("SceneViewImpostorLoadingRange"); //offer button to create impostors setup if (m_editorUtils.Button("OpenTerrainMeshExporterForImpostors", GUILayout.Width(EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 38))) { ExportTerrain exportTerrainWindow = EditorWindow.GetWindow <ExportTerrain>(); exportTerrainWindow.FindAndSetPreset("Create Impostors"); exportTerrainWindow.m_settings.m_customSettingsFoldedOut = false; } EditorGUILayout.EndHorizontal(); } if (loadingRange != m_terrainLoaderManager.GetLoadingRange() || impostorLoadingRange != m_terrainLoaderManager.GetImpostorLoadingRange()) { m_terrainLoaderManager.SetLoadingRange(loadingRange, impostorLoadingRange); } GUILayout.Space(10); m_editorUtils.Heading("CachingSettings"); m_editorUtils.InlineHelp("CachingSettings", helpEnabled); EditorGUI.BeginChangeCheck(); m_terrainLoaderManager.m_cacheInRuntime = m_editorUtils.Toggle("CacheInRuntime", m_terrainLoaderManager.m_cacheInRuntime, helpEnabled); m_terrainLoaderManager.m_cacheInEditor = m_editorUtils.Toggle("CacheInEditor", m_terrainLoaderManager.m_cacheInEditor, helpEnabled); string allocatedMegabytes = (Math.Round(Profiler.GetTotalAllocatedMemoryLong() / Math.Pow(1024, 2))).ToString(); string availableMegabytes = SystemInfo.systemMemorySize.ToString(); allocatedMegabytes = allocatedMegabytes.PadLeft(allocatedMegabytes.Length + (availableMegabytes.Length - allocatedMegabytes.Length) * 3, ' '); GUIStyle style = new GUIStyle(GUI.skin.label); if (m_terrainLoaderManager.m_cacheMemoryThreshold < Profiler.GetTotalAllocatedMemoryLong()) { style = redStyle; } else { style = greenStyle; } m_editorUtils.LabelField("MemoryAvailable", new GUIContent(availableMegabytes), helpEnabled); m_editorUtils.LabelField("MemoryAllocated", new GUIContent(allocatedMegabytes), style, helpEnabled); //GUI.color = originalGUIColor; if (m_terrainLoaderManager.m_cacheInRuntime || m_terrainLoaderManager.m_cacheInEditor) { m_terrainLoaderManager.m_cacheMemoryThresholdPreset = (CacheSizePreset)m_editorUtils.EnumPopup("CacheMemoryThreshold", m_terrainLoaderManager.m_cacheMemoryThresholdPreset, helpEnabled); if (m_terrainLoaderManager.m_cacheMemoryThresholdPreset == CacheSizePreset.Custom) { EditorGUI.indentLevel++; m_terrainLoaderManager.m_cacheMemoryThreshold = m_editorUtils.LongField("ThresholdInBytes", m_terrainLoaderManager.m_cacheMemoryThreshold, helpEnabled); EditorGUI.indentLevel--; } int cacheKeepAliveSeconds = (int)m_terrainLoaderManager.m_cacheKeepAliveTime / 1000; cacheKeepAliveSeconds = m_editorUtils.IntField("CacheKeepAliveSeconds", cacheKeepAliveSeconds, helpEnabled); m_terrainLoaderManager.m_cacheKeepAliveTime = cacheKeepAliveSeconds * 1000; } if (EditorGUI.EndChangeCheck()) { if (m_terrainLoaderManager.m_cacheMemoryThresholdPreset != CacheSizePreset.Custom) { m_terrainLoaderManager.m_cacheMemoryThreshold = (long)((int)m_terrainLoaderManager.m_cacheMemoryThresholdPreset * Math.Pow(1024, 3)); } m_terrainLoaderManager.UpdateCaching(); } GUILayout.Space(10); if (!GaiaUtils.HasColliderTerrains()) { GUI.enabled = false; } m_editorUtils.Heading("ColliderOnlyLoadingHeader"); //This flag is special in so far as that when the user switches it, we must first perform a scene unload while the old value is still active //then change the flag in the terrain scene storage and then do a refresh with the new setting applied. bool colliderLoadingEnabled = m_terrainLoaderManager.TerrainSceneStorage.m_colliderOnlyLoading; colliderLoadingEnabled = m_editorUtils.Toggle("ColliderOnlyLoadingEnabled", colliderLoadingEnabled, helpEnabled); if (colliderLoadingEnabled != m_terrainLoaderManager.TerrainSceneStorage.m_colliderOnlyLoading) { //User changed the flag, do an unload with the old setting m_terrainLoaderManager.UnloadAll(true); //then change the actual flag in storage m_terrainLoaderManager.TerrainSceneStorage.m_colliderOnlyLoading = colliderLoadingEnabled; //now do a refresh under the new setting m_terrainLoaderManager.RefreshSceneViewLoadingRange(); //Add the required scenes to build settings if (colliderLoadingEnabled) { GaiaSessionManager.AddOnlyColliderScenesToBuildSettings(TerrainLoaderManager.TerrainScenes); } else { GaiaSessionManager.AddTerrainScenesToBuildSettings(TerrainLoaderManager.TerrainScenes); } } GUI.enabled = originalGUIState; if (colliderLoadingEnabled) { EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("ColliderOnlyLoadingInfo"), MessageType.Info); m_editorUtils.Heading("DeactivateRuntimeHeader"); EditorGUI.indentLevel++; m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimePlayer = m_editorUtils.Toggle("DeactivateRuntimePlayer", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimePlayer, helpEnabled); m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeLighting = m_editorUtils.Toggle("DeactivateRuntimeLighting", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeLighting, helpEnabled); m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeAudio = m_editorUtils.Toggle("DeactivateRuntimeAudio", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeAudio, helpEnabled); m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeWeather = m_editorUtils.Toggle("DeactivateRuntimeWeather", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeWeather, helpEnabled); m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeWater = m_editorUtils.Toggle("DeactivateRuntimeWater", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeWater, helpEnabled); m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeScreenShotter = m_editorUtils.Toggle("DeactivateRuntimeScreenShotter", m_terrainLoaderManager.TerrainSceneStorage.m_deactivateRuntimeScreenShotter, helpEnabled); EditorGUI.indentLevel--; } else { //offer button to create collider setup if (m_editorUtils.Button("OpenTerrainMeshExporterForColliders")) { ExportTerrain exportTerrainWindow = EditorWindow.GetWindow <ExportTerrain>(); exportTerrainWindow.FindAndSetPreset("Collider"); exportTerrainWindow.m_settings.m_customSettingsFoldedOut = false; } } }
private void CameraCullingSettings(bool helpEnabled) { //Monitor for changes EditorGUI.BeginChangeCheck(); GaiaSceneCullingProfile cullingProfile = m_profile.CullingProfile; m_editorUtils.Heading("TerrainCulling"); EditorGUI.indentLevel++; m_profile.m_terrainCullingEnabled = m_editorUtils.Toggle("UseTerrainCulling", m_profile.m_terrainCullingEnabled, helpEnabled); EditorGUI.indentLevel--; EditorGUILayout.Space(); m_editorUtils.Heading("CameraCulling"); EditorGUI.indentLevel++; bool cullingEnabled = m_profile.m_enableLayerCulling; cullingEnabled = m_editorUtils.Toggle("EnableLayerCulling", cullingEnabled, helpEnabled); if (m_profile.m_enableLayerCulling != cullingEnabled) { m_profile.m_enableLayerCulling = cullingEnabled; if (Application.isPlaying) { GaiaScenePlayer.UpdateCullingDistances(); } else { GaiaScenePlayer.ApplySceneSetup(cullingEnabled); } } if (m_profile.m_enableLayerCulling) { m_editorUtils.LabelField("GeneralSettings", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); cullingProfile = (GaiaSceneCullingProfile)m_editorUtils.ObjectField("CullingProfile", cullingProfile, typeof(GaiaSceneCullingProfile), false); if (m_editorUtils.Button("NewProfile", GUILayout.MaxWidth(40f))) { GaiaSceneCullingProfile profile = GaiaSceneCullingProfile.CreateCullingProfile(); cullingProfile = AssetDatabase.LoadAssetAtPath <GaiaSceneCullingProfile>(AssetDatabase.GetAssetPath(profile)); m_profile.CullingProfile = cullingProfile; GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); m_editorUtils.InlineHelp("CullingProfile", helpEnabled); if (cullingProfile != m_profile.CullingProfile) { m_profile.CullingProfile = cullingProfile; if (cullingProfile != null) { GaiaScenePlayer.ApplySceneSetup(cullingProfile.m_applyToEditorCamera); } } #if GAIA_PRO_PRESENT if (ProceduralWorldsGlobalWeather.Instance == null) { m_profile.m_sunLight = (Light)m_editorUtils.ObjectField("SunLight", m_profile.m_sunLight, typeof(Light), true, helpEnabled); if (m_profile.m_sunLight == null) { m_profile.m_sunLight = GaiaUtils.GetMainDirectionalLight(); } } #else m_profile.m_sunLight = (Light)m_editorUtils.ObjectField("SunLight", m_profile.m_sunLight, typeof(Light), true, helpEnabled); if (m_profile.m_sunLight == null) { m_profile.m_sunLight = GaiaUtils.GetMainDirectionalLight(); } #endif if (m_profile.CullingProfile != null) { m_profile.CullingProfile.m_applyToEditorCamera = m_editorUtils.Toggle("ApplyInEditor", m_profile.CullingProfile.m_applyToEditorCamera, helpEnabled); m_profile.CullingProfile.m_realtimeUpdate = m_editorUtils.Toggle("RealtimeUpdate", m_profile.CullingProfile.m_realtimeUpdate, helpEnabled); } EditorGUI.indentLevel--; if (m_profile.CullingProfile != null) { //Objects EditorGUILayout.Space(); m_editorUtils.LabelField("ObjectCullingSettings", EditorStyles.boldLabel); EditorGUI.indentLevel++; m_editorUtils.InlineHelp("ObjectCullingSettings", helpEnabled); for (int i = 0; i < m_profile.CullingProfile.m_layerDistances.Length; i++) { string layerName = LayerMask.LayerToName(i); if (!string.IsNullOrEmpty(layerName)) { m_profile.CullingProfile.m_layerDistances[i] = EditorGUILayout.FloatField(string.Format("[{0}] {1}", i, layerName), m_profile.CullingProfile.m_layerDistances[i]); } } EditorGUI.indentLevel--; if (m_editorUtils.Button("RevertCullingToDefaults")) { m_profile.CullingProfile.UpdateCulling(m_gaiaSettings); EditorUtility.SetDirty(m_profile.CullingProfile); } //Shadows EditorGUILayout.Space(); m_editorUtils.LabelField("ShadowCullingSettings", EditorStyles.boldLabel); EditorGUI.indentLevel++; m_editorUtils.InlineHelp("ShadowCullingSettings", helpEnabled); for (int i = 0; i < m_profile.CullingProfile.m_shadowLayerDistances.Length; i++) { string layerName = LayerMask.LayerToName(i); if (!string.IsNullOrEmpty(layerName)) { m_profile.CullingProfile.m_shadowLayerDistances[i] = EditorGUILayout.FloatField(string.Format("[{0}] {1}", i, layerName), m_profile.CullingProfile.m_shadowLayerDistances[i]); } } EditorGUI.indentLevel--; if (m_editorUtils.Button("RevertShadowToDefaults")) { m_profile.CullingProfile.UpdateShadow(); EditorUtility.SetDirty(m_profile.CullingProfile); } EditorGUI.indentLevel--; } //Check for changes, make undo record, make changes and let editor know we are dirty if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_profile, "Made camera culling changes"); EditorUtility.SetDirty(m_profile); if (m_profile.CullingProfile != null) { EditorUtility.SetDirty(m_profile.CullingProfile); if (Application.isPlaying) { GaiaScenePlayer.UpdateCullingDistances(); } else { GaiaScenePlayer.ApplySceneSetup(m_profile.CullingProfile.m_applyToEditorCamera); } } } } }
private void SimpleLayerCulling(bool helpEnabled) { EditorGUI.BeginChangeCheck(); m_simpleCameraLayerCulling.m_applyToGameCamera = m_editorUtils.Toggle("ApplyToGameCamera", m_simpleCameraLayerCulling.m_applyToGameCamera); m_simpleCameraLayerCulling.m_applyToSceneCamera = m_editorUtils.Toggle("ApplyToSceneCamera", m_simpleCameraLayerCulling.m_applyToSceneCamera); if (m_simpleCameraLayerCulling.m_profile != null) { EditorGUILayout.Space(); m_editorUtils.LabelField("ObjectCullingSettings", EditorStyles.boldLabel); EditorGUI.indentLevel++; m_editorUtils.InlineHelp("ObjectCullingSettings", helpEnabled); for (int i = 0; i < m_simpleCameraLayerCulling.m_profile.m_layerDistances.Length; i++) { string layerName = LayerMask.LayerToName(i); if (!string.IsNullOrEmpty(layerName)) { m_simpleCameraLayerCulling.m_profile.m_layerDistances[i] = EditorGUILayout.FloatField(string.Format("[{0}] {1}", i, layerName), m_simpleCameraLayerCulling.m_profile.m_layerDistances[i]); } } EditorGUI.indentLevel--; if (m_editorUtils.Button("RevertCullingToDefaults")) { GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings(); m_simpleCameraLayerCulling.m_profile.UpdateCulling(gaiaSettings); EditorUtility.SetDirty(m_simpleCameraLayerCulling.m_profile); } EditorGUILayout.Space(); m_editorUtils.LabelField("ShadowCullingSettings", EditorStyles.boldLabel); EditorGUI.indentLevel++; m_editorUtils.InlineHelp("ShadowCullingSettings", helpEnabled); for (int i = 0; i < m_simpleCameraLayerCulling.m_profile.m_shadowLayerDistances.Length; i++) { string layerName = LayerMask.LayerToName(i); if (!string.IsNullOrEmpty(layerName)) { m_simpleCameraLayerCulling.m_profile.m_shadowLayerDistances[i] = EditorGUILayout.FloatField(string.Format("[{0}] {1}", i, layerName), m_simpleCameraLayerCulling.m_profile.m_shadowLayerDistances[i]); } } EditorGUI.indentLevel--; if (m_editorUtils.Button("RevertShadowToDefaults")) { m_simpleCameraLayerCulling.m_profile.UpdateShadow(); EditorUtility.SetDirty(m_simpleCameraLayerCulling.m_profile); } EditorGUI.indentLevel--; } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(m_simpleCameraLayerCulling); ApplyToSceneCamera(); m_simpleCameraLayerCulling.ApplyToGameCamera(); m_simpleCameraLayerCulling.ResetDirectionalLight(); SceneView.RepaintAll(); } }