diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 780473f4aea..11de7c0bdb5 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -585,6 +585,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix error when removing DecalProjector from component contextual menu (case 1243960) - Fixed issue with post process when running in RGBA16 and an object with additive blending is in the scene. - Fixed corrupted values on LayeredLit when using Vertex Color multiply mode to multiply and MSAA is activated. +- Fix conflicts with Handles manipulation when performing a Reset in DecalComponent (case 1238833) ### Changed - Improve MIP selection for decals on Transparents diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs index aa2ce0acb8a..8f7e0a840f0 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs @@ -109,7 +109,7 @@ private void OnEnable() UpdateMaterialEditor(); foreach (var decalProjector in targets) { - (decalProjector as DecalProjector).OnMaterialChange += UpdateMaterialEditor; + (decalProjector as DecalProjector).OnMaterialChange += RequireUpdateMaterialEditor; } // Fetch serialized properties @@ -128,7 +128,7 @@ private void OnDisable() foreach (DecalProjector decalProjector in targets) { if (decalProjector != null) - decalProjector.OnMaterialChange -= UpdateMaterialEditor; + decalProjector.OnMaterialChange -= RequireUpdateMaterialEditor; } s_Owner = null; } @@ -148,6 +148,10 @@ public Bounds OnGetFrameBounds() return new Bounds(decalProjector.transform.position, handle.size); } + private bool m_RequireUpdateMaterialEditor = false; + + private void RequireUpdateMaterialEditor() => m_RequireUpdateMaterialEditor = true; + public void UpdateMaterialEditor() { int validMaterialsCount = 0; @@ -318,41 +322,49 @@ Bounds GetBoundsGetter() public override void OnInspectorGUI() { - EditorGUI.BeginChangeCheck(); + serializedObject.Update(); - EditorGUILayout.BeginHorizontal(); - GUILayout.FlexibleSpace(); - DoInspectorToolbar(k_EditVolumeModes, editVolumeLabels, GetBoundsGetter, this); + if (m_RequireUpdateMaterialEditor) + { + UpdateMaterialEditor(); + m_RequireUpdateMaterialEditor = false; + } - //[TODO: add editable pivot. Uncomment this when ready] - //DoInspectorToolbar(k_EditPivotModes, editPivotLabels, GetBoundsGetter, this); - GUILayout.FlexibleSpace(); - EditorGUILayout.EndHorizontal(); + EditorGUI.BeginChangeCheck(); + { + EditorGUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + DoInspectorToolbar(k_EditVolumeModes, editVolumeLabels, GetBoundsGetter, this); - EditorGUILayout.Space(); + //[TODO: add editable pivot. Uncomment this when ready] + //DoInspectorToolbar(k_EditPivotModes, editPivotLabels, GetBoundsGetter, this); + GUILayout.FlexibleSpace(); + EditorGUILayout.EndHorizontal(); - EditorGUILayout.PropertyField(m_Size, k_SizeContent); - EditorGUILayout.PropertyField(m_MaterialProperty, k_MaterialContent); + EditorGUILayout.Space(); - EditorGUI.BeginChangeCheck(); - EditorGUILayout.PropertyField(m_DrawDistanceProperty, k_DistanceContent); - if (EditorGUI.EndChangeCheck() && m_DrawDistanceProperty.floatValue < 0f) - m_DrawDistanceProperty.floatValue = 0f; + EditorGUILayout.PropertyField(m_Size, k_SizeContent); + EditorGUILayout.PropertyField(m_MaterialProperty, k_MaterialContent); - EditorGUILayout.PropertyField(m_FadeScaleProperty, k_FadeScaleContent); - EditorGUILayout.PropertyField(m_UVScaleProperty, k_UVScaleContent); - EditorGUILayout.PropertyField(m_UVBiasProperty, k_UVBiasContent); - EditorGUILayout.PropertyField(m_FadeFactor, k_FadeFactorContent); + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(m_DrawDistanceProperty, k_DistanceContent); + if (EditorGUI.EndChangeCheck() && m_DrawDistanceProperty.floatValue < 0f) + m_DrawDistanceProperty.floatValue = 0f; - // only display the affects transparent property if material is HDRP/decal - if (showAffectTransparencyHaveMultipleDifferentValue) - { - using (new EditorGUI.DisabledScope(true)) - EditorGUILayout.LabelField(EditorGUIUtility.TrTextContent("Multiple material type in selection")); - } - else if (showAffectTransparency) - EditorGUILayout.PropertyField(m_AffectsTransparencyProperty, k_AffectTransparentContent); + EditorGUILayout.PropertyField(m_FadeScaleProperty, k_FadeScaleContent); + EditorGUILayout.PropertyField(m_UVScaleProperty, k_UVScaleContent); + EditorGUILayout.PropertyField(m_UVBiasProperty, k_UVBiasContent); + EditorGUILayout.PropertyField(m_FadeFactor, k_FadeFactorContent); + // only display the affects transparent property if material is HDRP/decal + if (showAffectTransparencyHaveMultipleDifferentValue) + { + using (new EditorGUI.DisabledScope(true)) + EditorGUILayout.LabelField(EditorGUIUtility.TrTextContent("Multiple material type in selection")); + } + else if (showAffectTransparency) + EditorGUILayout.PropertyField(m_AffectsTransparencyProperty, k_AffectTransparentContent); + } if (EditorGUI.EndChangeCheck()) serializedObject.ApplyModifiedProperties(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs index 4f2504252ed..aa381dd10c3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProjector.cs @@ -212,7 +212,7 @@ internal DecalSystem.DecalHandle Handle } } - void OnEnable() + void InitMaterial() { if (m_Material == null) { @@ -223,6 +223,13 @@ void OnEnable() m_Material = null; #endif } + } + + void Reset() => InitMaterial(); + + void OnEnable() + { + InitMaterial(); if (m_Handle != null) {