From 269cd564137e5225265f53db7daacfb9c83184e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Thu, 19 Aug 2021 11:53:33 +0200 Subject: [PATCH 1/3] XPipeline-Sharing styles across Light Inspectors --- .../Editor/CoreEditorStyles.cs | 3 ++ .../Editor/Lighting/LightUI.Skin.cs | 41 +++++++++++++++++++ .../Editor/Lighting/LightUI.Skin.cs.meta | 11 +++++ .../Editor/Lighting/HDLightUI.Skin.cs | 13 ------ .../Editor/Lighting/HDLightUI.cs | 35 ++++++++-------- .../UniversalRenderPipelineLightUI.Drawers.cs | 25 ++++++----- ...alRenderPipelineLightUI.PresetInspector.cs | 6 +-- .../UniversalRenderPipelineLightUI.Skin.cs | 14 +------ 8 files changed, 88 insertions(+), 60 deletions(-) create mode 100644 com.unity.render-pipelines.core/Editor/Lighting/LightUI.Skin.cs create mode 100644 com.unity.render-pipelines.core/Editor/Lighting/LightUI.Skin.cs.meta diff --git a/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs b/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs index 0641cc62b3a..b7702a857ee 100644 --- a/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs +++ b/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs @@ -169,6 +169,9 @@ internal static Texture2D GetMessageTypeIcon(MessageType messageType) /// Reset All content public static readonly GUIContent resetAllButtonLabel = EditorGUIUtility.TrTextContent("Reset All"); + // in case that you want to keep the indentation but have nothing to write + public static readonly GUIContent empty = EditorGUIUtility.TrTextContent(" "); + #endregion static CoreEditorStyles() diff --git a/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Skin.cs b/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Skin.cs new file mode 100644 index 00000000000..688576417c9 --- /dev/null +++ b/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Skin.cs @@ -0,0 +1,41 @@ +using UnityEngine; + +namespace UnityEditor.Rendering +{ + /// + /// Contains a set of methods to help render the inspectors of Lights across SRP's + /// + public partial class LightUI + { + /// + /// Styles + /// + public static class Styles + { + public static readonly GUIContent generalHeader = EditorGUIUtility.TrTextContent("General"); + public static readonly GUIContent shapeHeader = EditorGUIUtility.TrTextContent("Shape"); + public static readonly GUIContent renderingHeader = EditorGUIUtility.TrTextContent("Rendering"); + public static readonly GUIContent emissionHeader = EditorGUIUtility.TrTextContent("Emission"); + public static readonly GUIContent shadowHeader = EditorGUIUtility.TrTextContent("Shadows"); + + public static readonly GUIContent lightLayer = EditorGUIUtility.TrTextContent("Light Layer", "Specifies the current Light Layers that the Light affects. This Light illuminates corresponding Renderers with the same Light Layer flags."); + + // Emission + public static readonly GUIContent color = EditorGUIUtility.TrTextContent("Color", "Specifies the color this Light emits."); + public static readonly GUIContent lightAppearance = EditorGUIUtility.TrTextContent("Light Appearance", "Specifies the mode for this Light's color is calculated."); + public static readonly GUIContent[] lightAppearanceOptions = new[] + { + EditorGUIUtility.TrTextContent("Color"), + EditorGUIUtility.TrTextContent("Filter and Temperature") + }; + public static readonly GUIContent[] lightAppearanceUnits = new[] + { + EditorGUIUtility.TrTextContent("Kelvin") + }; + public static readonly GUIContent colorFilter = EditorGUIUtility.TrTextContent("Filter", "Specifies a color which tints the Light source."); + public static readonly GUIContent colorTemperature = EditorGUIUtility.TrTextContent("Temperature", "Specifies a temperature (in Kelvin) used to correlate a color for the Light. For reference, White is 6500K."); + + public static readonly string unsupportedPresetPropertiesMessage = L10n.Tr("When using Preset of Light Component, only a subset of properties are supported. Unsupported properties are hidden."); + } + } +} diff --git a/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Skin.cs.meta b/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Skin.cs.meta new file mode 100644 index 00000000000..650481f892f --- /dev/null +++ b/com.unity.render-pipelines.core/Editor/Lighting/LightUI.Skin.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 57198e360c6d9454b831562cef29b556 +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.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs index b789acdbc97..65956c05d28 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs @@ -9,12 +9,8 @@ partial class HDLightUI sealed class Styles { // Headers - public readonly GUIContent generalHeader = EditorGUIUtility.TrTextContent("General"); - public readonly GUIContent shapeHeader = EditorGUIUtility.TrTextContent("Shape"); public readonly GUIContent celestialBodyHeader = EditorGUIUtility.TrTextContent("Celestial Body"); - public readonly GUIContent emissionHeader = EditorGUIUtility.TrTextContent("Emission"); public readonly GUIContent volumetricHeader = EditorGUIUtility.TrTextContent("Volumetrics"); - public readonly GUIContent shadowHeader = EditorGUIUtility.TrTextContent("Shadows"); public readonly GUIContent shadowMapSubHeader = EditorGUIUtility.TrTextContent("Shadow Map"); public readonly GUIContent contactShadowsSubHeader = EditorGUIUtility.TrTextContent("Contact Shadows"); public readonly GUIContent bakedShadowsSubHeader = EditorGUIUtility.TrTextContent("Baked Shadows"); @@ -32,10 +28,6 @@ sealed class Styles public readonly GUIContent bakedShadowRadius = EditorGUIUtility.TrTextContent("Radius", "Sets the amount of artificial softening the baking process applies to the edges of shadows cast by this Point or Spot Light."); public readonly GUIContent bakedShadowAngle = EditorGUIUtility.TrTextContent("Angle", "Controls the amount of artificial softening the baking process applies to the edges of shadows cast by Directional Lights."); public readonly GUIContent lightBounceIntensity = EditorGUIUtility.TrTextContent("Indirect Multiplier", "Controls the intensity of the indirect light this Light contributes to the Scene. A value of 0 with a Realtime Light causes HDRP to remove it from realtime global illumination. A value of 0 for Baked and Mixed Lights cause them to no longer emit indirect lighting. This has no effect if you disable both Realtime and Baked global illumination."); - public readonly GUIContent color = EditorGUIUtility.TrTextContent("Color", "Specifies the color this Light emits."); - public readonly GUIContent lightAppearance = EditorGUIUtility.TrTextContent("Light Appearance", "Specifies the mode for how HDRP calculates this Light's color."); - public readonly GUIContent colorFilter = EditorGUIUtility.TrTextContent("Filter", "Specifies a color which tints the Light source."); - public readonly GUIContent colorTemperature = EditorGUIUtility.TrTextContent("Temperature", "Specifies a temperature (in Kelvin) HDRP uses to correlate a color for the Light. For reference, White is 6500K."); public readonly GUIContent areaLightCookie = EditorGUIUtility.TrTextContent("Cookie", "Cookie mask currently assigned to the area light."); public readonly GUIContent iesTexture = EditorGUIUtility.TrTextContent("IES Profile", "IES Profile (Support: Point, Spot, Rectangular-Area Lights)."); public readonly GUIContent cookieTextureTypeError = EditorGUIUtility.TrTextContent("HDRP does not support the Cookie Texture type, only Default is supported.", EditorGUIUtility.IconContent("console.warnicon").image); @@ -50,9 +42,6 @@ sealed class Styles public readonly GUIContent areaIntensity = EditorGUIUtility.TrTextContent("Intensity (Lumen)", "Luminous power of the Light in Lumen."); public readonly GUIContent lightIntensity = EditorGUIUtility.TrTextContent("Intensity", "Sets the strength of the Light. Use the drop-down to select the light units to use."); - // in case that you want to keep the indentation but have nothing to write - public readonly GUIContent empty = EditorGUIUtility.TrTextContent(" "); - public readonly GUIContent lightRadius = EditorGUIUtility.TrTextContent("Radius", "Sets the radius of the light source. This affects the falloff of diffuse lighting, the spread of the specular highlight, and the softness of Ray Traced shadows."); public readonly GUIContent affectDiffuse = EditorGUIUtility.TrTextContent("Affect Diffuse", "When disabled, HDRP does not calculate diffuse lighting for this Light. Does not increase performance as HDRP still calculates the diffuse lighting."); public readonly GUIContent affectSpecular = EditorGUIUtility.TrTextContent("Affect Specular", "When disabled, HDRP does not calculate specular lighting for this Light. Does not increase performance as HDRP still calculates the specular lighting."); @@ -83,7 +72,6 @@ sealed class Styles public readonly GUIContent areaLightEmissiveMeshMotionVector = EditorGUIUtility.TrTextContent("Motion Vectors", "Specify wether the generated Mesh renders 'Per Object Motion', 'Camera Motion' or 'No Motion' vectors to the Camera Motion Vector Texture."); public readonly GUIContent areaLightEmissiveMeshSameLayer = EditorGUIUtility.TrTextContent("Same Layer", "If checked, use the same Layer than the Light one."); public readonly GUIContent areaLightEmissiveMeshCustomLayer = EditorGUIUtility.TrTextContent("Custom Layer", "Specify on which layer the generated Mesh live."); - public readonly GUIContent lightLayer = EditorGUIUtility.TrTextContent("Light Layer", "Specifies the current Light Layers that the Light affects. This Light illuminates corresponding Renderers with the same Light Layer flags."); public readonly GUIContent interactsWithSky = EditorGUIUtility.TrTextContent("Affect Physically Based Sky", "Check this option to make the light and the Physically Based sky affect one another."); public readonly GUIContent angularDiameter = EditorGUIUtility.TrTextContent("Angular Diameter", "Angular diameter of the emissive celestial body represented by the light as seen from the camera (in degrees). Used to render the sun/moon disk."); @@ -160,7 +148,6 @@ sealed class Styles // Warnings public readonly string unsupportedLightShapeWarning = L10n.Tr("This light shape is not supported by Realtime Global Illumination."); - public readonly string unsupportedPresetPropertiesMessage = L10n.Tr("When using Preset of Light Component, only a subset of properties are supported. Unsupported properties are hidden."); public Styles() { 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 7209768671c..a703f3ee0f2 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs @@ -87,11 +87,11 @@ internal static void SetAdditionalPropertiesVisibility(bool value) static HDLightUI() { Inspector = CED.Group( - CED.AdditionalPropertiesFoldoutGroup(s_Styles.generalHeader, Expandable.General, k_ExpandedState, AdditionalProperties.General, k_AdditionalPropertiesState, DrawGeneralContent, DrawGeneralAdditionalContent), - CED.FoldoutGroup(s_Styles.shapeHeader, Expandable.Shape, k_ExpandedState, DrawShapeContent), + CED.AdditionalPropertiesFoldoutGroup(LightUI.Styles.generalHeader, Expandable.General, k_ExpandedState, AdditionalProperties.General, k_AdditionalPropertiesState, DrawGeneralContent, DrawGeneralAdditionalContent), + CED.FoldoutGroup(LightUI.Styles.shapeHeader, Expandable.Shape, k_ExpandedState, DrawShapeContent), CED.Conditional((serialized, owner) => serialized.type == HDLightType.Directional && !serialized.settings.isCompletelyBaked, CED.FoldoutGroup(s_Styles.celestialBodyHeader, Expandable.CelestialBody, k_ExpandedState, DrawCelestialBodyContent)), - CED.AdditionalPropertiesFoldoutGroup(s_Styles.emissionHeader, Expandable.Emission, k_ExpandedState, AdditionalProperties.Emission, k_AdditionalPropertiesState, DrawEmissionContent, DrawEmissionAdditionalContent), + CED.AdditionalPropertiesFoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedState, AdditionalProperties.Emission, k_AdditionalPropertiesState, DrawEmissionContent, DrawEmissionAdditionalContent), CED.Conditional((serialized, owner) => serialized.type != HDLightType.Area && !serialized.settings.isCompletelyBaked, CED.FoldoutGroup(s_Styles.volumetricHeader, Expandable.Volumetric, k_ExpandedState, DrawVolumetric)), CED.Conditional((serialized, owner) => @@ -100,7 +100,7 @@ static HDLightUI() return type != HDLightType.Area || type == HDLightType.Area && serialized.areaLightShape != AreaLightShape.Tube; }, CED.TernaryConditional((serialized, owner) => !serialized.settings.isCompletelyBaked, - CED.AdditionalPropertiesFoldoutGroup(s_Styles.shadowHeader, Expandable.Shadows, k_ExpandedState, AdditionalProperties.Shadow, k_AdditionalPropertiesState, + CED.AdditionalPropertiesFoldoutGroup(LightUI.Styles.shadowHeader, Expandable.Shadows, k_ExpandedState, AdditionalProperties.Shadow, k_AdditionalPropertiesState, CED.Group( CED.Group( CED.AdditionalPropertiesFoldoutGroup(s_Styles.shadowMapSubHeader, Expandable.ShadowMap, k_ExpandedState, AdditionalProperties.Shadow, k_AdditionalPropertiesState, @@ -120,7 +120,7 @@ static HDLightUI() ), CED.noop //will only add parameter in first sub header ), - CED.FoldoutGroup(s_Styles.shadowHeader, Expandable.Shadows, k_ExpandedState, + CED.FoldoutGroup(LightUI.Styles.shadowHeader, Expandable.Shadows, k_ExpandedState, CED.FoldoutGroup(s_Styles.bakedShadowsSubHeader, Expandable.BakedShadow, k_ExpandedState, FoldoutOption.SubFoldout | FoldoutOption.Indent | FoldoutOption.NoSpaceAtEnd, DrawBakedShadowsContent)) ) ) @@ -133,11 +133,11 @@ static HDLightUI() PresetInspector = CED.Group( CED.Group((serialized, owner) => - EditorGUILayout.HelpBox(s_Styles.unsupportedPresetPropertiesMessage, MessageType.Info)), + EditorGUILayout.HelpBox(LightUI.Styles.unsupportedPresetPropertiesMessage, MessageType.Info)), CED.Group((serialized, owner) => EditorGUILayout.Space()), - CED.FoldoutGroup(s_Styles.generalHeader, Expandable.General, k_ExpandedStatePreset, DrawGeneralContent), - CED.FoldoutGroup(s_Styles.emissionHeader, Expandable.Emission, k_ExpandedStatePreset, DrawEmissionContentForPreset), - CED.FoldoutGroup(s_Styles.shadowHeader, Expandable.Shadows, k_ExpandedStatePreset, DrawEnableShadowMapInternal) + CED.FoldoutGroup(LightUI.Styles.generalHeader, Expandable.General, k_ExpandedStatePreset, DrawGeneralContent), + CED.FoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedStatePreset, DrawEmissionContentForPreset), + CED.FoldoutGroup(LightUI.Styles.shadowHeader, Expandable.Shadows, k_ExpandedStatePreset, DrawEnableShadowMapInternal) ); } @@ -221,7 +221,7 @@ static void DrawGeneralAdditionalContent(SerializedHDLight serialized, Editor ow { using (var change = new EditorGUI.ChangeCheckScope()) { - EditorGUILayout.PropertyField(serialized.lightlayersMask, s_Styles.lightLayer); + EditorGUILayout.PropertyField(serialized.lightlayersMask, LightUI.Styles.lightLayer); if (change.changed && serialized.linkShadowLayers.boolValue) SyncLightAndShadowLayers(serialized, owner); } @@ -625,7 +625,7 @@ static void DrawLightIntensityGUILayout(SerializedHDLight serialized, Editor own // Draw the unit textfield EditorGUI.BeginChangeCheck(); - EditorGUI.PropertyField(valueRect, serialized.intensity, s_Styles.empty); + EditorGUI.PropertyField(valueRect, serialized.intensity, CoreEditorStyles.empty); DrawLightIntensityUnitPopup(unitRect, serialized, owner); if (EditorGUI.EndChangeCheck()) @@ -652,21 +652,20 @@ static void DrawEmissionContentFiltered(SerializedHDLight serialized, Editor own { // Use the color temperature bool to create a popup dropdown to choose between the two modes. var colorTemperaturePopupValue = Convert.ToInt32(serialized.settings.useColorTemperature.boolValue); - var lightAppearanceOptions = new[] { "Color", "Filter and Temperature" }; - colorTemperaturePopupValue = EditorGUILayout.Popup(s_Styles.lightAppearance, colorTemperaturePopupValue, lightAppearanceOptions); + 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, s_Styles.colorFilter); + 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, s_Styles.colorTemperature); + EditorGUI.LabelField(labelRect, LightUI.Styles.colorTemperature); var temperatureSliderRect = lineRect; temperatureSliderRect.x += EditorGUIUtility.labelWidth + k_ValueUnitSeparator; @@ -684,16 +683,16 @@ static void DrawEmissionContentFiltered(SerializedHDLight serialized, Editor own unitRect.x += valueRect.width - indent + k_ValueUnitSeparator; unitRect.width = k_UnitWidth + .5f; - EditorGUI.PropertyField(valueRect, serialized.settings.colorTemperature, s_Styles.empty); + EditorGUI.PropertyField(valueRect, serialized.settings.colorTemperature, CoreEditorStyles.empty); EditorGUI.Popup(unitRect, 0, new[] { "Kelvin" }); EditorGUI.indentLevel -= 1; } else - EditorGUILayout.PropertyField(serialized.settings.color, s_Styles.color); + EditorGUILayout.PropertyField(serialized.settings.color, LightUI.Styles.color); } else - EditorGUILayout.PropertyField(serialized.settings.color, s_Styles.color); + EditorGUILayout.PropertyField(serialized.settings.color, LightUI.Styles.color); } if (!isInPreset) 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 13381cfa3f3..8ebb1173053 100644 --- a/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs +++ b/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs @@ -40,13 +40,13 @@ enum Expandable return !sceneLighting; }, (_, __) => EditorGUILayout.HelpBox(Styles.DisabledLightWarning.text, MessageType.Warning)), - CED.FoldoutGroup(Styles.generalHeader, + CED.FoldoutGroup(LightUI.Styles.generalHeader, Expandable.General, k_ExpandedState, DrawGeneralContent), CED.Conditional( (serializedLight, editor) => !serializedLight.settings.lightType.hasMultipleDifferentValues && serializedLight.settings.light.type == LightType.Spot, - CED.FoldoutGroup(Styles.shapeHeader, Expandable.Shape, k_ExpandedState, DrawSpotShapeContent)), + CED.FoldoutGroup(LightUI.Styles.shapeHeader, Expandable.Shape, k_ExpandedState, DrawSpotShapeContent)), CED.Conditional( (serializedLight, editor) => { @@ -55,16 +55,16 @@ enum Expandable var lightType = serializedLight.settings.light.type; return lightType == LightType.Rectangle || lightType == LightType.Disc; }, - CED.FoldoutGroup(Styles.shapeHeader, Expandable.Shape, k_ExpandedState, DrawAreaShapeContent)), - CED.FoldoutGroup(Styles.emissionHeader, + CED.FoldoutGroup(LightUI.Styles.shapeHeader, Expandable.Shape, k_ExpandedState, DrawAreaShapeContent)), + CED.FoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedState, CED.Group(DrawerColor, DrawEmissionContent)), - CED.FoldoutGroup(Styles.renderingHeader, + CED.FoldoutGroup(LightUI.Styles.renderingHeader, Expandable.Rendering, k_ExpandedState, DrawRenderingContent), - CED.FoldoutGroup(Styles.shadowHeader, + CED.FoldoutGroup(LightUI.Styles.shadowHeader, Expandable.Shadows, k_ExpandedState, DrawShadowsContent), @@ -170,7 +170,7 @@ static void DrawGeneralContentInternal(UniversalRenderPipelineSerializedLight se if (lightType != LightType.Rectangle && !serializedLight.settings.isCompletelyBaked && UniversalRenderPipeline.asset.supportsLightLayers && !isInPreset) { EditorGUI.BeginChangeCheck(); - DrawLightLayerMask(serializedLight.lightLayerMask, Styles.LightLayer); + DrawLightLayerMask(serializedLight.lightLayerMask, LightUI.Styles.lightLayer); if (EditorGUI.EndChangeCheck()) { if (!serializedLight.customShadowLayers.boolValue) @@ -253,23 +253,22 @@ static void DrawerColor(UniversalRenderPipelineSerializedLight serializedLight, { // Use the color temperature bool to create a popup dropdown to choose between the two modes. var colorTemperaturePopupValue = Convert.ToInt32(serializedLight.settings.useColorTemperature.boolValue); - var lightAppearanceOptions = new[] { "Color", "Filter and Temperature" }; - colorTemperaturePopupValue = EditorGUILayout.Popup(Styles.lightAppearance, colorTemperaturePopupValue, lightAppearanceOptions); + 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, Styles.colorFilter); - k_SliderWithTexture(Styles.colorTemperature, serializedLight.settings.colorTemperature, serializedLight.settings); + EditorGUILayout.PropertyField(serializedLight.settings.color, LightUI.Styles.colorFilter); + k_SliderWithTexture(LightUI.Styles.colorTemperature, serializedLight.settings.colorTemperature, serializedLight.settings); } else - EditorGUILayout.PropertyField(serializedLight.settings.color, Styles.color); + EditorGUILayout.PropertyField(serializedLight.settings.color, LightUI.Styles.color); } } else - EditorGUILayout.PropertyField(serializedLight.settings.color, Styles.color); + EditorGUILayout.PropertyField(serializedLight.settings.color, LightUI.Styles.color); } } 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 72aeacc0ad1..82bf5d0ae4a 100644 --- a/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.PresetInspector.cs +++ b/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.PresetInspector.cs @@ -13,13 +13,13 @@ partial class UniversalRenderPipelineLightUI public static readonly CED.IDrawer PresetInspector = CED.Group( CED.Group((serialized, owner) => - EditorGUILayout.HelpBox(Styles.unsupportedPresetPropertiesMessage, MessageType.Info)), + EditorGUILayout.HelpBox(LightUI.Styles.unsupportedPresetPropertiesMessage, MessageType.Info)), CED.Group((serialized, owner) => EditorGUILayout.Space()), - CED.FoldoutGroup(Styles.generalHeader, + CED.FoldoutGroup(LightUI.Styles.generalHeader, Expandable.General, k_ExpandedStatePreset, DrawGeneralContentPreset), - CED.FoldoutGroup(Styles.emissionHeader, + CED.FoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedStatePreset, CED.Group(DrawerColor, diff --git a/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs b/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs index 8414b405e51..d1605235505 100644 --- a/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs +++ b/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs @@ -7,11 +7,6 @@ partial class UniversalRenderPipelineLightUI { static class Styles { - public static readonly GUIContent generalHeader = new GUIContent("General"); - public static readonly GUIContent shapeHeader = new GUIContent("Shape"); - public static readonly GUIContent renderingHeader = new GUIContent("Rendering"); - public static readonly GUIContent emissionHeader = new GUIContent("Emission"); - public static readonly GUIContent shadowHeader = new GUIContent("Shadows"); public static readonly GUIContent lightCookieHeader = new GUIContent("Light Cookie"); public static readonly GUIContent Type = EditorGUIUtility.TrTextContent("Type", "Specifies the current type of light. Possible types are Directional, Spot, Point, and Area lights."); @@ -46,7 +41,7 @@ static class Styles }; public static readonly GUIContent[] ShadowResolutionDefaultOptions = { - new GUIContent("Custom"), + EditorGUIUtility.TrTextContent("Custom"), UniversalRenderPipelineAssetUI.Styles.additionalLightsShadowResolutionTierNames[0], UniversalRenderPipelineAssetUI.Styles.additionalLightsShadowResolutionTierNames[1], UniversalRenderPipelineAssetUI.Styles.additionalLightsShadowResolutionTierNames[2], @@ -61,18 +56,11 @@ static class Styles EditorGUIUtility.TrTextContent("Use settings from Render Pipeline Asset") }; - public static readonly GUIContent LightLayer = EditorGUIUtility.TrTextContent("Light Layer", "Specifies the current Light Layers that the Light affects. This Light illuminates corresponding Renderers with the same Light Layer flags."); public static readonly GUIContent customShadowLayers = EditorGUIUtility.TrTextContent("Custom Shadow Layers", "When enabled, you can use the Layer property below to specify the layers for shadows seperately to lighting. When disabled, the Light Layer property in the General section specifies the layers for both lighting and for shadows."); public static readonly GUIContent ShadowLayer = EditorGUIUtility.TrTextContent("Layer", "Specifies the light layer to use for shadows."); public static readonly GUIContent LightCookieSize = EditorGUIUtility.TrTextContent("Cookie Size", "Controls the size of the cookie mask currently assigned to the light."); public static readonly GUIContent LightCookieOffset = EditorGUIUtility.TrTextContent("Cookie Offset", "Controls the offset of the cookie mask currently assigned to the light."); - - public static readonly GUIContent colorTemperature = new GUIContent("Temperature", "Specifies a temperature (in Kelvin) used to correlate a color for the Light. For reference, White is 6500K."); - public static readonly GUIContent lightAppearance = new GUIContent("Light Appearance", "Specifies the mode for how this Light's color is calculated."); - public static readonly GUIContent color = new GUIContent("Color", "Specifies the color this Light emits."); - public static readonly GUIContent colorFilter = new GUIContent("Filter", "Specifies a color which tints the Light source."); - public static readonly string unsupportedPresetPropertiesMessage = L10n.Tr("When using Preset of Light Component, only a subset of properties are supported. Unsupported properties are hidden."); } } } From 0a65f77df6f15f9e42d832144ba3b6e22ad1121b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Thu, 19 Aug 2021 11:59:29 +0200 Subject: [PATCH 2/3] Docs --- com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs b/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs index b7702a857ee..044bbf1f2c7 100644 --- a/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs +++ b/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs @@ -169,7 +169,9 @@ internal static Texture2D GetMessageTypeIcon(MessageType messageType) /// Reset All content public static readonly GUIContent resetAllButtonLabel = EditorGUIUtility.TrTextContent("Reset All"); - // in case that you want to keep the indentation but have nothing to write + /// + /// Empty space content in case that you want to keep the indentation but have nothing to write + /// public static readonly GUIContent empty = EditorGUIUtility.TrTextContent(" "); #endregion From 9dd2001c075ea7128b5289f9525cfb0a2bcfe73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Fri, 3 Sep 2021 14:02:44 +0200 Subject: [PATCH 3/3] format --- .../Editor/Lighting/HDLightUI.cs | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) 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 8a12cc6ef88..a44120089c3 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs @@ -670,49 +670,49 @@ 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); + // 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.DrawTemperatureSlider(serialized.settings, 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); + 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, s_Styles.color); + EditorGUILayout.PropertyField(serialized.settings.color, LightUI.Styles.color); } static void DrawEmissionContent(SerializedHDLight serialized, Editor owner)