Skip to content

Commit a66baea

Browse files
committed
feat: support non full-rect graphics for some effect
1 parent 5bee8ad commit a66baea

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

Packages/src/Editor/UIEffectEditor.cs

+12
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public class UIEffect2Editor : Editor
5555
private SerializedProperty _shadowEffectOnOrigin;
5656
private SerializedProperty _shadowMirrorScale;
5757

58+
private bool _expandOthers;
59+
private SerializedProperty _allowExtendVertex;
60+
5861
private void OnEnable()
5962
{
6063
if (target == null) return;
@@ -101,6 +104,8 @@ private void OnEnable()
101104
_shadowFade = serializedObject.FindProperty("m_ShadowFade");
102105
_shadowEffectOnOrigin = serializedObject.FindProperty("m_ShadowEffectOnOrigin");
103106
_shadowMirrorScale = serializedObject.FindProperty("m_ShadowMirrorScale");
107+
108+
_allowExtendVertex = serializedObject.FindProperty("m_AllowExtendVertex");
104109
}
105110

106111
public override void OnInspectorGUI()
@@ -230,6 +235,13 @@ public void DrawProperties()
230235
EditorGUILayout.PropertyField(_shadowEffectOnOrigin);
231236
EditorGUI.indentLevel--;
232237
}
238+
239+
DrawSeparator();
240+
_expandOthers = EditorGUILayout.BeginFoldoutHeaderGroup(_expandOthers, "Others");
241+
if (_expandOthers)
242+
{
243+
EditorGUILayout.PropertyField(_allowExtendVertex);
244+
}
233245
}
234246

235247
private static void DrawColor(SerializedProperty filter, SerializedProperty color, ColorFilter prevFilter)

Packages/src/Runtime/UIEffect.cs

+17
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ public class UIEffect : UIEffectBase
127127
[SerializeField]
128128
protected float m_ShadowMirrorScale = 0.5f;
129129

130+
[SerializeField]
131+
protected bool m_AllowExtendVertex = true;
132+
130133
public ToneFilter toneFilter
131134
{
132135
get => m_ToneFilter;
@@ -521,6 +524,17 @@ public float shadowMirrorScale
521524
}
522525
}
523526

527+
public bool allowExtendVertex
528+
{
529+
get => m_AllowExtendVertex;
530+
set
531+
{
532+
if (m_AllowExtendVertex == value) return;
533+
context.allowExtendVertex = m_AllowExtendVertex = value;
534+
SetVerticesDirty();
535+
}
536+
}
537+
524538
public List<UIEffectReplica> replicas => _replicas ??= InternalListPool<UIEffectReplica>.Rent();
525539
private List<UIEffectReplica> _replicas;
526540

@@ -604,6 +618,7 @@ protected override void UpdateContext(UIEffectContext c)
604618
c.shadowFade = m_ShadowFade;
605619
c.shadowEffectOnOrigin = m_ShadowEffectOnOrigin;
606620
c.shadowMirrorScale = m_ShadowMirrorScale;
621+
c.allowExtendVertex = m_AllowExtendVertex;
607622
}
608623

609624
public override void ApplyContextToMaterial()
@@ -749,6 +764,8 @@ internal void CopyFrom(UIEffectContext c)
749764
m_ShadowEffectOnOrigin = c.shadowEffectOnOrigin;
750765
m_ShadowMirrorScale = c.shadowMirrorScale;
751766

767+
m_AllowExtendVertex = c.allowExtendVertex;
768+
752769
UpdateContext(context);
753770
ApplyContextToMaterial();
754771
SetVerticesDirty();

Packages/src/Runtime/UIEffectContext.cs

+6
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ public class UIEffectContext
139139
public bool shadowEffectOnOrigin = false;
140140
public float shadowMirrorScale = 0.5f;
141141

142+
public bool allowExtendVertex;
143+
142144

143145
public bool willModifyMaterial => samplingFilter != SamplingFilter.None
144146
|| transitionFilter != TransitionFilter.None
@@ -191,6 +193,8 @@ public void CopyFrom(UIEffectContext preset)
191193
shadowIteration = preset.shadowIteration;
192194
shadowFade = preset.shadowFade;
193195
shadowEffectOnOrigin = preset.shadowEffectOnOrigin;
196+
197+
allowExtendVertex = preset.allowExtendVertex;
194198
}
195199

196200
public void ApplyToMaterial(Material material, float actualSamplingScale = 1f)
@@ -435,6 +439,8 @@ private int GetVertexCountMultiply()
435439

436440
private Vector2 GetExpandSize()
437441
{
442+
if (!allowExtendVertex) return Vector2.zero;
443+
438444
var expandSize = Vector2.zero;
439445
switch (samplingFilter)
440446
{

0 commit comments

Comments
 (0)