Hd/fix targets used in ongui in decalcomponent by RSlysz · Pull Request #413 · Unity-Technologies/Graphics · GitHub
Skip to content
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 @@ -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