diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs
index 4451c24e1fb..49d9c310abd 100644
--- a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs
+++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs
@@ -34,7 +34,7 @@ public VolumeComponentEditorAttribute(Type componentType)
}
///
- /// A custom editor class that draws a in the Inspector. If you do not
+ /// A custom editor class that draws a in the Inspector. If you do not
/// provide a custom editor for a , Unity uses the default one.
/// You must use a to let the editor know which
/// component this drawer is for.
@@ -43,7 +43,7 @@ public VolumeComponentEditorAttribute(Type componentType)
/// Below is an example of a custom :
///
/// using UnityEngine.Rendering;
- ///
+ ///
/// [Serializable, VolumeComponentMenu("Custom/Example Component")]
/// public class ExampleComponent : VolumeComponent
/// {
@@ -53,18 +53,18 @@ public VolumeComponentEditorAttribute(Type componentType)
/// And its associated editor:
///
/// using UnityEditor.Rendering;
- ///
+ ///
/// [VolumeComponentEditor(typeof(ExampleComponent))]
/// class ExampleComponentEditor : VolumeComponentEditor
/// {
/// SerializedDataParameter m_Intensity;
- ///
+ ///
/// public override void OnEnable()
/// {
/// var o = new PropertyFetcher<ExampleComponent>(serializedObject);
/// m_Intensity = Unpack(o.Find(x => x.intensity));
/// }
- ///
+ ///
/// public override void OnInspectorGUI()
/// {
/// PropertyField(m_Intensity);
@@ -125,7 +125,7 @@ internal set
///
protected Editor m_Inspector;
- List m_Parameters;
+ List<(GUIContent displayName, int displayOrder, SerializedDataParameter param)> m_Parameters;
static Dictionary s_ParameterDrawers;
@@ -179,6 +179,20 @@ internal void Init(VolumeComponent target, Editor inspector)
OnEnable();
}
+
+ class ParameterSorter : Comparer<(GUIContent displayName, int displayOrder, SerializedDataParameter param)>
+ {
+ public override int Compare((GUIContent displayName, int displayOrder, SerializedDataParameter param) x, (GUIContent displayName, int displayOrder, SerializedDataParameter param) y)
+ {
+ if (x.displayOrder < y.displayOrder)
+ return -1;
+ else if (x.displayOrder == y.displayOrder)
+ return 0;
+ else
+ return 1;
+ }
+ }
+
///
/// Unity calls this method when the object loads.
///
@@ -188,7 +202,7 @@ internal void Init(VolumeComponent target, Editor inspector)
///
public virtual void OnEnable()
{
- m_Parameters = new List();
+ m_Parameters = new List<(GUIContent, int, SerializedDataParameter)>();
// Grab all valid serializable field on the VolumeComponent
// TODO: Should only be done when needed / on demand as this can potentially be wasted CPU when a custom editor is in use
@@ -206,9 +220,19 @@ public virtual void OnEnable()
foreach (var field in fields)
{
var property = serializedObject.FindProperty(field.Name);
+ var name = "";
+ var order = 0;
+ var attr = (DisplayInfoAttribute[])field.GetCustomAttributes(typeof(DisplayInfoAttribute), true);
+ if (attr.Length != 0)
+ {
+ name = attr[0].name;
+ order = attr[0].order;
+ }
+
var parameter = new SerializedDataParameter(property);
- m_Parameters.Add(parameter);
+ m_Parameters.Add((new GUIContent(name), order, parameter));
}
+ m_Parameters.Sort(new ParameterSorter());
}
///
@@ -239,7 +263,12 @@ public virtual void OnInspectorGUI()
{
// Display every field as-is
foreach (var parameter in m_Parameters)
- PropertyField(parameter);
+ {
+ if (parameter.displayName.text != "")
+ PropertyField(parameter.param, parameter.displayName);
+ else
+ PropertyField(parameter.param);
+ }
}
///
diff --git a/com.unity.render-pipelines.core/Runtime/Common/CoreAttributes.cs b/com.unity.render-pipelines.core/Runtime/Common/CoreAttributes.cs
new file mode 100644
index 00000000000..29f5777a4af
--- /dev/null
+++ b/com.unity.render-pipelines.core/Runtime/Common/CoreAttributes.cs
@@ -0,0 +1,16 @@
+using System;
+
+namespace UnityEngine.Rendering
+{
+ ///
+ /// Attribute used to customize UI display.
+ ///
+ [AttributeUsage(AttributeTargets.Field)]
+ public class DisplayInfoAttribute : Attribute
+ {
+ /// Display name used in UI.
+ public string name;
+ /// Display order used in UI.
+ public int order;
+ }
+}
diff --git a/com.unity.render-pipelines.core/Runtime/Common/CoreAttributes.cs.meta b/com.unity.render-pipelines.core/Runtime/Common/CoreAttributes.cs.meta
new file mode 100644
index 00000000000..c1ac544e67a
--- /dev/null
+++ b/com.unity.render-pipelines.core/Runtime/Common/CoreAttributes.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 07346c0b2cba0214f8f27c46ec2dd613
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 370f65a345c..a807afb001c 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -115,6 +115,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added scenes for hair and fabric and decals with material samples
- Added fabric materials and textures
- Added information for fabric materials in fabric scene
+- Added a DisplayInfo attribute to specify a name override and a display order for Volume Component fields (used only in default inspector for now).
### Fixed
- Fix when rescale probe all direction below zero (1219246)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
index 501cebc9b34..d292bea79d2 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
@@ -1311,9 +1311,20 @@ DebugUI.Widget makeWidget(string name, VolumeParameter param)
// One row per parameter
foreach (var f in fields)
{
+ var fieldName = f.Name;
+ var attr = (DisplayInfoAttribute[])f.GetCustomAttributes(typeof(DisplayInfoAttribute), true);
+ if (attr.Length != 0)
+ fieldName = attr[0].name;
+#if UNITY_EDITOR
+ // Would be nice to have the equivalent for the runtime debug.
+ else
+ fieldName = UnityEditor.ObjectNames.NicifyVariableName(fieldName);
+#endif
+
+
row = new DebugUI.Table.Row()
{
- displayName = f.Name,
+ displayName = fieldName,
children = { makeWidget("Interpolated Value", data.volumeDebugSettings.GetParameter(f)) }
};
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/Fog.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/Fog.cs
index 7acdd1647a1..6128aa79825 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/Fog.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/Fog.cs
@@ -11,28 +11,28 @@ public class Fog : VolumeComponent
{
/// Enable fog.
[Tooltip("Enables the fog.")]
- public BoolParameter enabled = new BoolParameter(false);
+ public BoolParameter enabled = new BoolParameter(false);
/// Fog color mode.
- public FogColorParameter colorMode = new FogColorParameter(FogColorMode.SkyColor);
+ public FogColorParameter colorMode = new FogColorParameter(FogColorMode.SkyColor);
/// Fog color.
[Tooltip("Specifies the constant color of the fog.")]
- public ColorParameter color = new ColorParameter(Color.grey, hdr: true, showAlpha: false, showEyeDropper: true);
+ public ColorParameter color = new ColorParameter(Color.grey, hdr: true, showAlpha: false, showEyeDropper: true);
/// Specifies the tint of the fog when using Sky Color.
[Tooltip("Specifies the tint of the fog.")]
- public ColorParameter tint = new ColorParameter(Color.white, hdr: true, showAlpha: false, showEyeDropper: true);
+ public ColorParameter tint = new ColorParameter(Color.white, hdr: true, showAlpha: false, showEyeDropper: true);
/// Maximum fog distance.
[Tooltip("Sets the maximum fog distance HDRP uses when it shades the skybox or the Far Clipping Plane of the Camera.")]
- public MinFloatParameter maxFogDistance = new MinFloatParameter(5000.0f, 0.0f);
+ public MinFloatParameter maxFogDistance = new MinFloatParameter(5000.0f, 0.0f);
/// Controls the maximum mip map HDRP uses for mip fog (0 is the lowest mip and 1 is the highest mip).
[Tooltip("Controls the maximum mip map HDRP uses for mip fog (0 is the lowest mip and 1 is the highest mip).")]
public ClampedFloatParameter mipFogMaxMip = new ClampedFloatParameter(0.5f, 0.0f, 1.0f);
/// Sets the distance at which HDRP uses the minimum mip image of the blurred sky texture as the fog color.
[Tooltip("Sets the distance at which HDRP uses the minimum mip image of the blurred sky texture as the fog color.")]
- public MinFloatParameter mipFogNear = new MinFloatParameter(0.0f, 0.0f);
+ public MinFloatParameter mipFogNear = new MinFloatParameter(0.0f, 0.0f);
/// Sets the distance at which HDRP uses the maximum mip image of the blurred sky texture as the fog color.
[Tooltip("Sets the distance at which HDRP uses the maximum mip image of the blurred sky texture as the fog color.")]
- public MinFloatParameter mipFogFar = new MinFloatParameter(1000.0f, 0.0f);
+ public MinFloatParameter mipFogFar = new MinFloatParameter(1000.0f, 0.0f);
// Height Fog
/// Height fog base height.
@@ -44,14 +44,17 @@ public class Fog : VolumeComponent
/// Fog albedo.
public ColorParameter albedo = new ColorParameter(Color.white);
/// Fog mean free path.
+ [DisplayInfo(name = "Fog Attenuation Distance")]
public MinFloatParameter meanFreePath = new MinFloatParameter(400.0f, 1.0f);
// Optional Volumetric Fog
/// Enable volumetric fog.
+ [DisplayInfo(name = "Volumetric Fog")]
public BoolParameter enableVolumetricFog = new BoolParameter(false);
/// Volumetric fog anisotropy.
public ClampedFloatParameter anisotropy = new ClampedFloatParameter(0.0f, -1.0f, 1.0f);
/// Multiplier for ambient probe contribution.
+ [DisplayInfo(name = "Ambient Light Probe Dimmer")]
public ClampedFloatParameter globalLightProbeDimmer = new ClampedFloatParameter(1.0f, 0.0f, 1.0f);
/// Sets the distance (in meters) from the Camera's Near Clipping Plane to the back of the Camera's volumetric lighting buffer.