diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs
index 87a6b6f1073..ec2540dda56 100644
--- a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs
+++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs
@@ -166,6 +166,11 @@ internal Editor inspector
set => m_Inspector = value;
}
+ ///
+ /// Obtains the that is being edited from this volume component
+ ///
+ protected Volume volume => inspector?.target as Volume;
+
List<(GUIContent displayName, int displayOrder, SerializedDataParameter param)> m_Parameters;
static Dictionary s_ParameterDrawers;
diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md
index 9dc28ed40a0..a53c1c6d89f 100644
--- a/com.unity.render-pipelines.high-definition/CHANGELOG.md
+++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -120,6 +120,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed HDRP build issues with DOTS_INSTANCING_ON shader variant.
- Fixed default value of "Distortion Blur" from 1 to 0 according to the doc.
- Fixed Transparent Depth Pre/Post pass by default for the built-in HDRP Hair shader graph.
+- Fixed NullReferenceException when opening a Volume Component with a Diffusion Profile with any inspector.
### Changed
- Converted most TGA textures files to TIF to reduce the size of HDRP material samples.
diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/DiffusionProfileOverrideEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/DiffusionProfileOverrideEditor.cs
index 91dfb406a51..47b1eb9a702 100644
--- a/com.unity.render-pipelines.high-definition/Editor/Lighting/DiffusionProfileOverrideEditor.cs
+++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/DiffusionProfileOverrideEditor.cs
@@ -14,7 +14,6 @@ namespace UnityEditor.Rendering.HighDefinition
sealed class DiffusionProfileOverrideEditor : VolumeComponentEditor
{
SerializedDataParameter m_DiffusionProfiles;
- Volume m_Volume;
DiffusionProfileSettingsListUI listUI = new DiffusionProfileSettingsListUI();
@@ -23,8 +22,6 @@ sealed class DiffusionProfileOverrideEditor : VolumeComponentEditor
public override void OnEnable()
{
var o = new PropertyFetcher(serializedObject);
-
- m_Volume = (m_Inspector.target as Volume);
m_DiffusionProfiles = Unpack(o.Find(x => x.diffusionProfiles));
}
@@ -36,7 +33,7 @@ public override void OnInspectorGUI()
// If the volume is null it means that we're editing the component from the asset
// So we can't access the bounds of the volume to fill diffusion profiles used in the volume
- if (m_Volume != null && !m_Volume.isGlobal)
+ if (volume != null && !volume.isGlobal)
{
if (GUILayout.Button("Fill Profile List With Scene Materials"))
FillProfileListWithScene();
@@ -54,10 +51,10 @@ void DrawDiffusionProfileElement(SerializedProperty element, Rect rect, int inde
void FillProfileListWithScene()
{
var profiles = new HashSet();
- if (m_Volume.isGlobal)
+ if (volume.isGlobal)
return;
- var volumeCollider = m_Volume.GetComponent();
+ var volumeCollider = volume.GetComponent();
// Get all mesh renderers that are within the current volume
var diffusionProfiles = new List();