mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-19 17:22:37 +08:00
feat: add EdgeColorGlow option
This commit is contained in:
@@ -96,6 +96,7 @@ namespace Coffee.UIEffects.Editors
|
||||
private SerializedProperty _edgeWidth;
|
||||
private SerializedProperty _edgeColorFilter;
|
||||
private SerializedProperty _edgeColor;
|
||||
private SerializedProperty _edgeColorGlow;
|
||||
private SerializedProperty _edgeShinyRate;
|
||||
private SerializedProperty _edgeShinyWidth;
|
||||
private SerializedProperty _edgeShinyAutoPlaySpeed;
|
||||
@@ -170,6 +171,7 @@ namespace Coffee.UIEffects.Editors
|
||||
_edgeWidth = serializedObject.FindProperty("m_EdgeWidth");
|
||||
_edgeColorFilter = serializedObject.FindProperty("m_EdgeColorFilter");
|
||||
_edgeColor = serializedObject.FindProperty("m_EdgeColor");
|
||||
_edgeColorGlow = serializedObject.FindProperty("m_EdgeColorGlow");
|
||||
_edgeShinyRate = serializedObject.FindProperty("m_EdgeShinyRate");
|
||||
_edgeShinyWidth = serializedObject.FindProperty("m_EdgeShinyWidth");
|
||||
_edgeShinyAutoPlaySpeed = serializedObject.FindProperty("m_EdgeShinyAutoPlaySpeed");
|
||||
@@ -397,7 +399,7 @@ namespace Coffee.UIEffects.Editors
|
||||
if (DrawHeaderPopup(_edgeMode))
|
||||
{
|
||||
EditorGUILayout.PropertyField(_edgeWidth);
|
||||
DrawColor(_edgeColorFilter, _edgeColor, null);
|
||||
DrawColor(_edgeColorFilter, _edgeColor, _edgeColorGlow);
|
||||
|
||||
if ((EdgeMode)_edgeMode.intValue == EdgeMode.Shiny)
|
||||
{
|
||||
|
||||
@@ -205,6 +205,9 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
protected Color m_EdgeColor = Color.white;
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_EdgeColorGlow = false;
|
||||
|
||||
[Range(0, 1)]
|
||||
[SerializeField]
|
||||
protected float m_EdgeShinyRate = 0.5f;
|
||||
@@ -1075,6 +1078,17 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public bool edgeColorGlow
|
||||
{
|
||||
get => m_EdgeColorGlow;
|
||||
set
|
||||
{
|
||||
if (m_EdgeColorGlow == value) return;
|
||||
context.edgeColorGlow = m_EdgeColorGlow = value;
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public float edgeShinyWidth
|
||||
{
|
||||
get => m_EdgeShinyWidth;
|
||||
@@ -1367,6 +1381,7 @@ namespace Coffee.UIEffects
|
||||
c.edgeWidth = m_EdgeWidth;
|
||||
c.edgeColorFilter = m_EdgeColorFilter;
|
||||
c.edgeColor = m_EdgeColor;
|
||||
c.edgeColorGlow = m_EdgeColorGlow;
|
||||
c.edgeShinyWidth = m_EdgeShinyWidth;
|
||||
c.edgeShinyAutoPlaySpeed = m_EdgeShinyAutoPlaySpeed;
|
||||
c.patternArea = m_PatternArea;
|
||||
@@ -1555,6 +1570,7 @@ namespace Coffee.UIEffects
|
||||
m_EdgeWidth = preset.m_EdgeWidth;
|
||||
m_EdgeColorFilter = preset.m_EdgeColorFilter;
|
||||
m_EdgeColor = preset.m_EdgeColor;
|
||||
m_EdgeColorGlow = preset.m_EdgeColorGlow;
|
||||
m_EdgeShinyWidth = preset.m_EdgeShinyWidth;
|
||||
m_EdgeShinyAutoPlaySpeed = preset.m_EdgeShinyAutoPlaySpeed;
|
||||
m_PatternArea = preset.m_PatternArea;
|
||||
@@ -1637,6 +1653,7 @@ namespace Coffee.UIEffects
|
||||
m_EdgeWidth = c.edgeWidth;
|
||||
m_EdgeColorFilter = c.edgeColorFilter;
|
||||
m_EdgeColor = c.edgeColor;
|
||||
m_EdgeColorGlow = c.edgeColorGlow;
|
||||
m_EdgeShinyWidth = c.edgeShinyWidth;
|
||||
m_EdgeShinyAutoPlaySpeed = c.edgeShinyAutoPlaySpeed;
|
||||
m_PatternArea = c.patternArea;
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Coffee.UIEffects
|
||||
private static readonly int s_ShadowColorGlow = Shader.PropertyToID("_ShadowColorGlow");
|
||||
private static readonly int s_EdgeWidth = Shader.PropertyToID("_EdgeWidth");
|
||||
private static readonly int s_EdgeColor = Shader.PropertyToID("_EdgeColor");
|
||||
private static readonly int s_EdgeColorGlow = Shader.PropertyToID("_EdgeColorGlow");
|
||||
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");
|
||||
@@ -217,6 +218,7 @@ namespace Coffee.UIEffects
|
||||
public float edgeWidth;
|
||||
public ColorFilter edgeColorFilter;
|
||||
public Color edgeColor;
|
||||
public bool edgeColorGlow;
|
||||
public float edgeShinyWidth;
|
||||
public float edgeShinyAutoPlaySpeed;
|
||||
public PatternArea patternArea;
|
||||
@@ -306,6 +308,7 @@ namespace Coffee.UIEffects
|
||||
edgeWidth = preset.edgeWidth;
|
||||
edgeColorFilter = preset.edgeColorFilter;
|
||||
edgeColor = preset.edgeColor;
|
||||
edgeColorGlow = preset.edgeColorGlow;
|
||||
edgeShinyAutoPlaySpeed = preset.edgeShinyAutoPlaySpeed;
|
||||
edgeShinyWidth = preset.edgeShinyWidth;
|
||||
patternArea = preset.patternArea;
|
||||
@@ -383,6 +386,7 @@ namespace Coffee.UIEffects
|
||||
|
||||
material.SetFloat(s_EdgeWidth, Mathf.Clamp01(edgeWidth));
|
||||
material.SetColor(s_EdgeColor, edgeColor);
|
||||
material.SetInt(s_EdgeColorGlow, edgeColorGlow ? 1 : 0);
|
||||
material.SetFloat(s_EdgeShinyRate, Mathf.Clamp01(edgeShinyRate));
|
||||
material.SetFloat(s_EdgeShinyWidth, Mathf.Clamp01(edgeShinyWidth));
|
||||
material.SetFloat(s_EdgeShinyAutoPlaySpeed, edgeShinyAutoPlaySpeed);
|
||||
|
||||
@@ -34,6 +34,7 @@ uniform const float _EdgeShinyRate;
|
||||
uniform const float _EdgeShinyAutoPlaySpeed;
|
||||
uniform const float _EdgeShinyWidth;
|
||||
uniform const half4 _EdgeColor;
|
||||
uniform const int _EdgeColorGlow;
|
||||
uniform const int _PatternArea;
|
||||
|
||||
// For performance reasons, limit the sampling of blur in TextMeshPro.
|
||||
@@ -366,6 +367,7 @@ half4 apply_edge_color_filter(half4 color, const half4 factor, const float inten
|
||||
}
|
||||
#endif
|
||||
color = lerp(inColor, color, intensity);
|
||||
color.a *= 1 - _EdgeColorGlow * intensity;
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user