Skip to content

Hd/fix targets used in ongui in decalcomponent #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -128,7 +128,7 @@ private void OnDisable()
foreach (DecalProjector decalProjector in targets)
{
if (decalProjector != null)
decalProjector.OnMaterialChange -= UpdateMaterialEditor;
decalProjector.OnMaterialChange -= RequireUpdateMaterialEditor;
}
s_Owner = null;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ internal DecalSystem.DecalHandle Handle
}
}

void OnEnable()
void InitMaterial()
{
if (m_Material == null)
{
Expand All @@ -223,6 +223,13 @@ void OnEnable()
m_Material = null;
#endif
}
}

void Reset() => InitMaterial();

void OnEnable()
{
InitMaterial();

if (m_Handle != null)
{
Expand Down