mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-19 17:22:37 +08:00
feat: add Color Glow, Transition Color Glow and Shadow Color Glow options
This commit is contained in:
@@ -19,6 +19,7 @@ namespace Coffee.UIEffects.Editors
|
||||
private SerializedProperty _colorFilter;
|
||||
private SerializedProperty _color;
|
||||
private SerializedProperty _colorIntensity;
|
||||
private SerializedProperty _colorGlow;
|
||||
|
||||
private SerializedProperty _samplingFilter;
|
||||
private SerializedProperty _samplingIntensity;
|
||||
@@ -36,6 +37,7 @@ namespace Coffee.UIEffects.Editors
|
||||
private SerializedProperty _transitionSoftness;
|
||||
private SerializedProperty _transitionColorFilter;
|
||||
private SerializedProperty _transitionColor;
|
||||
private SerializedProperty _transitionColorGlow;
|
||||
|
||||
private SerializedProperty _targetMode;
|
||||
private SerializedProperty _targetColor;
|
||||
@@ -56,6 +58,7 @@ namespace Coffee.UIEffects.Editors
|
||||
private SerializedProperty _shadowBlurIntensity;
|
||||
private SerializedProperty _shadowColorFilter;
|
||||
private SerializedProperty _shadowColor;
|
||||
private SerializedProperty _shadowColorGlow;
|
||||
|
||||
private bool _expandOthers;
|
||||
private SerializedProperty _allowExtendVertex;
|
||||
@@ -71,6 +74,7 @@ namespace Coffee.UIEffects.Editors
|
||||
_colorFilter = serializedObject.FindProperty("m_ColorFilter");
|
||||
_color = serializedObject.FindProperty("m_Color");
|
||||
_colorIntensity = serializedObject.FindProperty("m_ColorIntensity");
|
||||
_colorGlow = serializedObject.FindProperty("m_ColorGlow");
|
||||
|
||||
_samplingFilter = serializedObject.FindProperty("m_SamplingFilter");
|
||||
_samplingIntensity = serializedObject.FindProperty("m_SamplingIntensity");
|
||||
@@ -88,6 +92,7 @@ namespace Coffee.UIEffects.Editors
|
||||
_transitionSoftness = serializedObject.FindProperty("m_TransitionSoftness");
|
||||
_transitionColorFilter = serializedObject.FindProperty("m_TransitionColorFilter");
|
||||
_transitionColor = serializedObject.FindProperty("m_TransitionColor");
|
||||
_transitionColorGlow = serializedObject.FindProperty("m_TransitionColorGlow");
|
||||
|
||||
_targetMode = serializedObject.FindProperty("m_TargetMode");
|
||||
_targetColor = serializedObject.FindProperty("m_TargetColor");
|
||||
@@ -108,6 +113,7 @@ namespace Coffee.UIEffects.Editors
|
||||
_shadowBlurIntensity = serializedObject.FindProperty("m_ShadowBlurIntensity");
|
||||
_shadowColorFilter = serializedObject.FindProperty("m_ShadowColorFilter");
|
||||
_shadowColor = serializedObject.FindProperty("m_ShadowColor");
|
||||
_shadowColorGlow = serializedObject.FindProperty("m_ShadowColorGlow");
|
||||
|
||||
_allowExtendVertex = serializedObject.FindProperty("m_AllowExtendVertex");
|
||||
}
|
||||
@@ -141,6 +147,7 @@ namespace Coffee.UIEffects.Editors
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_colorIntensity);
|
||||
DrawColor(_colorFilter, _color, prevColorFilter);
|
||||
EditorGUILayout.PropertyField(_colorGlow);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
@@ -179,6 +186,7 @@ namespace Coffee.UIEffects.Editors
|
||||
prevColorFilter = (ColorFilter)_transitionColorFilter.intValue;
|
||||
EditorGUILayout.PropertyField(_transitionColorFilter);
|
||||
DrawColor(_transitionColorFilter, _transitionColor, prevColorFilter);
|
||||
EditorGUILayout.PropertyField(_transitionColorGlow);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
@@ -237,6 +245,7 @@ namespace Coffee.UIEffects.Editors
|
||||
|
||||
EditorGUILayout.PropertyField(_shadowColorFilter);
|
||||
EditorGUILayout.PropertyField(_shadowColor);
|
||||
EditorGUILayout.PropertyField(_shadowColorGlow);
|
||||
EditorGUILayout.PropertyField(_shadowFade);
|
||||
|
||||
switch ((SamplingFilter)_samplingFilter.intValue)
|
||||
|
||||
@@ -30,6 +30,9 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
protected Color m_Color = Color.white;
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_ColorGlow = false;
|
||||
|
||||
[SerializeField]
|
||||
protected SamplingFilter m_SamplingFilter = SamplingFilter.None;
|
||||
|
||||
@@ -82,6 +85,9 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
protected Color m_TransitionColor = new Color(0f, 0.5f, 1.0f, 1.0f);
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_TransitionColorGlow = false;
|
||||
|
||||
[SerializeField]
|
||||
protected TargetMode m_TargetMode = TargetMode.None;
|
||||
|
||||
@@ -135,6 +141,9 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
protected Color m_ShadowColor = Color.white;
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_ShadowColorGlow = false;
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_AllowExtendVertex = true;
|
||||
|
||||
@@ -196,6 +205,17 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public bool colorGlow
|
||||
{
|
||||
get => m_ColorGlow;
|
||||
set
|
||||
{
|
||||
if (m_ColorGlow == value) return;
|
||||
context.colorGlow = m_ColorGlow = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
public SamplingFilter samplingFilter
|
||||
{
|
||||
get => m_SamplingFilter;
|
||||
@@ -372,6 +392,17 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public bool transitionColorGlow
|
||||
{
|
||||
get => m_TransitionColorGlow;
|
||||
set
|
||||
{
|
||||
if (m_TransitionColorGlow == value) return;
|
||||
context.transitionColorGlow = m_TransitionColorGlow = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
public TargetMode targetMode
|
||||
{
|
||||
get => m_TargetMode;
|
||||
@@ -555,6 +586,17 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public bool shadowGlow
|
||||
{
|
||||
get => m_ShadowColorGlow;
|
||||
set
|
||||
{
|
||||
if (m_ShadowColorGlow == value) return;
|
||||
context.shadowColorGlow = m_ShadowColorGlow = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
public bool allowExtendVertex
|
||||
{
|
||||
get => m_AllowExtendVertex;
|
||||
@@ -623,6 +665,7 @@ namespace Coffee.UIEffects
|
||||
c.colorFilter = m_ColorFilter;
|
||||
c.color = m_Color;
|
||||
c.colorIntensity = m_ColorIntensity;
|
||||
c.colorGlow = m_ColorGlow;
|
||||
c.samplingFilter = m_SamplingFilter;
|
||||
c.samplingIntensity = m_SamplingIntensity;
|
||||
c.transitionFilter = m_TransitionFilter;
|
||||
@@ -637,6 +680,7 @@ namespace Coffee.UIEffects
|
||||
c.transitionSoftness = m_TransitionSoftness;
|
||||
c.transitionColorFilter = m_TransitionColorFilter;
|
||||
c.transitionColor = m_TransitionColor;
|
||||
c.transitionColorGlow = m_TransitionColorGlow;
|
||||
c.targetMode = m_TargetMode;
|
||||
c.targetColor = m_TargetColor;
|
||||
c.targetRange = m_TargetRange;
|
||||
@@ -651,6 +695,7 @@ namespace Coffee.UIEffects
|
||||
c.shadowBlurIntensity = m_ShadowBlurIntensity;
|
||||
c.shadowColorFilter = m_ShadowColorFilter;
|
||||
c.shadowColor = m_ShadowColor;
|
||||
c.shadowColorGlow = m_ShadowColorGlow;
|
||||
c.allowExtendVertex = m_AllowExtendVertex;
|
||||
}
|
||||
|
||||
@@ -716,6 +761,7 @@ namespace Coffee.UIEffects
|
||||
m_ColorFilter = preset.m_ColorFilter;
|
||||
m_Color = preset.m_Color;
|
||||
m_ColorIntensity = preset.m_ColorIntensity;
|
||||
m_ColorGlow = preset.m_ColorGlow;
|
||||
|
||||
m_SamplingFilter = preset.m_SamplingFilter;
|
||||
m_SamplingIntensity = preset.m_SamplingIntensity;
|
||||
@@ -733,6 +779,7 @@ namespace Coffee.UIEffects
|
||||
m_TransitionSoftness = preset.m_TransitionSoftness;
|
||||
m_TransitionColorFilter = preset.m_TransitionColorFilter;
|
||||
m_TransitionColor = preset.m_TransitionColor;
|
||||
m_TransitionColorGlow = preset.m_TransitionColorGlow;
|
||||
|
||||
m_TargetMode = preset.m_TargetMode;
|
||||
m_TargetColor = preset.m_TargetColor;
|
||||
@@ -750,6 +797,7 @@ namespace Coffee.UIEffects
|
||||
m_ShadowBlurIntensity = preset.m_ShadowBlurIntensity;
|
||||
m_ShadowColorFilter = preset.m_ShadowColorFilter;
|
||||
m_ShadowColor = preset.m_ShadowColor;
|
||||
m_ShadowColorGlow = preset.m_ShadowColorGlow;
|
||||
|
||||
UpdateContext(context);
|
||||
ApplyContextToMaterial();
|
||||
@@ -766,6 +814,7 @@ namespace Coffee.UIEffects
|
||||
m_ColorFilter = c.colorFilter;
|
||||
m_Color = c.color;
|
||||
m_ColorIntensity = c.colorIntensity;
|
||||
m_ColorGlow = c.colorGlow;
|
||||
|
||||
m_SamplingFilter = c.samplingFilter;
|
||||
m_SamplingIntensity = c.samplingIntensity;
|
||||
@@ -782,6 +831,7 @@ namespace Coffee.UIEffects
|
||||
m_TransitionSoftness = c.transitionSoftness;
|
||||
m_TransitionColorFilter = c.transitionColorFilter;
|
||||
m_TransitionColor = c.transitionColor;
|
||||
m_TransitionColorGlow = c.transitionColorGlow;
|
||||
|
||||
m_TargetMode = c.targetMode;
|
||||
m_TargetColor = c.targetColor;
|
||||
@@ -800,6 +850,7 @@ namespace Coffee.UIEffects
|
||||
m_ShadowBlurIntensity = c.shadowBlurIntensity;
|
||||
m_ShadowColorFilter = c.shadowColorFilter;
|
||||
m_ShadowColor = c.shadowColor;
|
||||
m_ShadowColorGlow = c.shadowColorGlow;
|
||||
|
||||
m_AllowExtendVertex = c.allowExtendVertex;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Coffee.UIEffects
|
||||
private static readonly int s_ToneParams = Shader.PropertyToID("_ToneParams");
|
||||
private static readonly int s_ColorValue = Shader.PropertyToID("_ColorValue");
|
||||
private static readonly int s_ColorIntensity = Shader.PropertyToID("_ColorIntensity");
|
||||
private static readonly int s_ColorGlow = Shader.PropertyToID("_ColorGlow");
|
||||
private static readonly int s_SamplingIntensity = Shader.PropertyToID("_SamplingIntensity");
|
||||
private static readonly int s_SamplingScale = Shader.PropertyToID("_SamplingScale");
|
||||
private static readonly int s_TransitionRate = Shader.PropertyToID("_TransitionRate");
|
||||
@@ -28,11 +29,13 @@ namespace Coffee.UIEffects
|
||||
private static readonly int s_TransitionSoftness = Shader.PropertyToID("_TransitionSoftness");
|
||||
private static readonly int s_TransitionColorFilter = Shader.PropertyToID("_TransitionColorFilter");
|
||||
private static readonly int s_TransitionColor = Shader.PropertyToID("_TransitionColor");
|
||||
private static readonly int s_TransitionColorGlow = Shader.PropertyToID("_TransitionColorGlow");
|
||||
private static readonly int s_TargetColor = Shader.PropertyToID("_TargetColor");
|
||||
private static readonly int s_TargetRange = Shader.PropertyToID("_TargetRange");
|
||||
private static readonly int s_TargetSoftness = Shader.PropertyToID("_TargetSoftness");
|
||||
private static readonly int s_ShadowColor = Shader.PropertyToID("_ShadowColor");
|
||||
private static readonly int s_ShadowBlurIntensity = Shader.PropertyToID("_ShadowBlurIntensity");
|
||||
private static readonly int s_ShadowColorGlow = Shader.PropertyToID("_ShadowColorGlow");
|
||||
|
||||
private static readonly string[] s_ToneKeywords =
|
||||
{
|
||||
@@ -135,6 +138,7 @@ namespace Coffee.UIEffects
|
||||
public ColorFilter colorFilter = ColorFilter.None;
|
||||
public float colorIntensity = 1;
|
||||
public Color color = Color.white;
|
||||
public bool colorGlow;
|
||||
|
||||
public SamplingFilter samplingFilter = SamplingFilter.None;
|
||||
public float samplingIntensity = 0.5f;
|
||||
@@ -151,6 +155,7 @@ namespace Coffee.UIEffects
|
||||
public float transitionSoftness = 0.2f;
|
||||
public ColorFilter transitionColorFilter = ColorFilter.MultiplyAdditive;
|
||||
public Color transitionColor = new Color(0f, 0.5f, 1.0f, 1.0f);
|
||||
public bool transitionColorGlow;
|
||||
|
||||
public TargetMode targetMode = TargetMode.None;
|
||||
public Color targetColor = Color.white;
|
||||
@@ -168,6 +173,7 @@ namespace Coffee.UIEffects
|
||||
public float shadowBlurIntensity;
|
||||
public ColorFilter shadowColorFilter;
|
||||
public Color shadowColor;
|
||||
public bool shadowColorGlow;
|
||||
|
||||
public bool allowExtendVertex;
|
||||
|
||||
@@ -194,6 +200,7 @@ namespace Coffee.UIEffects
|
||||
colorFilter = preset.colorFilter;
|
||||
color = preset.color;
|
||||
colorIntensity = preset.colorIntensity;
|
||||
colorGlow = preset.colorGlow;
|
||||
|
||||
samplingFilter = preset.samplingFilter;
|
||||
samplingIntensity = preset.samplingIntensity;
|
||||
@@ -210,6 +217,7 @@ namespace Coffee.UIEffects
|
||||
transitionSoftness = preset.transitionSoftness;
|
||||
transitionColor = preset.transitionColor;
|
||||
transitionColorFilter = preset.transitionColorFilter;
|
||||
transitionColorGlow = preset.transitionColorGlow;
|
||||
|
||||
targetMode = preset.targetMode;
|
||||
targetColor = preset.targetColor;
|
||||
@@ -227,6 +235,7 @@ namespace Coffee.UIEffects
|
||||
shadowBlurIntensity = preset.shadowBlurIntensity;
|
||||
shadowColorFilter = preset.shadowColorFilter;
|
||||
shadowColor = preset.shadowColor;
|
||||
shadowColorGlow = preset.shadowColorGlow;
|
||||
|
||||
allowExtendVertex = preset.allowExtendVertex;
|
||||
}
|
||||
@@ -245,6 +254,7 @@ namespace Coffee.UIEffects
|
||||
|
||||
material.SetColor(s_ColorValue, color);
|
||||
material.SetFloat(s_ColorIntensity, Mathf.Clamp01(colorIntensity));
|
||||
material.SetInt(s_ColorGlow, colorGlow ? 1 : 0);
|
||||
|
||||
material.SetFloat(s_SamplingIntensity, Mathf.Clamp01(samplingIntensity));
|
||||
material.SetFloat(s_SamplingScale, actualSamplingScale);
|
||||
@@ -259,6 +269,7 @@ namespace Coffee.UIEffects
|
||||
material.SetFloat(s_TransitionSoftness, Mathf.Clamp01(transitionSoftness));
|
||||
material.SetInt(s_TransitionColorFilter, (int)transitionColorFilter);
|
||||
material.SetColor(s_TransitionColor, transitionColor);
|
||||
material.SetInt(s_TransitionColorGlow, transitionColorGlow ? 1 : 0);
|
||||
|
||||
material.SetColor(s_TargetColor, targetColor);
|
||||
material.SetFloat(s_TargetRange, Mathf.Clamp01(targetRange));
|
||||
@@ -277,6 +288,7 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
|
||||
material.SetColor(s_ShadowColor, shadowColor);
|
||||
material.SetInt(s_ShadowColorGlow, shadowColorGlow ? 1 : 0);
|
||||
|
||||
SetKeyword(material, s_ToneKeywords, (int)toneFilter);
|
||||
SetKeyword(material, s_ColorKeywords, (int)colorFilter);
|
||||
|
||||
@@ -5,6 +5,7 @@ uniform float4 _MainTex_TexelSize;
|
||||
uniform float _ToneIntensity;
|
||||
uniform half4 _ColorValue;
|
||||
uniform float _ColorIntensity;
|
||||
uniform int _ColorGlow;
|
||||
uniform float _SamplingIntensity;
|
||||
uniform float _SamplingScale;
|
||||
uniform sampler2D _TransitionTex;
|
||||
@@ -12,6 +13,7 @@ uniform float4 _TransitionTex_ST;
|
||||
uniform float _TransitionRate;
|
||||
uniform int _TransitionReverse;
|
||||
uniform half4 _TransitionColor;
|
||||
uniform int _TransitionColorGlow;
|
||||
uniform float _TransitionSoftness;
|
||||
uniform float _TransitionWidth;
|
||||
uniform fixed4 _TargetColor;
|
||||
@@ -19,6 +21,7 @@ uniform float _TargetRange;
|
||||
uniform float _TargetSoftness;
|
||||
uniform float _ShadowBlurIntensity;
|
||||
uniform half4 _ShadowColor;
|
||||
uniform int _ShadowColorGlow;
|
||||
|
||||
// For performance reasons, limit the sampling of blur in TextMeshPro.
|
||||
#ifdef UIEFFECT_TEXTMESHPRO
|
||||
@@ -180,6 +183,7 @@ half4 apply_color_filter(half4 color, const half4 factor, const float intensity)
|
||||
}
|
||||
#endif
|
||||
color = lerp(inColor, color, intensity);
|
||||
color.a *= 1 - _ColorGlow;
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -227,6 +231,7 @@ half4 apply_transition_color_filter(half4 color, const half4 factor, const float
|
||||
}
|
||||
#endif
|
||||
color = lerp(inColor, color, intensity);
|
||||
color.a *= 1 - _TransitionColorGlow;
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -278,6 +283,7 @@ half4 apply_shadow_color_filter(half4 color, const half4 factor, const float int
|
||||
}
|
||||
#endif
|
||||
color = lerp(inColor, color, intensity);
|
||||
color.a *= 1 - _ShadowColorGlow;
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user