diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index 0df56ba9184..5452c4d9445 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -81,6 +81,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed potentially conflicting runtime Rendering Debugger UI command by adding an option to disable runtime UI altogether (1345783). - Fixed Lens Flare position for celestial at very far camera distances. It now locks correctly into the celestial position regardless of camera distance (1363291) - Fixed issues caused by automatically added EventSystem component, required to support Rendering Debugger Runtime UI input. (1361901) +- Fixed API to draw color temperature for Lights. ### Changed - Improved the warning messages for Volumes and their Colliders. diff --git a/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Drawers.cs b/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Drawers.cs new file mode 100644 index 00000000000..81650c43b9e --- /dev/null +++ b/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Drawers.cs @@ -0,0 +1,61 @@ +using System; +using UnityEngine; +using UnityEngine.Rendering; + +namespace UnityEditor.Rendering +{ + /// + /// Contains a set of methods to help render the inspectors of Lights across SRP's + /// + public partial class LightUI + { + public static void DrawColor(ISerializedLight serialized, Editor owner) + { + if (GraphicsSettings.lightsUseLinearIntensity && GraphicsSettings.lightsUseColorTemperature) + { + // Use the color temperature bool to create a popup dropdown to choose between the two modes. + var colorTemperaturePopupValue = Convert.ToInt32(serialized.settings.useColorTemperature.boolValue); + colorTemperaturePopupValue = EditorGUILayout.Popup(Styles.lightAppearance, colorTemperaturePopupValue, Styles.lightAppearanceOptions); + serialized.settings.useColorTemperature.boolValue = Convert.ToBoolean(colorTemperaturePopupValue); + + if (serialized.settings.useColorTemperature.boolValue) + { + EditorGUI.indentLevel += 1; + EditorGUILayout.PropertyField(serialized.settings.color, Styles.colorFilter); + + // Light unit slider + const int k_ValueUnitSeparator = 2; + var lineRect = EditorGUILayout.GetControlRect(); + var labelRect = lineRect; + labelRect.width = EditorGUIUtility.labelWidth; + EditorGUI.LabelField(labelRect, Styles.colorTemperature); + + var temperatureSliderRect = lineRect; + temperatureSliderRect.x += EditorGUIUtility.labelWidth + k_ValueUnitSeparator; + temperatureSliderRect.width -= EditorGUIUtility.labelWidth + k_ValueUnitSeparator; + TemperatureSliderUIDrawer.Draw(serialized.settings, serialized.serializedObject, serialized.settings.colorTemperature, temperatureSliderRect); + + // Value and unit label + // Match const defined in EditorGUI.cs + const int k_IndentPerLevel = 15; + const int k_UnitWidth = 60 + k_IndentPerLevel; + int indent = k_IndentPerLevel * EditorGUI.indentLevel; + Rect valueRect = EditorGUILayout.GetControlRect(); + valueRect.width += indent - k_ValueUnitSeparator - k_UnitWidth; + Rect unitRect = valueRect; + unitRect.x += valueRect.width - indent + k_ValueUnitSeparator; + unitRect.width = k_UnitWidth + .5f; + + EditorGUI.PropertyField(valueRect, serialized.settings.colorTemperature, CoreEditorStyles.empty); + EditorGUI.LabelField(unitRect, Styles.lightAppearanceUnits[0]); + + EditorGUI.indentLevel -= 1; + } + else + EditorGUILayout.PropertyField(serialized.settings.color, Styles.color); + } + else + EditorGUILayout.PropertyField(serialized.settings.color, Styles.color); + } + } +} diff --git a/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Drawers.cs.meta b/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Drawers.cs.meta new file mode 100644 index 00000000000..32dec915f3e --- /dev/null +++ b/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Drawers.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 63524ac66f4f7c044bc3dc991c570e89 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs index 9472e3830ff..872b3da020a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs @@ -94,7 +94,7 @@ static HDLightUI() CED.FoldoutGroup(s_Styles.celestialBodyHeader, Expandable.CelestialBody, k_ExpandedState, DrawCelestialBodyContent)), CED.AdditionalPropertiesFoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedState, AdditionalProperties.Emission, k_AdditionalPropertiesState, CED.Group( - DrawColor, + LightUI.DrawColor, DrawLightIntensityGUILayout, DrawEmissionContent), DrawEmissionAdditionalContent), @@ -137,7 +137,9 @@ static HDLightUI() EditorGUILayout.HelpBox(LightUI.Styles.unsupportedPresetPropertiesMessage, MessageType.Info)), CED.Group((serialized, owner) => EditorGUILayout.Space()), CED.FoldoutGroup(LightUI.Styles.generalHeader, Expandable.General, k_ExpandedStatePreset, CED.Group((serialized, owner) => DrawGeneralContent(serialized, owner, true))), - CED.FoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedStatePreset, CED.Group(DrawColor, DrawEmissionContent)), + CED.FoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedStatePreset, CED.Group( + LightUI.DrawColor, + DrawEmissionContent)), CED.FoldoutGroup(LightUI.Styles.shadowHeader, Expandable.Shadows, k_ExpandedStatePreset, DrawEnableShadowMapInternal) ); @@ -666,55 +668,6 @@ static void DrawLightIntensityGUILayout(SerializedHDLight serialized, Editor own } } - static void DrawColor(SerializedHDLight serialized, Editor owner) - { - if (GraphicsSettings.lightsUseLinearIntensity && GraphicsSettings.lightsUseColorTemperature) - { - // Use the color temperature bool to create a popup dropdown to choose between the two modes. - var colorTemperaturePopupValue = Convert.ToInt32(serialized.settings.useColorTemperature.boolValue); - colorTemperaturePopupValue = EditorGUILayout.Popup(LightUI.Styles.lightAppearance, colorTemperaturePopupValue, LightUI.Styles.lightAppearanceOptions); - serialized.settings.useColorTemperature.boolValue = Convert.ToBoolean(colorTemperaturePopupValue); - - if (serialized.settings.useColorTemperature.boolValue) - { - EditorGUI.indentLevel += 1; - EditorGUILayout.PropertyField(serialized.settings.color, LightUI.Styles.colorFilter); - - // Light unit slider - const int k_ValueUnitSeparator = 2; - var lineRect = EditorGUILayout.GetControlRect(); - var labelRect = lineRect; - labelRect.width = EditorGUIUtility.labelWidth; - EditorGUI.LabelField(labelRect, LightUI.Styles.colorTemperature); - - var temperatureSliderRect = lineRect; - temperatureSliderRect.x += EditorGUIUtility.labelWidth + k_ValueUnitSeparator; - temperatureSliderRect.width -= EditorGUIUtility.labelWidth + k_ValueUnitSeparator; - TemperatureSliderUIDrawer.Draw(serialized.settings, serialized.serializedObject, serialized.settings.colorTemperature, temperatureSliderRect); - - // Value and unit label - // Match const defined in EditorGUI.cs - const int k_IndentPerLevel = 15; - const int k_UnitWidth = 100 + k_IndentPerLevel; - int indent = k_IndentPerLevel * EditorGUI.indentLevel; - Rect valueRect = EditorGUILayout.GetControlRect(); - valueRect.width += indent - k_ValueUnitSeparator - k_UnitWidth; - Rect unitRect = valueRect; - unitRect.x += valueRect.width - indent + k_ValueUnitSeparator; - unitRect.width = k_UnitWidth + .5f; - - EditorGUI.PropertyField(valueRect, serialized.settings.colorTemperature, CoreEditorStyles.empty); - EditorGUI.Popup(unitRect, 0, new[] { "Kelvin" }); - - EditorGUI.indentLevel -= 1; - } - else - EditorGUILayout.PropertyField(serialized.settings.color, LightUI.Styles.color); - } - else - EditorGUILayout.PropertyField(serialized.settings.color, LightUI.Styles.color); - } - static void DrawEmissionContent(SerializedHDLight serialized, Editor owner) { HDLightType lightType = serialized.type; diff --git a/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs b/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs index 8ebb1173053..2b2b364c2d5 100644 --- a/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs +++ b/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs @@ -59,7 +59,9 @@ enum Expandable CED.FoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedState, - CED.Group(DrawerColor, DrawEmissionContent)), + CED.Group( + LightUI.DrawColor, + DrawEmissionContent)), CED.FoldoutGroup(LightUI.Styles.renderingHeader, Expandable.Rendering, k_ExpandedState, @@ -245,33 +247,6 @@ static void DrawAreaShapeContent(UniversalRenderPipelineSerializedLight serializ serializedLight.settings.DrawArea(); } - static void DrawerColor(UniversalRenderPipelineSerializedLight serializedLight, Editor owner) - { - using (var changes = new EditorGUI.ChangeCheckScope()) - { - if (GraphicsSettings.lightsUseLinearIntensity && GraphicsSettings.lightsUseColorTemperature) - { - // Use the color temperature bool to create a popup dropdown to choose between the two modes. - var colorTemperaturePopupValue = Convert.ToInt32(serializedLight.settings.useColorTemperature.boolValue); - colorTemperaturePopupValue = EditorGUILayout.Popup(LightUI.Styles.lightAppearance, colorTemperaturePopupValue, LightUI.Styles.lightAppearanceOptions); - serializedLight.settings.useColorTemperature.boolValue = Convert.ToBoolean(colorTemperaturePopupValue); - - using (new EditorGUI.IndentLevelScope()) - { - if (serializedLight.settings.useColorTemperature.boolValue) - { - EditorGUILayout.PropertyField(serializedLight.settings.color, LightUI.Styles.colorFilter); - k_SliderWithTexture(LightUI.Styles.colorTemperature, serializedLight.settings.colorTemperature, serializedLight.settings); - } - else - EditorGUILayout.PropertyField(serializedLight.settings.color, LightUI.Styles.color); - } - } - else - EditorGUILayout.PropertyField(serializedLight.settings.color, LightUI.Styles.color); - } - } - static void DrawEmissionContent(UniversalRenderPipelineSerializedLight serializedLight, Editor owner) { serializedLight.settings.DrawIntensity(); diff --git a/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.PresetInspector.cs b/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.PresetInspector.cs index 82bf5d0ae4a..64c7993c9bc 100644 --- a/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.PresetInspector.cs +++ b/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.PresetInspector.cs @@ -22,7 +22,8 @@ partial class UniversalRenderPipelineLightUI CED.FoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedStatePreset, - CED.Group(DrawerColor, + CED.Group( + LightUI.DrawColor, DrawEmissionContent)), CED.FoldoutGroup(Styles.lightCookieHeader, Expandable.LightCookie,