// TODO: See if this can be refactored into a custom VolumeParameterDrawer void DoExposurePropertyField(SerializedDataParameter exposureProperty) { using (var scope = new OverridablePropertyScope(exposureProperty, exposureProperty.displayName, this)) { if (!scope.displayed) { return; } using (new EditorGUILayout.VerticalScope()) { EditorGUILayout.LabelField(scope.label); var xOffset = EditorGUIUtility.labelWidth + 2; var lineRect = EditorGUILayout.GetControlRect(); lineRect.x += xOffset; lineRect.width -= xOffset; var sliderRect = lineRect; sliderRect.y -= EditorGUIUtility.singleLineHeight; k_LightUnitSlider.SetSerializedObject(serializedObject); k_LightUnitSlider.DrawExposureSlider(exposureProperty.value, sliderRect); // GUIContent.none disables horizontal scrolling, use TrTextContent and adjust the rect to make it work. lineRect.x -= EditorGUIUtility.labelWidth + 2; lineRect.y += EditorGUIUtility.standardVerticalSpacing; lineRect.width += EditorGUIUtility.labelWidth + 2; EditorGUI.PropertyField(lineRect, exposureProperty.value, EditorGUIUtility.TrTextContent(" ")); } } }
public override void OnInspectorGUI() { UpdateSkyAndFogIntPopupData(); using (var scope = new OverridablePropertyScope(m_SkyType, EditorGUIUtility.TrTextContent("Sky type", "Specifies the type of sky this Volume uses."), this)) { if (scope.displayed) { EditorGUILayout.IntPopup(m_SkyType.value, m_SkyClassNames.ToArray(), m_SkyUniqueIDs.ToArray(), scope.label); } } using (var scope = new OverridablePropertyScope(m_CloudType, EditorGUIUtility.TrTextContent("Background clouds", "Specifies the type of background cloud this Volume uses."), this)) { if (scope.displayed) { EditorGUILayout.IntPopup(m_CloudType.value, m_CloudClassNames.ToArray(), m_CloudUniqueIDs.ToArray(), scope.label); } } PropertyField(m_SkyAmbientMode, EditorGUIUtility.TrTextContent("Ambient Mode", "Specifies how the global ambient probe is computed. Dynamic will use the currently displayed sky and static will use the sky setup in the environment lighting panel.")); var staticLightingSky = SkyManager.GetStaticLightingSky(); if (m_SkyAmbientMode.value.GetEnumValue <SkyAmbientMode>() == SkyAmbientMode.Static) { if (staticLightingSky == null) { EditorGUILayout.HelpBox("No Static Lighting Sky is assigned in the Environment settings.", MessageType.Info); } else { var skyType = staticLightingSky.staticLightingSkyUniqueID == 0 ? "no Sky" : SkyManager.skyTypesDict[staticLightingSky.staticLightingSkyUniqueID].Name.ToString(); var cloudType = staticLightingSky.staticLightingCloudsUniqueID == 0 ? "no Clouds" : SkyManager.cloudTypesDict[staticLightingSky.staticLightingCloudsUniqueID].Name.ToString(); EditorGUILayout.HelpBox($"Current Static Lighting Sky uses {skyType} and {cloudType} of profile {staticLightingSky.profile?.name ?? "None"}.", MessageType.Info); } } PropertyField(m_WindOrientation, EditorGUIUtility.TrTextContent("Global Orientation", "Controls the orientation of the wind relative to the X world vector.")); PropertyField(m_WindSpeed, EditorGUIUtility.TrTextContent("Global Speed", "Controls the global wind speed in kilometers per hour.")); }
public override void OnInspectorGUI() { bool updateDefaultShadowTint = false; EditorGUI.BeginChangeCheck(); PropertyField(m_hdriSky); if (EditorGUI.EndChangeCheck()) { GetUpperHemisphereLuxValue(); updateDefaultShadowTint = true; } PropertyField(m_EnableCloudMotion); if (m_EnableCloudMotion.value.boolValue) { using (new IndentLevelScope()) { using (var scope = new OverridablePropertyScope(m_Procedural, Styles.distorsionMode, this)) { if (scope.displayed) { EditorGUI.BeginChangeCheck(); bool newValue = EditorGUILayout.IntPopup(Styles.distorsionMode, (int)m_Procedural.value.intValue, m_DistortionModes, m_DistortionModeValues) == 1; if (EditorGUI.EndChangeCheck()) { m_Procedural.value.boolValue = newValue; } } } if (!m_Procedural.value.boolValue) { using (new IndentLevelScope()) { PropertyField(m_Flowmap); if (IsFlowmapFormatInvalid(m_Flowmap)) { EditorGUILayout.HelpBox(Styles.flowmapInfoMessage, MessageType.Info); } PropertyField(m_UpperHemisphereOnly); } } PropertyField(m_ScrollDirection); PropertyField(m_ScrollSpeed); } } base.CommonSkySettingsGUI(); PropertyField(m_EnableBackplate, Styles.backplate); if (m_EnableBackplate.value.boolValue) { using (new IndentLevelScope()) { PropertyField(m_BackplateType, Styles.type); bool constraintAsCircle = false; if (m_BackplateType.value.enumValueIndex == (uint)BackplateType.Disc) { constraintAsCircle = true; } PropertyField(m_GroundLevel); if (m_BackplateType.value.enumValueIndex != (uint)BackplateType.Infinite) { EditorGUI.BeginChangeCheck(); PropertyField(m_Scale); if (EditorGUI.EndChangeCheck()) { if (m_Scale.value.vector2Value.x < 0.0f || m_Scale.value.vector2Value.y < 0.0f) { m_Scale.value.vector2Value = new Vector2(Mathf.Abs(m_Scale.value.vector2Value.x), Mathf.Abs(m_Scale.value.vector2Value.x)); } } if (constraintAsCircle) { m_Scale.value.vector2Value = new Vector2(m_Scale.value.vector2Value.x, m_Scale.value.vector2Value.x); } else if (m_BackplateType.value.enumValueIndex == (uint)BackplateType.Ellipse && Mathf.Abs(m_Scale.value.vector2Value.x - m_Scale.value.vector2Value.y) < 1e-4f) { m_Scale.value.vector2Value = new Vector2(m_Scale.value.vector2Value.x, m_Scale.value.vector2Value.x + 1e-4f); } } PropertyField(m_ProjectionDistance, Styles.projection); PropertyField(m_PlateRotation, Styles.rotation); PropertyField(m_PlateTexRotation, Styles.textureRotation); PropertyField(m_PlateTexOffset, Styles.textureOffset); if (m_BackplateType.value.enumValueIndex != (uint)BackplateType.Infinite) { PropertyField(m_BlendAmount); } PropertyField(m_PointLightShadow, Styles.pointSpotShadow); PropertyField(m_DirLightShadow, Styles.directionalShadow); PropertyField(m_RectLightShadow, Styles.areaShadow); PropertyField(m_ShadowTint); if (updateDefaultShadowTint || GUILayout.Button(Styles.resetColors)) { m_ShadowTint.value.colorValue = new Color(m_UpperHemisphereLuxColor.value.vector3Value.x, m_UpperHemisphereLuxColor.value.vector3Value.y, m_UpperHemisphereLuxColor.value.vector3Value.z); } } } }
/// <summary> /// Method used to display common sky UI elements. /// </summary> protected void CommonSkySettingsGUI() { if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.SkyIntensity) != 0) { using (var scope = new OverridablePropertyScope(m_IntensityMode, m_SkyIntensityModeLabel, this)) { if (scope.displayed) { var rect = EditorGUILayout.GetControlRect(); EditorGUI.BeginProperty(rect, m_SkyIntensityModeLabel, m_IntensityMode.value); if (m_EnableLuxIntensityMode) { m_IntensityMode.value.intValue = EditorGUI.IntPopup(rect, m_SkyIntensityModeLabel, (int)m_IntensityMode.value.intValue, m_IntensityModes, m_IntensityModeValues); } else { m_IntensityMode.value.intValue = EditorGUI.IntPopup(rect, m_SkyIntensityModeLabel, (int)m_IntensityMode.value.intValue, m_IntensityModesNoLux, m_IntensityModeValuesNoLux); } EditorGUI.EndProperty(); } } using (new IndentLevelScope()) { if (m_IntensityMode.value.GetEnumValue <SkyIntensityMode>() == SkyIntensityMode.Exposure) { PropertyField(m_SkyExposure, m_ExposureCompensationLabel); } else if (m_IntensityMode.value.GetEnumValue <SkyIntensityMode>() == SkyIntensityMode.Multiplier) { PropertyField(m_SkyMultiplier); } else if (m_IntensityMode.value.GetEnumValue <SkyIntensityMode>() == SkyIntensityMode.Lux) { PropertyField(m_DesiredLuxValue); // Show the multiplier EditorGUILayout.HelpBox(System.String.Format( "Upper hemisphere lux value: {0}\nAbsolute multiplier: {1}", m_UpperHemisphereLuxValue.value.floatValue, (m_DesiredLuxValue.value.floatValue / m_UpperHemisphereLuxValue.value.floatValue) ), MessageType.Info); } } } if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.Rotation) != 0) { PropertyField(m_SkyRotation); } if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.UpdateMode) != 0) { PropertyField(m_EnvUpdateMode); if (!m_EnvUpdateMode.value.hasMultipleDifferentValues && m_EnvUpdateMode.value.intValue == (int)EnvironmentUpdateMode.Realtime) { using (new IndentLevelScope()) { PropertyField(m_EnvUpdatePeriod); } } } if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.IncludeSunInBaking) != 0) { PropertyField(m_IncludeSunInBaking); } }
public override void OnInspectorGUI() { DrawHeader("Model"); using (var scope = new OverridablePropertyScope(m_Type, m_ModelTypeLabel, this)) if (scope.displayed) { m_Type.value.intValue = EditorGUILayout.IntPopup(m_ModelTypeLabel, m_Type.value.intValue, m_ModelTypes, m_ModelTypeValues); } PhysicallyBasedSkyModel type = (PhysicallyBasedSkyModel)m_Type.value.intValue; DrawHeader("Planet"); if (type == PhysicallyBasedSkyModel.EarthSimple) { PropertyField(m_SeaLevel); } else { PropertyField(m_SphericalMode); using (new IndentLevelScope()) { bool isSpherical = !m_SphericalMode.overrideState.boolValue || m_SphericalMode.value.boolValue; if (isSpherical) { PropertyField(m_PlanetCenterPosition); if (type == PhysicallyBasedSkyModel.Custom) { PropertyField(m_PlanetaryRadius); } } else { PropertyField(m_SeaLevel); } } PropertyField(m_PlanetRotation); PropertyField(m_GroundColorTexture); } PropertyField(m_GroundTint); if (type != PhysicallyBasedSkyModel.EarthSimple) { PropertyField(m_GroundEmissionTexture); PropertyField(m_GroundEmissionMultiplier); } if (type != PhysicallyBasedSkyModel.EarthSimple) { DrawHeader("Space"); PropertyField(m_SpaceRotation); PropertyField(m_SpaceEmissionTexture); PropertyField(m_SpaceEmissionMultiplier); } if (type == PhysicallyBasedSkyModel.Custom) { DrawHeader("Air"); PropertyField(m_AirMaximumAltitude); PropertyField(m_AirDensityR); PropertyField(m_AirDensityG); PropertyField(m_AirDensityB); PropertyField(m_AirTint); } DrawHeader("Aerosols"); PropertyField(m_AerosolDensity); PropertyField(m_AerosolTint); if (type != PhysicallyBasedSkyModel.EarthSimple) { PropertyField(m_AerosolAnisotropy); PropertyField(m_AerosolMaximumAltitude); } EditorGUILayout.Space(); DrawHeader("Artistic Overrides"); PropertyField(m_ColorSaturation); PropertyField(m_AlphaSaturation); PropertyField(m_AlphaMultiplier); PropertyField(m_HorizonTint); PropertyField(m_HorizonZenithShift); PropertyField(m_ZenithTint); EditorGUILayout.Space(); DrawHeader("Miscellaneous"); PropertyField(m_NumberOfBounces); base.CommonSkySettingsGUI(); }