feat: support non full-rect graphics for some effect

This commit is contained in:
mob-sakai
2024-12-26 17:16:39 +09:00
parent 5bee8adc83
commit a66baea1e8
3 changed files with 35 additions and 0 deletions
+12
View File
@@ -55,6 +55,9 @@ namespace Coffee.UIEffects.Editors
private SerializedProperty _shadowEffectOnOrigin;
private SerializedProperty _shadowMirrorScale;
private bool _expandOthers;
private SerializedProperty _allowExtendVertex;
private void OnEnable()
{
if (target == null) return;
@@ -101,6 +104,8 @@ namespace Coffee.UIEffects.Editors
_shadowFade = serializedObject.FindProperty("m_ShadowFade");
_shadowEffectOnOrigin = serializedObject.FindProperty("m_ShadowEffectOnOrigin");
_shadowMirrorScale = serializedObject.FindProperty("m_ShadowMirrorScale");
_allowExtendVertex = serializedObject.FindProperty("m_AllowExtendVertex");
}
public override void OnInspectorGUI()
@@ -230,6 +235,13 @@ namespace Coffee.UIEffects.Editors
EditorGUILayout.PropertyField(_shadowEffectOnOrigin);
EditorGUI.indentLevel--;
}
DrawSeparator();
_expandOthers = EditorGUILayout.BeginFoldoutHeaderGroup(_expandOthers, "Others");
if (_expandOthers)
{
EditorGUILayout.PropertyField(_allowExtendVertex);
}
}
private static void DrawColor(SerializedProperty filter, SerializedProperty color, ColorFilter prevFilter)
+17
View File
@@ -127,6 +127,9 @@ namespace Coffee.UIEffects
[SerializeField]
protected float m_ShadowMirrorScale = 0.5f;
[SerializeField]
protected bool m_AllowExtendVertex = true;
public ToneFilter toneFilter
{
get => m_ToneFilter;
@@ -521,6 +524,17 @@ namespace Coffee.UIEffects
}
}
public bool allowExtendVertex
{
get => m_AllowExtendVertex;
set
{
if (m_AllowExtendVertex == value) return;
context.allowExtendVertex = m_AllowExtendVertex = value;
SetVerticesDirty();
}
}
public List<UIEffectReplica> replicas => _replicas ??= InternalListPool<UIEffectReplica>.Rent();
private List<UIEffectReplica> _replicas;
@@ -604,6 +618,7 @@ namespace Coffee.UIEffects
c.shadowFade = m_ShadowFade;
c.shadowEffectOnOrigin = m_ShadowEffectOnOrigin;
c.shadowMirrorScale = m_ShadowMirrorScale;
c.allowExtendVertex = m_AllowExtendVertex;
}
public override void ApplyContextToMaterial()
@@ -749,6 +764,8 @@ namespace Coffee.UIEffects
m_ShadowEffectOnOrigin = c.shadowEffectOnOrigin;
m_ShadowMirrorScale = c.shadowMirrorScale;
m_AllowExtendVertex = c.allowExtendVertex;
UpdateContext(context);
ApplyContextToMaterial();
SetVerticesDirty();
+6
View File
@@ -139,6 +139,8 @@ namespace Coffee.UIEffects
public bool shadowEffectOnOrigin = false;
public float shadowMirrorScale = 0.5f;
public bool allowExtendVertex;
public bool willModifyMaterial => samplingFilter != SamplingFilter.None
|| transitionFilter != TransitionFilter.None
@@ -191,6 +193,8 @@ namespace Coffee.UIEffects
shadowIteration = preset.shadowIteration;
shadowFade = preset.shadowFade;
shadowEffectOnOrigin = preset.shadowEffectOnOrigin;
allowExtendVertex = preset.allowExtendVertex;
}
public void ApplyToMaterial(Material material, float actualSamplingScale = 1f)
@@ -435,6 +439,8 @@ namespace Coffee.UIEffects
private Vector2 GetExpandSize()
{
if (!allowExtendVertex) return Vector2.zero;
var expandSize = Vector2.zero;
switch (samplingFilter)
{