Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ internal static Texture2D GetMessageTypeIcon(MessageType messageType)
/// <summary>Reset All content</summary>
public static readonly GUIContent resetAllButtonLabel = EditorGUIUtility.TrTextContent("Reset All");

/// <summary>
/// Empty space content in case that you want to keep the indentation but have nothing to write
/// </summary>
public static readonly GUIContent empty = EditorGUIUtility.TrTextContent(" ");

#endregion

static CoreEditorStyles()
Expand Down
41 changes: 41 additions & 0 deletions com.unity.render-pipelines.core/Editor/Lighting/LightUI.Skin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using UnityEngine;

namespace UnityEditor.Rendering
{
/// <summary>
/// Contains a set of methods to help render the inspectors of Lights across SRP's
/// </summary>
public partial class LightUI
{
/// <summary>
/// Styles
/// </summary>
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.");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand All @@ -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.");
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -159,7 +147,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.");
}

static Styles s_Styles = new Styles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ internal static void SetAdditionalPropertiesVisibility(bool value)
static HDLightUI()
{
Inspector = CED.Group(
CED.AdditionalPropertiesFoldoutGroup(s_Styles.generalHeader, Expandable.General, k_ExpandedState, AdditionalProperties.General, k_AdditionalPropertiesState,
CED.AdditionalPropertiesFoldoutGroup(LightUI.Styles.generalHeader, Expandable.General, k_ExpandedState, AdditionalProperties.General, k_AdditionalPropertiesState,
CED.Group((serialized, owner) => DrawGeneralContent(serialized, owner)), DrawGeneralAdditionalContent),
CED.FoldoutGroup(s_Styles.shapeHeader, Expandable.Shape, k_ExpandedState, DrawShapeContent),
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,
CED.AdditionalPropertiesFoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedState, AdditionalProperties.Emission, k_AdditionalPropertiesState,
CED.Group(
DrawColor,
DrawLightIntensityGUILayout,
Expand All @@ -106,7 +106,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,
Expand All @@ -126,19 +126,19 @@ 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))
)
)
);

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, CED.Group((serialized, owner) => DrawGeneralContent(serialized, owner, true))),
CED.FoldoutGroup(s_Styles.emissionHeader, Expandable.Emission, k_ExpandedStatePreset, CED.Group(DrawColor, DrawEmissionContent)),
CED.FoldoutGroup(s_Styles.shadowHeader, Expandable.Shadows, k_ExpandedStatePreset, DrawEnableShadowMapInternal)
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.shadowHeader, Expandable.Shadows, k_ExpandedStatePreset, DrawEnableShadowMapInternal)
);

Type lightMappingType = typeof(Lightmapping);
Expand Down Expand Up @@ -253,7 +253,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);
}
Expand Down Expand Up @@ -657,7 +657,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())
Expand All @@ -672,21 +672,20 @@ static void DrawColor(SerializedHDLight serialized, Editor owner)
{
// 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;
Expand All @@ -704,16 +703,16 @@ static void DrawColor(SerializedHDLight serialized, Editor owner)
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);
}

static void DrawEmissionContent(SerializedHDLight serialized, Editor owner)
Expand Down
Loading