mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-20 01:42:37 +08:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9380f96572 | |||
| b4adb32512 | |||
| 59874ddffe | |||
| c4202b45d2 | |||
| ce692580a3 | |||
| 6c808aa341 | |||
| a975cf347a | |||
| 3207105a06 | |||
| 4cca2fb5ab | |||
| d1adb33884 | |||
| b077d97ed7 | |||
| 6f90044ec8 | |||
| 83128ebb09 | |||
| 9dffdb0ed8 | |||
| 16be53e145 | |||
| fd2d1b8059 | |||
| cf43bfffb9 | |||
| a2f4a2d5c9 | |||
| 0d7fb1eb63 | |||
| 145f56968a | |||
| cadbb8d68d | |||
| a0c3e4997a | |||
| ec57c2a994 | |||
| 804b48c73e |
@@ -1,3 +1,65 @@
|
||||
# [5.10.0](https://github.com/mob-sakai/UIEffect/compare/5.9.7...5.10.0) (2025-09-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `TmpProxy` causes loss of modifications from other `IMeshModifiers` ([c4202b4](https://github.com/mob-sakai/UIEffect/commit/c4202b45d28fa84567a5671baaef8fa3e3df85dc)), closes [#371](https://github.com/mob-sakai/UIEffect/issues/371)
|
||||
* display may disappear when using TMP SubMesh (multi-language or sprites, etc.) ([b4adb32](https://github.com/mob-sakai/UIEffect/commit/b4adb325120eeed64af1d9cb2468a1e1e8e10812)), closes [#372](https://github.com/mob-sakai/UIEffect/issues/372)
|
||||
* TMP Text sprite submesh lost when changing fontMaterial ([59874dd](https://github.com/mob-sakai/UIEffect/commit/59874ddffe356f927dc8ff9b157c54043e149522)), closes [#368](https://github.com/mob-sakai/UIEffect/issues/368)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* [improve performance] merged apply_color function and reduced shader compilation size ([ce69258](https://github.com/mob-sakai/UIEffect/commit/ce692580a33c0c433fd7fadb64a3dcda0121b2ff))
|
||||
* [improve performance] various view matrices are only updated when necessary ([6c808aa](https://github.com/mob-sakai/UIEffect/commit/6c808aa3417450fd1ce0fc6fbfe0adffdff9a79a))
|
||||
|
||||
## [5.9.7](https://github.com/mob-sakai/UIEffect/compare/5.9.6...5.9.7) (2025-09-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* edges of `TransitionFilter.Shiny` appear sharp ([b077d97](https://github.com/mob-sakai/UIEffect/commit/b077d97ed706acbbdd3b20e765ec0552fa464f9b)), closes [#366](https://github.com/mob-sakai/UIEffect/issues/366)
|
||||
* error message sometimes after importing assets ([3207105](https://github.com/mob-sakai/UIEffect/commit/3207105a067801696de789d282c74a93b798ed57)), closes [#365](https://github.com/mob-sakai/UIEffect/issues/365)
|
||||
* flickering issue when scale Y changes when used `ShadowMode` with TextMeshPro ([4cca2fb](https://github.com/mob-sakai/UIEffect/commit/4cca2fb5ab34ea454ff8df3def5f1730a71a198c)), closes [#367](https://github.com/mob-sakai/UIEffect/issues/367)
|
||||
* skip monitoring TMP objects that can ignore Y-axis scaling ([d1adb33](https://github.com/mob-sakai/UIEffect/commit/d1adb33884971aa7d6c473fcd08cdf25e58cd261))
|
||||
|
||||
## [5.9.6](https://github.com/mob-sakai/UIEffect/compare/5.9.5...5.9.6) (2025-07-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `ColorFilter` does not output intended color when vertex color is not white ([9dffdb0](https://github.com/mob-sakai/UIEffect/commit/9dffdb0ed88750a915fdd5e437b79ab766ce45c2)), closes [#363](https://github.com/mob-sakai/UIEffect/issues/363)
|
||||
* draw calls increase even when using `UIEffectReplica` ([83128eb](https://github.com/mob-sakai/UIEffect/commit/83128ebb09305e4c15a58968a94550179e96ffac)), closes [#364](https://github.com/mob-sakai/UIEffect/issues/364)
|
||||
|
||||
## [5.9.5](https://github.com/mob-sakai/UIEffect/compare/5.9.4...5.9.5) (2025-06-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `GetGradientKeys` and `GetTransitionGradientKeys` cannot get GradientMode ([fd2d1b8](https://github.com/mob-sakai/UIEffect/commit/fd2d1b80592ac4ea62e15b6150be63964b113fa2)), closes [#358](https://github.com/mob-sakai/UIEffect/issues/358)
|
||||
|
||||
## [5.9.4](https://github.com/mob-sakai/UIEffect/compare/5.9.3...5.9.4) (2025-06-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* colors specified in UIEffect are output differently in linear color space ([0d7fb1e](https://github.com/mob-sakai/UIEffect/commit/0d7fb1eb63881b67f2658567750a83c92187df35)), closes [#359](https://github.com/mob-sakai/UIEffect/issues/359)
|
||||
|
||||
## [5.9.3](https://github.com/mob-sakai/UIEffect/compare/5.9.2...5.9.3) (2025-06-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add `GetGradientKeys` and `GetTransitionGradientKeys` APIs ([a0c3e49](https://github.com/mob-sakai/UIEffect/commit/a0c3e4997af181ae16744c53ad3867e2106ccff3)), closes [#358](https://github.com/mob-sakai/UIEffect/issues/358)
|
||||
* support world canvas without UI events ([cadbb8d](https://github.com/mob-sakai/UIEffect/commit/cadbb8d68d17a2ec7e2d6e8e885d711e61fa53af)), closes [#356](https://github.com/mob-sakai/UIEffect/issues/356) [#357](https://github.com/mob-sakai/UIEffect/issues/357)
|
||||
|
||||
## [5.9.2](https://github.com/mob-sakai/UIEffect/compare/5.9.1...5.9.2) (2025-06-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* TextMeshPro 3.2.0-pre support ([804b48c](https://github.com/mob-sakai/UIEffect/commit/804b48c73ec648eaceb720cb79551fdbf3729fc9)), closes [#355](https://github.com/mob-sakai/UIEffect/issues/355)
|
||||
|
||||
## [5.9.1](https://github.com/mob-sakai/UIEffect/compare/5.9.0...5.9.1) (2025-06-11)
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,11 @@
|
||||
"name": "com.unity.timeline",
|
||||
"expression": "1.0.0",
|
||||
"define": "TIMELINE_ENABLE"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.textmeshpro",
|
||||
"expression": "[1.0.0,3.2.0-pre.1)",
|
||||
"define": "LEGACY_TMP_ENABLE"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
|
||||
@@ -112,8 +112,10 @@ namespace Coffee.UIEffects
|
||||
Vertical = 3,
|
||||
VerticalGradient = 4,
|
||||
Radial = 5,
|
||||
|
||||
[Obsolete]
|
||||
RadialFast = 5,
|
||||
|
||||
[Obsolete]
|
||||
RadialDetail = 6,
|
||||
RadialGradient = 12,
|
||||
|
||||
@@ -158,6 +158,8 @@ namespace Coffee.UIEffectInternal
|
||||
|
||||
private void OnPlayModeStateChanged(PlayModeStateChange state)
|
||||
{
|
||||
if (!this) return;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case PlayModeStateChange.ExitingEditMode:
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Coffee.UIEffectInternal
|
||||
{
|
||||
@@ -67,7 +68,15 @@ namespace Coffee.UIEffectInternal
|
||||
if (s_IsInitializedAfterCanvasRebuild) return;
|
||||
s_IsInitializedAfterCanvasRebuild = true;
|
||||
|
||||
// Explicitly set `Canvas.willRenderCanvases += CanvasUpdateRegistry.PerformUpdate`.
|
||||
CanvasUpdateRegistry.IsRebuildingLayout();
|
||||
#if TMP_ENABLE
|
||||
// Explicitly set `Canvas.willRenderCanvases += TMP_UpdateManager.DoRebuilds`.
|
||||
typeof(TMPro.TMP_UpdateManager)
|
||||
.GetProperty("instance", BindingFlags.NonPublic | BindingFlags.Static)
|
||||
.GetValue(null);
|
||||
#endif
|
||||
Canvas.willRenderCanvases -= OnAfterCanvasRebuild;
|
||||
Canvas.willRenderCanvases += OnAfterCanvasRebuild;
|
||||
Logging.LogMulticast(typeof(Canvas), "willRenderCanvases",
|
||||
message: "InitializeAfterCanvasRebuild");
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
// #if TIMELINE_ENABLE
|
||||
// using System;
|
||||
// using System.ComponentModel;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace Coffee.UIEffects.Timeline
|
||||
// {
|
||||
// [DisplayName("Clip")]
|
||||
// public class UIEffectFloat01Clip : UIEffectClip<UIEffectFloatBehaviour>
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// // [Serializable]
|
||||
// // public class UIEffectFloat01Behaviour : UIEffectFloatBehaviour
|
||||
// // {
|
||||
// // [Range(0, 1)]
|
||||
// // public float m_Value = 1;
|
||||
// //
|
||||
// // [Range(0, 1)]
|
||||
// // public float m_From = 1;
|
||||
// //
|
||||
// // protected override float from => m_From;
|
||||
// // protected override float value => m_Value;
|
||||
// // }
|
||||
//
|
||||
// // public class UIEffectFloatBehaviour : UIEffectBehaviour, IGetValue<float>
|
||||
// // {
|
||||
// // protected virtual float value { get; }
|
||||
// // protected virtual float from { get; }
|
||||
// //
|
||||
// // public float Get(float time)
|
||||
// // {
|
||||
// // return m_Tween
|
||||
// // ? Mathf.Lerp(from, value, m_Curve.Evaluate(time))
|
||||
// // : value;
|
||||
// // }
|
||||
// // }
|
||||
// //
|
||||
// // public abstract class UIEffectFloatMixerBehaviour : UIEffectMixerBehaviour<float, UIEffectFloatBehaviour>
|
||||
// // {
|
||||
// // protected override float Add(float baseValue, float value, float weight)
|
||||
// // {
|
||||
// // return baseValue + value * weight;
|
||||
// // }
|
||||
// //
|
||||
// // protected override float Lerp(float defaultValue, float value, float weight)
|
||||
// // {
|
||||
// // return Mathf.Lerp(defaultValue, value, weight);
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// #endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: deea59e7cd34449c89e7c1f6438a5392
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -76,7 +76,6 @@ namespace Coffee.UIEffects.Timeline
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1519,6 +1519,17 @@ namespace Coffee.UIEffects
|
||||
SetGradientKeys(gradient.colorKeys, gradient.alphaKeys, gradient.mode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get gradation gradient's keys.
|
||||
/// </summary>
|
||||
public void GetGradientKeys(out GradientColorKey[] colorKeys, out GradientAlphaKey[] alphaKeys,
|
||||
out GradientMode mode)
|
||||
{
|
||||
colorKeys = m_GradationGradient?.colorKeys ?? Array.Empty<GradientColorKey>();
|
||||
alphaKeys = m_GradationGradient?.alphaKeys ?? Array.Empty<GradientAlphaKey>();
|
||||
mode = m_GradationGradient?.mode ?? GradientMode.Blend;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set transition gradient's keys.
|
||||
/// </summary>
|
||||
@@ -1527,6 +1538,17 @@ namespace Coffee.UIEffects
|
||||
SetTransitionGradientKeys(gradient.colorKeys, gradient.alphaKeys, gradient.mode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get transition gradation gradient's keys.
|
||||
/// </summary>
|
||||
public void GetTransitionGradientKeys(out GradientColorKey[] colorKeys, out GradientAlphaKey[] alphaKeys,
|
||||
out GradientMode mode)
|
||||
{
|
||||
colorKeys = m_TransitionGradient?.colorKeys ?? Array.Empty<GradientColorKey>();
|
||||
alphaKeys = m_TransitionGradient?.alphaKeys ?? Array.Empty<GradientAlphaKey>();
|
||||
mode = m_TransitionGradient?.mode ?? GradientMode.Blend;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set gradation gradient's keys.
|
||||
/// </summary>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Coffee.UIEffects
|
||||
[DisallowMultipleComponent]
|
||||
public abstract class UIEffectBase : UIBehaviour, IMeshModifier, IMaterialModifier, ICanvasRaycastFilter
|
||||
#if TIMELINE_ENABLE
|
||||
,ITimeControl
|
||||
, ITimeControl
|
||||
#endif
|
||||
{
|
||||
private static readonly InternalObjectPool<UIEffectContext> s_ContextPool =
|
||||
@@ -117,6 +117,7 @@ namespace Coffee.UIEffects
|
||||
protected virtual void OnAfterCanvasRebuild()
|
||||
{
|
||||
if (!_material || !graphic || !graphic.canvas || context == null) return;
|
||||
if (!context.useViewMatrix) return;
|
||||
|
||||
context.UpdateViewMatrix(GetCurrentMaterial(), transitionRoot, graphic.canvas.rootCanvas);
|
||||
}
|
||||
|
||||
@@ -258,6 +258,11 @@ namespace Coffee.UIEffects
|
||||
|
||||
public bool willModifyVertex => willModifyMaterial;
|
||||
|
||||
public bool useViewMatrix => m_TransitionFilter != TransitionFilter.None
|
||||
|| m_GradationMode != GradationMode.None
|
||||
|| m_DetailFilter != DetailFilter.None
|
||||
|| m_EdgeMode == EdgeMode.Shiny;
|
||||
|
||||
private Texture2D _gradationRampTex;
|
||||
private Texture2D _transitionRampTex;
|
||||
private bool _isGradientDirty = true;
|
||||
@@ -294,7 +299,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
var x = m_GradationReverse ? w - 1 - i : i;
|
||||
var t = (float)i / (w - 1);
|
||||
s_Colors[x] = m_GradationGradient.Evaluate(t);
|
||||
s_Colors[x] = ApplyColorSpace(m_GradationGradient.Evaluate(t));
|
||||
}
|
||||
|
||||
_gradationRampTex.wrapMode = m_GradationWrapMode;
|
||||
@@ -320,7 +325,7 @@ namespace Coffee.UIEffects
|
||||
for (var i = 0; i < w; i++)
|
||||
{
|
||||
var t = (float)i / (w - 1);
|
||||
s_Colors[i] = m_TransitionGradient.Evaluate(t);
|
||||
s_Colors[i] = ApplyColorSpace(m_TransitionGradient.Evaluate(t));
|
||||
}
|
||||
|
||||
s_Colors[w - 1].a = 0;
|
||||
@@ -454,7 +459,7 @@ namespace Coffee.UIEffects
|
||||
material.SetFloat(s_ToneIntensity, Mathf.Clamp01(m_ToneIntensity));
|
||||
|
||||
material.SetInt(s_ColorFilter, (int)m_ColorFilter);
|
||||
material.SetColor(s_ColorValue, m_Color);
|
||||
material.SetColor(s_ColorValue, ApplyColorSpace(m_Color));
|
||||
material.SetFloat(s_ColorIntensity, Mathf.Clamp01(m_ColorIntensity));
|
||||
material.SetInt(s_ColorGlow, m_ColorGlow ? 1 : 0);
|
||||
|
||||
@@ -473,14 +478,14 @@ namespace Coffee.UIEffects
|
||||
material.SetFloat(s_TransitionSoftness, Mathf.Clamp01(m_TransitionSoftness));
|
||||
material.SetVector(s_TransitionRange, new Vector2(m_TransitionRange.min, m_TransitionRange.max));
|
||||
material.SetInt(s_TransitionColorFilter, (int)m_TransitionColorFilter);
|
||||
material.SetColor(s_TransitionColor, m_TransitionColor);
|
||||
material.SetColor(s_TransitionColor, ApplyColorSpace(m_TransitionColor));
|
||||
material.SetInt(s_TransitionColorGlow, m_TransitionColorGlow ? 1 : 0);
|
||||
material.SetInt(s_TransitionPatternReverse, m_TransitionPatternReverse ? 1 : 0);
|
||||
material.SetFloat(s_TransitionAutoPlaySpeed, m_TransitionAutoPlaySpeed);
|
||||
material.SetTexture(s_TransitionGradientTex,
|
||||
m_TransitionFilter == TransitionFilter.Blaze ? transitionRampTex : null);
|
||||
|
||||
material.SetColor(s_TargetColor, m_TargetColor);
|
||||
material.SetColor(s_TargetColor, ApplyColorSpace(m_TargetColor));
|
||||
material.SetFloat(s_TargetRange, Mathf.Clamp01(m_TargetRange));
|
||||
material.SetFloat(s_TargetSoftness, Mathf.Clamp01(m_TargetSoftness));
|
||||
|
||||
@@ -497,12 +502,12 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
|
||||
material.SetInt(s_ShadowColorFilter, (int)m_ShadowColorFilter);
|
||||
material.SetColor(s_ShadowColor, m_ShadowColor);
|
||||
material.SetColor(s_ShadowColor, ApplyColorSpace(m_ShadowColor));
|
||||
material.SetInt(s_ShadowColorGlow, m_ShadowColorGlow ? 1 : 0);
|
||||
|
||||
material.SetFloat(s_EdgeWidth, Mathf.Clamp01(m_EdgeWidth));
|
||||
material.SetInt(s_EdgeColorFilter, (int)m_EdgeColorFilter);
|
||||
material.SetColor(s_EdgeColor, m_EdgeColor);
|
||||
material.SetColor(s_EdgeColor, ApplyColorSpace(m_EdgeColor));
|
||||
material.SetInt(s_EdgeColorGlow, m_EdgeColorGlow ? 1 : 0);
|
||||
material.SetFloat(s_EdgeShinyRate, Mathf.Clamp01(m_EdgeShinyRate));
|
||||
material.SetFloat(s_EdgeShinyWidth, Mathf.Clamp01(m_EdgeShinyWidth));
|
||||
@@ -514,10 +519,10 @@ namespace Coffee.UIEffects
|
||||
|
||||
material.SetFloat(s_GradationIntensity, m_GradationIntensity);
|
||||
material.SetInt(s_GradationColorFilter, (int)m_GradationColorFilter);
|
||||
material.SetColor(s_GradationColor1, m_GradationColor1);
|
||||
material.SetColor(s_GradationColor2, m_GradationColor2);
|
||||
material.SetColor(s_GradationColor3, m_GradationColor3);
|
||||
material.SetColor(s_GradationColor4, m_GradationColor4);
|
||||
material.SetColor(s_GradationColor1, ApplyColorSpace(m_GradationColor1));
|
||||
material.SetColor(s_GradationColor2, ApplyColorSpace(m_GradationColor2));
|
||||
material.SetColor(s_GradationColor3, ApplyColorSpace(m_GradationColor3));
|
||||
material.SetColor(s_GradationColor4, ApplyColorSpace(m_GradationColor4));
|
||||
material.SetInt(s_GradationRadial, m_GradationMode == GradationMode.Radial
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
|| m_GradationMode == GradationMode.RadialDetail
|
||||
@@ -525,7 +530,7 @@ namespace Coffee.UIEffects
|
||||
|| m_GradationMode == GradationMode.RadialGradient ? 1 : 0);
|
||||
|
||||
material.SetFloat(s_DetailIntensity, Mathf.Clamp01(m_DetailIntensity));
|
||||
material.SetColor(s_DetailColor, m_DetailColor);
|
||||
material.SetColor(s_DetailColor, ApplyColorSpace(m_DetailColor));
|
||||
material.SetVector(s_DetailThreshold, new Vector2(m_DetailThreshold.min, m_DetailThreshold.max));
|
||||
material.SetTexture(s_DetailTex, m_DetailFilter != 0 ? m_DetailTex : null);
|
||||
material.SetVector(s_DetailTex_ST,
|
||||
@@ -623,7 +628,11 @@ namespace Coffee.UIEffects
|
||||
* Matrix4x4.TRS(mirrorOffset, Quaternion.identity, mirrorScale) * w2LMat);
|
||||
}
|
||||
|
||||
if (canvas.renderMode == RenderMode.ScreenSpaceOverlay || !canvas.worldCamera)
|
||||
if (canvas.renderMode == RenderMode.WorldSpace)
|
||||
{
|
||||
material.SetMatrix(s_CanvasToWorldMatrix, Matrix4x4.identity);
|
||||
}
|
||||
else if (canvas.renderMode == RenderMode.ScreenSpaceOverlay || !canvas.worldCamera)
|
||||
{
|
||||
material.SetMatrix(s_CanvasToWorldMatrix, canvas.transform.localToWorldMatrix);
|
||||
}
|
||||
@@ -830,5 +839,10 @@ namespace Coffee.UIEffects
|
||||
|
||||
return expandSize;
|
||||
}
|
||||
|
||||
private static Color ApplyColorSpace(Color color)
|
||||
{
|
||||
return QualitySettings.activeColorSpace == ColorSpace.Linear ? color.linear : color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Coffee.UIEffects
|
||||
[InitializeOnLoadMethod]
|
||||
private static void InitializeOnLoadMethod()
|
||||
{
|
||||
#if UNITY_2023_2_OR_NEWER
|
||||
#if !LEGACY_TMP_ENABLE
|
||||
const string tmpSupport = "TextMeshPro Support (Unity 6)";
|
||||
const string version = "v5.9.0 (Unity 6)";
|
||||
#else
|
||||
|
||||
@@ -99,7 +99,12 @@ namespace Coffee.UIEffects
|
||||
|
||||
public override bool canModifyShape => m_AllowToModifyMeshShape;
|
||||
|
||||
public override uint effectId => target ? target.effectId : 0;
|
||||
public override uint effectId => target
|
||||
? target.effectId
|
||||
: preset
|
||||
? (uint)preset.GetInstanceID()
|
||||
: (uint)GetInstanceID();
|
||||
|
||||
|
||||
public override UIEffectContext context
|
||||
{
|
||||
@@ -115,11 +120,25 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public override RectTransform transitionRoot => useTargetTransform && isTargetInScene
|
||||
? target.transitionRoot
|
||||
: m_CustomRoot
|
||||
? m_CustomRoot
|
||||
: transform as RectTransform;
|
||||
public override RectTransform transitionRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
if (preset && useTargetTransform && !m_CustomRoot && graphic && graphic.canvas)
|
||||
{
|
||||
return graphic.canvas.transform as RectTransform;
|
||||
}
|
||||
|
||||
if (useTargetTransform && isTargetInScene)
|
||||
{
|
||||
return target.transitionRoot;
|
||||
}
|
||||
|
||||
return m_CustomRoot
|
||||
? m_CustomRoot
|
||||
: transform as RectTransform;
|
||||
}
|
||||
}
|
||||
|
||||
private bool isTargetInScene => target && target.gameObject.scene.IsValid();
|
||||
|
||||
|
||||
@@ -131,7 +131,10 @@ namespace Coffee.UIEffects
|
||||
// When the text is changed, add it to the changed list
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(obj =>
|
||||
{
|
||||
if (obj is TextMeshProUGUI textMeshProUGUI && textMeshProUGUI.isActiveAndEnabled)
|
||||
if (obj is TextMeshProUGUI textMeshProUGUI
|
||||
&& textMeshProUGUI.isActiveAndEnabled
|
||||
// fix: `TmpProxy` causes loss of modifications from other `IMeshModifiers` (#371)
|
||||
&& textMeshProUGUI.TryGetComponent<UIEffectBase>(out var _))
|
||||
{
|
||||
s_ChangedInstances.Add(textMeshProUGUI);
|
||||
}
|
||||
@@ -143,7 +146,9 @@ namespace Coffee.UIEffects
|
||||
var toRemove = InternalListPool<TextMeshProUGUI>.Rent();
|
||||
foreach (var textMeshProUGUI in s_RegisteredInstances)
|
||||
{
|
||||
if (textMeshProUGUI && textMeshProUGUI.isActiveAndEnabled)
|
||||
if (textMeshProUGUI
|
||||
&& textMeshProUGUI.isActiveAndEnabled
|
||||
&& !textMeshProUGUI.isTextObjectScaleStatic)
|
||||
{
|
||||
var id = textMeshProUGUI.GetHashCode();
|
||||
var lossyScaleY = textMeshProUGUI.transform.lossyScale.y;
|
||||
@@ -227,8 +232,21 @@ namespace Coffee.UIEffects
|
||||
var meshInfo = textMeshProUGUI.textInfo.meshInfo[i];
|
||||
if (meshInfo.vertexCount == 0)
|
||||
{
|
||||
// Clear mesh if no vertices.
|
||||
s_Mesh.Clear(false);
|
||||
textMeshProUGUI.canvasRenderer.SetMesh(s_Mesh);
|
||||
if (i == 0)
|
||||
{
|
||||
textMeshProUGUI.canvasRenderer.SetMesh(s_Mesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
var subMeshUI = GetSubMeshUI(subMeshes, meshInfo.material, i - 1);
|
||||
if (subMeshUI)
|
||||
{
|
||||
subMeshUI.canvasRenderer.SetMesh(s_Mesh);
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -255,7 +273,16 @@ namespace Coffee.UIEffects
|
||||
var subMeshUI = GetSubMeshUI(subMeshes, meshInfo.material, i - 1);
|
||||
if (!subMeshUI) break;
|
||||
|
||||
var replica = subMeshUI.GetOrAddComponent<UIEffectReplica>();
|
||||
// fix: TMP Text sprite submesh lost when changing fontMaterial (#368)
|
||||
if (!subMeshUI.TryGetComponent<UIEffectReplica>(out var replica))
|
||||
{
|
||||
replica = subMeshUI.gameObject.AddComponent<UIEffectReplica>();
|
||||
textMeshProUGUI.RegisterDirtyMaterialCallback(() =>
|
||||
{
|
||||
if (subMeshUI) subMeshUI.SetMaterialDirty();
|
||||
});
|
||||
}
|
||||
|
||||
if (effect is UIEffect pEffect && pEffect.isActiveAndEnabled)
|
||||
{
|
||||
replica.target = pEffect;
|
||||
|
||||
@@ -223,84 +223,34 @@ half4 apply_tone_filter(half4 color)
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_color_filter(const half4 inColor, const half4 factor, const float intensity)
|
||||
half4 apply_color_filter(int mode, half4 inColor, half4 factor, float intensity, float glow)
|
||||
{
|
||||
const float glow = _ColorGlow;
|
||||
const int mode = _ColorFilter;
|
||||
half4 color = inColor;
|
||||
if (mode == 1) // Color.Multiply
|
||||
{
|
||||
color.rgb = color.rgb * factor.rgb;
|
||||
color *= factor.a;
|
||||
}
|
||||
else if (mode == 2) // Color.Additive
|
||||
{
|
||||
color.rgb = color.rgb + factor.rgb * color.a;
|
||||
color.rgb = color.rgb + factor.rgb * color.a * factor.a;
|
||||
}
|
||||
else if (mode == 3) // Color.Subtractive
|
||||
{
|
||||
color.rgb = color.rgb - factor.rgb * color.a;
|
||||
color.rgb = color.rgb - factor.rgb * color.a * factor.a;
|
||||
}
|
||||
else if (mode == 4) // Color.Replace
|
||||
{
|
||||
color.rgb = factor.rgb * color.a;
|
||||
color *= factor.a;
|
||||
}
|
||||
else if (mode == 5) // Color.MultiplyLuminance
|
||||
{
|
||||
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
|
||||
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb * factor.a / 2 * color.a;
|
||||
}
|
||||
else if (mode == 6) // Color.MultiplyAdditive
|
||||
{
|
||||
color.rgb = color.rgb * (1 + factor.rgb);
|
||||
}
|
||||
else if (mode == 7) // Color.HsvModifier
|
||||
{
|
||||
const float3 hsv = rgb_to_hsv(color.rgb);
|
||||
color.rgb = hsv_to_rgb(hsv + factor.rgb) * color.a * factor.a;
|
||||
color.a = inColor.a * factor.a;
|
||||
}
|
||||
else if (mode == 8) // Color.Contrast
|
||||
{
|
||||
color.rgb = ((color.rgb - 0.5) * (factor.r + 1) + 0.5 + factor.g * 1.5) * color.a * factor.a;
|
||||
color.a = color.a * factor.a;
|
||||
}
|
||||
|
||||
if (0 < mode)
|
||||
{
|
||||
color = lerp(inColor, color, intensity);
|
||||
color.a *= 1 - glow * intensity;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_transition_color_filter(const half4 inColor, const half4 factor, const float intensity)
|
||||
{
|
||||
const float glow = _TransitionColorGlow;
|
||||
const int mode = _TransitionColorFilter;
|
||||
half4 color = inColor;
|
||||
if (mode == 1) // Color.Multiply
|
||||
{
|
||||
color.rgb = color.rgb * factor.rgb;
|
||||
}
|
||||
else if (mode == 2) // Color.Additive
|
||||
{
|
||||
color.rgb = color.rgb + factor.rgb * color.a;
|
||||
}
|
||||
else if (mode == 3) // Color.Subtractive
|
||||
{
|
||||
color.rgb = color.rgb - factor.rgb * color.a;
|
||||
}
|
||||
else if (mode == 4) // Color.Replace
|
||||
{
|
||||
color.rgb = factor.rgb * color.a;
|
||||
}
|
||||
else if (mode == 5) // Color.MultiplyLuminance
|
||||
{
|
||||
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
|
||||
}
|
||||
else if (mode == 6) // Color.MultiplyAdditive
|
||||
{
|
||||
color.rgb = color.rgb * (1 + factor.rgb);
|
||||
color.rgb = color.rgb * (1 + factor.rgb * factor.a);
|
||||
}
|
||||
else if (mode == 7) // Color.HsvModifier
|
||||
{
|
||||
@@ -323,106 +273,6 @@ half4 apply_transition_color_filter(const half4 inColor, const half4 factor, con
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_shadow_color_filter(const half4 inColor, const half4 factor, const float intensity)
|
||||
{
|
||||
const float glow = _ShadowColorGlow;
|
||||
const int mode = _ShadowColorFilter;
|
||||
half4 color = inColor;
|
||||
if (mode == 1) // Color.Multiply
|
||||
{
|
||||
color.rgb = color.rgb * factor.rgb;
|
||||
}
|
||||
else if (mode == 2) // Color.Additive
|
||||
{
|
||||
color.rgb = color.rgb + factor.rgb * color.a;
|
||||
}
|
||||
else if (mode == 3) // Color.Subtractive
|
||||
{
|
||||
color.rgb = color.rgb - factor.rgb * color.a;
|
||||
}
|
||||
else if (mode == 4) // Color.Replace
|
||||
{
|
||||
color.rgb = factor.rgb * color.a;
|
||||
}
|
||||
else if (mode == 5) // Color.MultiplyLuminance
|
||||
{
|
||||
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
|
||||
}
|
||||
else if (mode == 6) // Color.MultiplyAdditive
|
||||
{
|
||||
color.rgb = color.rgb * (1 + factor.rgb);
|
||||
}
|
||||
else if (mode == 7) // Color.HsvModifier
|
||||
{
|
||||
const float3 hsv = rgb_to_hsv(color.rgb);
|
||||
color.rgb = hsv_to_rgb(hsv + factor.rgb) * color.a * factor.a;
|
||||
color.a = inColor.a * factor.a;
|
||||
}
|
||||
else if (mode == 8) // Color.Contrast
|
||||
{
|
||||
color.rgb = ((color.rgb - 0.5) * (factor.r + 1) + 0.5 + factor.g * 1.5) * color.a * factor.a;
|
||||
color.a = color.a * factor.a;
|
||||
}
|
||||
|
||||
if (0 < mode)
|
||||
{
|
||||
color = lerp(inColor, color, intensity);
|
||||
color.a *= 1 - glow * intensity;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_edge_color_filter(const half4 inColor, const half4 factor, const float intensity)
|
||||
{
|
||||
const float glow = _EdgeColorGlow;
|
||||
const int mode = _EdgeColorFilter;
|
||||
half4 color = inColor;
|
||||
if (mode == 1) // Color.Multiply
|
||||
{
|
||||
color.rgb = color.rgb * factor.rgb;
|
||||
}
|
||||
else if (mode == 2) // Color.Additive
|
||||
{
|
||||
color.rgb = color.rgb + factor.rgb * color.a;
|
||||
}
|
||||
else if (mode == 3) // Color.Subtractive
|
||||
{
|
||||
color.rgb = color.rgb - factor.rgb * color.a;
|
||||
}
|
||||
else if (mode == 4) // Color.Replace
|
||||
{
|
||||
color.rgb = factor.rgb * color.a;
|
||||
}
|
||||
else if (mode == 5) // Color.MultiplyLuminance
|
||||
{
|
||||
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
|
||||
}
|
||||
else if (mode == 6) // Color.MultiplyAdditive
|
||||
{
|
||||
color.rgb = color.rgb * (1 + factor.rgb);
|
||||
}
|
||||
else if (mode == 7) // Color.HsvModifier
|
||||
{
|
||||
const float3 hsv = rgb_to_hsv(color.rgb);
|
||||
color.rgb = hsv_to_rgb(hsv + factor.rgb) * color.a * factor.a;
|
||||
color.a = inColor.a * factor.a;
|
||||
}
|
||||
else if (mode == 8) // Color.Contrast
|
||||
{
|
||||
color.rgb = ((color.rgb - 0.5) * (factor.r + 1) + 0.5 + factor.g * 1.5) * color.a * factor.a;
|
||||
color.a = color.a * factor.a;
|
||||
}
|
||||
|
||||
if (0 < mode)
|
||||
{
|
||||
color = lerp(inColor, color, intensity);
|
||||
color.a *= 1 - glow * intensity;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_sampling_filter(float2 uv, const float4 uvMask, const float isShadow)
|
||||
{
|
||||
#if SAMPLING_BLUR_FAST || SAMPLING_BLUR_MEDIUM || SAMPLING_BLUR_DETAIL
|
||||
@@ -505,7 +355,7 @@ half4 apply_transition_filter(half4 color, const float alpha, const float2 uvLoc
|
||||
}
|
||||
#elif TRANSITION_PATTERN // Transition.Pattern
|
||||
{
|
||||
const half4 patternColor = apply_transition_color_filter(half4(color.rgb, 1), half4(_TransitionColor.rgb * color.a, 1), _TransitionColor.a);
|
||||
const half4 patternColor = apply_color_filter(_TransitionColorFilter, half4(color.rgb, 1), half4(_TransitionColor.rgb * color.a, 1), _TransitionColor.a, _TransitionColorGlow);
|
||||
float isPattern = min(inv_lerp(_TransitionRange.x, _TransitionRange.y, uvLocal.x), 0.995) < (_TransitionPatternReverse ? alpha : 1 - alpha);
|
||||
isPattern = _TransitionPatternReverse ? isPattern : 1 - isPattern;
|
||||
const float patternFactor = _PatternArea == 0 ? 1 : _PatternArea == 1 ? 1 - edgeFactor : edgeFactor;
|
||||
@@ -516,10 +366,10 @@ half4 apply_transition_filter(half4 color, const float alpha, const float2 uvLoc
|
||||
{
|
||||
const float factor = alpha - transition_rate() * (1 + _TransitionWidth) + _TransitionWidth;
|
||||
const float softness = max(0.0001, _TransitionWidth * _TransitionSoftness);
|
||||
const half bandLerp = saturate((_TransitionWidth - factor) * 1 / softness);
|
||||
const half bandLerp = saturate((_TransitionWidth - factor) * 2 / softness);
|
||||
const half softLerp = saturate(factor * 2 / softness);
|
||||
half4 bandColor = apply_transition_color_filter(half4(color.rgb, 1), half4(_TransitionColor.rgb, 1),
|
||||
_TransitionColor.a);
|
||||
half4 bandColor = apply_color_filter(_TransitionColorFilter, half4(color.rgb, 1),
|
||||
half4(_TransitionColor.rgb, 1), _TransitionColor.a, _TransitionColorGlow);
|
||||
bandColor *= color.a;
|
||||
|
||||
#if TRANSITION_MELT
|
||||
@@ -540,7 +390,14 @@ half4 apply_transition_filter(half4 color, const float alpha, const float2 uvLoc
|
||||
}
|
||||
#endif
|
||||
|
||||
color = lerp(color, bandColor, bandLerp * softLerp);
|
||||
half lerpFactor = bandLerp * softLerp;
|
||||
#if TRANSITION_SHINY
|
||||
{
|
||||
lerpFactor *= lerpFactor;
|
||||
}
|
||||
#endif
|
||||
|
||||
color = lerp(color, bandColor, lerpFactor);
|
||||
|
||||
#if TRANSITION_DISSOLVE
|
||||
{
|
||||
@@ -598,42 +455,7 @@ half4 apply_gradation_filter(const half4 inColor, const float2 uvGrad)
|
||||
}
|
||||
#endif
|
||||
|
||||
const int mode = _GradationColorFilter;
|
||||
const float intensity = _GradationIntensity;
|
||||
half4 color = inColor;
|
||||
if (mode == 1) // Color.Multiply
|
||||
{
|
||||
color.rgb = color.rgb * factor.rgb;
|
||||
color *= factor.a;
|
||||
}
|
||||
else if (mode == 2) // Color.Additive
|
||||
{
|
||||
color.rgb = color.rgb + factor.rgb * color.a * factor.a;
|
||||
}
|
||||
else if (mode == 3) // Color.Subtractive
|
||||
{
|
||||
color.rgb = color.rgb - factor.rgb * color.a * factor.a;
|
||||
}
|
||||
else if (mode == 4) // Color.Replace
|
||||
{
|
||||
color.rgb = factor.rgb * color.a;
|
||||
color *= factor.a;
|
||||
}
|
||||
else if (mode == 5) // Color.MultiplyLuminance
|
||||
{
|
||||
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb * factor.a / 2 * color.a;
|
||||
}
|
||||
else if (mode == 6) // Color.MultiplyAdditive
|
||||
{
|
||||
color.rgb = color.rgb * (1 + factor.rgb * factor.a);
|
||||
}
|
||||
|
||||
if (0 < mode)
|
||||
{
|
||||
color = lerp(inColor, color, intensity);
|
||||
}
|
||||
|
||||
return color;
|
||||
return apply_color_filter(_GradationColorFilter, inColor, factor, _GradationIntensity, 0);
|
||||
}
|
||||
|
||||
half4 apply_detail_filter(half4 color, float2 uvLocal)
|
||||
@@ -743,20 +565,20 @@ half4 uieffect_internal(float2 uv, float4 uvMask, const float2 uvLocal, const fl
|
||||
|
||||
if (0 < isShadow)
|
||||
{
|
||||
return apply_shadow_color_filter(color, _ShadowColor, 1);
|
||||
return apply_color_filter(_ShadowColorFilter, color, _ShadowColor, 1, _ShadowColorGlow);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if EDGE_PLAIN || EDGE_SHINY
|
||||
{
|
||||
color = apply_color_filter(color, _ColorValue, _ColorIntensity);
|
||||
const half4 edgeColor = apply_edge_color_filter(color, _EdgeColor, 1);
|
||||
color = apply_color_filter(_ColorFilter, color, _ColorValue, _ColorIntensity, _ColorGlow);
|
||||
const half4 edgeColor = apply_color_filter(_EdgeColorFilter, color, _EdgeColor, 1, _EdgeColorGlow);
|
||||
const float isEdgeShiny = is_edge_shiny(uvLocal);
|
||||
return lerp(color, edgeColor, edgeFactor * isEdgeShiny);
|
||||
}
|
||||
#else
|
||||
{
|
||||
return apply_color_filter(color, _ColorValue, _ColorIntensity);
|
||||
return apply_color_filter(_ColorFilter, color, _ColorValue, _ColorIntensity, _ColorGlow);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ Shader "Hidden/UI/Default (UIEffect)"
|
||||
{
|
||||
v2f IN = _fragInput;
|
||||
half4 color = (tex2D(_MainTex, uv) + _TextureSampleAdd);
|
||||
color.rgb *= IN.color.rgb;
|
||||
color.rgb *= color.a;
|
||||
return color;
|
||||
}
|
||||
@@ -170,7 +171,6 @@ Shader "Hidden/UI/Default (UIEffect)"
|
||||
|
||||
_fragInput = IN;
|
||||
half4 c = uieffect(IN.texcoord, IN.uvMask, IN.worldPosition);
|
||||
c.rgb *= IN.color.rgb;
|
||||
c *= IN.color.a;
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "com.coffee.ui-effect",
|
||||
"displayName": "UI Effect",
|
||||
"description": "UIEffect is an open-source package that allows you to intuitively apply rich UI effects directly from the Inspector or via code.\nCombine various filters, such as grayscale, blur, and dissolve, to decorate your UI with a unique visual style!",
|
||||
"version": "5.9.1",
|
||||
"version": "5.10.0",
|
||||
"unity": "2020.3",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user