From ebd06cc15f4e42f5839373b9299c1737e1f36cf7 Mon Sep 17 00:00:00 2001 From: Remi Slysz <40034005+RSlysz@users.noreply.github.com> Date: Tue, 12 May 2020 11:57:36 +0200 Subject: [PATCH 1/3] Fix Reset not resetting to default --- .../Runtime/Material/Decal/DecalProjector.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) { From 6c77792635bdd197d34973f129c5128ac77be96c Mon Sep 17 00:00:00 2001 From: Remi Slysz <40034005+RSlysz@users.noreply.github.com> Date: Tue, 12 May 2020 11:58:26 +0200 Subject: [PATCH 2/3] Delay MaterialEditor recreation to when possible --- .../Material/Decal/DecalProjectorEditor.cs | 70 +++++++++++-------- 1 file changed, 41 insertions(+), 29 deletions(-) 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 ab124573fa3..170dd6bbc41 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 @@ -127,7 +127,7 @@ private void OnDisable() { foreach (var decalProjector in targets) { - (decalProjector as DecalProjector).OnMaterialChange -= UpdateMaterialEditor; + (decalProjector as DecalProjector).OnMaterialChange -= RequireUpdateMaterialEditor; } s_Owner = null; } @@ -147,6 +147,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; @@ -317,41 +321,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(); From c375a1fd6edd313f070db207342a9be27ef156f7 Mon Sep 17 00:00:00 2001 From: Remi Slysz <40034005+RSlysz@users.noreply.github.com> Date: Tue, 12 May 2020 12:01:39 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index e6d59ed0021..115db126fb4 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -581,6 +581,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed flickering of the game/scene view when lookdev is running. - Fixed issue with reflection probes in realtime time mode with OnEnable baking having wrong lighting with sky set to dynamic (case 1238047). - Fixed transparent motion vectors not working when in MSAA. +- Fix conflicts with Handles manipulation when performing a Reset in DecalComponent (case 1238833) ### Changed - Improve MIP selection for decals on Transparents