feat: tweener supports EdgeMode.Shiny

close #307
This commit is contained in:
mob-sakai
2025-02-10 19:52:06 +09:00
parent bbb1f965fd
commit 32558d4481
5 changed files with 35 additions and 2 deletions
+3
View File
@@ -88,6 +88,7 @@ namespace Coffee.UIEffects.Editors
private SerializedProperty _edgeWidth;
private SerializedProperty _edgeColorFilter;
private SerializedProperty _edgeColor;
private SerializedProperty _edgeShinyRate;
private SerializedProperty _edgeShinyWidth;
private SerializedProperty _edgeShinyAutoPlaySpeed;
private SerializedProperty _patternArea;
@@ -154,6 +155,7 @@ namespace Coffee.UIEffects.Editors
_edgeWidth = serializedObject.FindProperty("m_EdgeWidth");
_edgeColorFilter = serializedObject.FindProperty("m_EdgeColorFilter");
_edgeColor = serializedObject.FindProperty("m_EdgeColor");
_edgeShinyRate = serializedObject.FindProperty("m_EdgeShinyRate");
_edgeShinyWidth = serializedObject.FindProperty("m_EdgeShinyWidth");
_edgeShinyAutoPlaySpeed = serializedObject.FindProperty("m_EdgeShinyAutoPlaySpeed");
_patternArea = serializedObject.FindProperty("m_PatternArea");
@@ -378,6 +380,7 @@ namespace Coffee.UIEffects.Editors
if ((EdgeMode)_edgeMode.intValue == EdgeMode.Shiny)
{
EditorGUILayout.PropertyField(_edgeShinyRate);
EditorGUILayout.PropertyField(_edgeShinyWidth);
EditorGUILayout.PropertyField(_edgeShinyAutoPlaySpeed);
+24
View File
@@ -194,6 +194,10 @@ namespace Coffee.UIEffects
[SerializeField]
protected Color m_EdgeColor = Color.white;
[Range(0, 1)]
[SerializeField]
protected float m_EdgeShinyRate = 0.5f;
[Range(0, 1)]
[SerializeField]
protected float m_EdgeShinyWidth = 0.5f;
@@ -736,6 +740,18 @@ namespace Coffee.UIEffects
}
}
public float edgeShinyRate
{
get => m_EdgeShinyRate;
set
{
value = Mathf.Clamp(value, 0, 1);
if (Mathf.Approximately(m_EdgeShinyRate, value)) return;
context.edgeShinyRate = m_EdgeShinyRate = value;
SetMaterialDirty();
}
}
public float edgeWidth
{
get => m_EdgeWidth;
@@ -994,6 +1010,7 @@ namespace Coffee.UIEffects
c.shadowColorGlow = m_ShadowColorGlow;
c.edgeMode = m_EdgeMode;
c.edgeShinyRate = m_EdgeShinyRate;
c.edgeWidth = m_EdgeWidth;
c.edgeColorFilter = m_EdgeColorFilter;
c.edgeColor = m_EdgeColor;
@@ -1052,6 +1069,11 @@ namespace Coffee.UIEffects
{
gradationRotation = Mathf.Lerp(0f, 360f, rate);
}
if (edgeMode == EdgeMode.Shiny && 0 < (mask & UIEffectTweener.CullingMask.EdgeShiny))
{
edgeShinyRate = rate;
}
}
public override bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
@@ -1132,6 +1154,7 @@ namespace Coffee.UIEffects
m_ShadowColorGlow = preset.m_ShadowColorGlow;
m_EdgeMode = preset.m_EdgeMode;
m_EdgeShinyRate = preset.m_EdgeShinyRate;
m_EdgeWidth = preset.m_EdgeWidth;
m_EdgeColorFilter = preset.m_EdgeColorFilter;
m_EdgeColor = preset.m_EdgeColor;
@@ -1205,6 +1228,7 @@ namespace Coffee.UIEffects
m_ShadowColorGlow = c.shadowColorGlow;
m_EdgeMode = c.edgeMode;
m_EdgeShinyRate = c.edgeShinyRate;
m_EdgeWidth = c.edgeWidth;
m_EdgeColorFilter = c.edgeColorFilter;
m_EdgeColor = c.edgeColor;
+4
View File
@@ -43,6 +43,7 @@ namespace Coffee.UIEffects
private static readonly int s_EdgeWidth = Shader.PropertyToID("_EdgeWidth");
private static readonly int s_EdgeColor = Shader.PropertyToID("_EdgeColor");
private static readonly int s_EdgeShinyAutoPlaySpeed = Shader.PropertyToID("_EdgeShinyAutoPlaySpeed");
private static readonly int s_EdgeShinyRate = Shader.PropertyToID("_EdgeShinyRate");
private static readonly int s_EdgeShinyWidth = Shader.PropertyToID("_EdgeShinyWidth");
private static readonly int s_PatternArea = Shader.PropertyToID("_PatternArea");
@@ -210,6 +211,7 @@ namespace Coffee.UIEffects
public bool shadowColorGlow;
public EdgeMode edgeMode;
public float edgeShinyRate;
public float edgeWidth;
public ColorFilter edgeColorFilter;
public Color edgeColor;
@@ -292,6 +294,7 @@ namespace Coffee.UIEffects
shadowColorGlow = preset.shadowColorGlow;
edgeMode = preset.edgeMode;
edgeShinyRate = preset.edgeShinyRate;
edgeWidth = preset.edgeWidth;
edgeColorFilter = preset.edgeColorFilter;
edgeColor = preset.edgeColor;
@@ -369,6 +372,7 @@ namespace Coffee.UIEffects
material.SetFloat(s_EdgeWidth, Mathf.Clamp01(edgeWidth));
material.SetColor(s_EdgeColor, edgeColor);
material.SetFloat(s_EdgeShinyRate, Mathf.Clamp01(edgeShinyRate));
material.SetFloat(s_EdgeShinyWidth, Mathf.Clamp01(edgeShinyWidth));
material.SetFloat(s_EdgeShinyAutoPlaySpeed, edgeShinyAutoPlaySpeed);
material.SetInt(s_PatternArea, edgeMode != EdgeMode.None ? (int)patternArea : 0);
+2 -1
View File
@@ -17,7 +17,8 @@ namespace Coffee.UIEffects
Sampling = 1 << 2,
Transition = 1 << 3,
GradiationOffset = 1 << 5,
GradiationRotation = 1 << 6
GradiationRotation = 1 << 6,
EdgeShiny = 1 << 8
}
public enum UpdateMode
+2 -1
View File
@@ -27,6 +27,7 @@ uniform const float _ShadowBlurIntensity;
uniform const half4 _ShadowColor;
uniform const int _ShadowColorGlow;
uniform const float _EdgeWidth;
uniform const float _EdgeShinyRate;
uniform const float _EdgeShinyAutoPlaySpeed;
uniform const float _EdgeShinyWidth;
uniform const half4 _EdgeColor;
@@ -539,7 +540,7 @@ int is_edge_shiny(const float2 uvLocal)
{
#if EDGE_SHINY
const float deg = atan2(uvLocal.y - 0.5, uvLocal.x - 0.5) / UNITY_PI;
return frac(_Time.y * _EdgeShinyAutoPlaySpeed + deg) < _EdgeShinyWidth;
return frac(_EdgeShinyRate + _Time.y * _EdgeShinyAutoPlaySpeed + deg) < _EdgeShinyWidth;
#else
return 1;
#endif