Skip to content

Commit b30a0eb

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.0] HDRP Fix Decal Projector Layer Mask Override
1 parent f549355 commit b30a0eb

File tree

1 file changed

+44
-20
lines changed

1 file changed

+44
-20
lines changed

Packages/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,9 @@ void UpdateSizeOfOneTarget(DecalProjector currentTarget)
630630
m_SizeValues[axe].floatValue = newSize;
631631
}
632632

633-
internal void MinMaxSliderWithFields(GUIContent label, ref float minValue, ref float maxValue, float minLimit, float maxLimit)
633+
internal void MinMaxSliderWithFields(Rect rect, GUIContent label, ref float minValue, ref float maxValue, float minLimit, float maxLimit)
634634
{
635-
var rect = EditorGUILayout.GetControlRect();
635+
// Reserve label space and push the slider rect to the right
636636
rect = EditorGUI.PrefixLabel(rect, label);
637637

638638
const float fieldWidth = 40, padding = 4;
@@ -662,6 +662,45 @@ internal void MinMaxSliderWithFields(GUIContent label, ref float minValue, ref f
662662
}
663663
}
664664

665+
void DoRenderingLayerMask()
666+
{
667+
Rect rect = EditorGUILayout.GetControlRect(true, 18f);
668+
EditorGUI.BeginProperty(rect, k_DecalLayerMaskContent, m_DecalLayerMask);
669+
670+
var mask = m_DecalLayerMask.uintValue;
671+
EditorGUI.BeginChangeCheck();
672+
mask = EditorGUI.RenderingLayerMaskField(rect, k_DecalLayerMaskContent, (RenderingLayerMask)mask, EditorStyles.layerMaskField);
673+
if (EditorGUI.EndChangeCheck())
674+
{
675+
m_DecalLayerMask.intValue = unchecked((int) mask);
676+
serializedObject.ApplyModifiedProperties();
677+
}
678+
679+
EditorGUI.EndProperty();
680+
}
681+
682+
void DoAngleFade()
683+
{
684+
// The slider edits 2 different properties. Both can be overridden separately.
685+
var rect = EditorGUILayout.GetControlRect();
686+
EditorGUI.BeginProperty(rect, k_AngleFadeContent, m_StartAngleFadeProperty);
687+
EditorGUI.BeginProperty(rect, k_AngleFadeContent, m_EndAngleFadeProperty);
688+
689+
float angleFadeMinValue = m_StartAngleFadeProperty.floatValue;
690+
float angleFadeMaxValue = m_EndAngleFadeProperty.floatValue;
691+
EditorGUI.BeginChangeCheck();
692+
MinMaxSliderWithFields(rect,k_AngleFadeContent, ref angleFadeMinValue, ref angleFadeMaxValue, 0.0f, 180.0f);
693+
if (EditorGUI.EndChangeCheck())
694+
{
695+
m_StartAngleFadeProperty.floatValue = angleFadeMinValue;
696+
m_EndAngleFadeProperty.floatValue = angleFadeMaxValue;
697+
serializedObject.ApplyModifiedProperties();
698+
}
699+
700+
EditorGUI.EndProperty();
701+
EditorGUI.EndProperty();
702+
}
703+
665704
public override void OnInspectorGUI()
666705
{
667706
bool supportDecals = false;
@@ -735,14 +774,7 @@ public override void OnInspectorGUI()
735774
decalLayerEnabled = supportDecals && hdrp.currentPlatformRenderPipelineSettings.supportDecalLayers;
736775
using (new EditorGUI.DisabledScope(!decalLayerEnabled))
737776
{
738-
var mask = m_DecalLayerMask.uintValue;
739-
EditorGUI.BeginChangeCheck();
740-
mask = EditorGUILayout.RenderingLayerMaskField(k_DecalLayerMaskContent, mask);
741-
if (EditorGUI.EndChangeCheck())
742-
{
743-
m_DecalLayerMask.intValue = unchecked((int) mask);
744-
EditorUtility.SetDirty(m_DecalLayerMask.serializedObject.targetObject);
745-
}
777+
DoRenderingLayerMask();
746778
}
747779
}
748780

@@ -758,15 +790,7 @@ public override void OnInspectorGUI()
758790
EditorGUILayout.PropertyField(m_FadeScaleProperty, k_FadeScaleContent);
759791
using (new EditorGUI.DisabledScope(!decalLayerEnabled))
760792
{
761-
float angleFadeMinValue = m_StartAngleFadeProperty.floatValue;
762-
float angleFadeMaxValue = m_EndAngleFadeProperty.floatValue;
763-
EditorGUI.BeginChangeCheck();
764-
MinMaxSliderWithFields(k_AngleFadeContent, ref angleFadeMinValue, ref angleFadeMaxValue, 0.0f, 180.0f);
765-
if (EditorGUI.EndChangeCheck())
766-
{
767-
m_StartAngleFadeProperty.floatValue = angleFadeMinValue;
768-
m_EndAngleFadeProperty.floatValue = angleFadeMaxValue;
769-
}
793+
DoAngleFade();
770794
}
771795

772796
if (!decalLayerEnabled)
@@ -985,7 +1009,7 @@ public override void Action(int instanceId, string pathName, string resourceFile
9851009
}
9861010

9871011
if (shader != null)
988-
{
1012+
{
9891013
var material = new Material(shader);
9901014
AssetDatabase.CreateAsset(material, materialName);
9911015
ProjectWindowUtil.ShowCreatedAsset(material);

0 commit comments

Comments
 (0)