mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-20 01:42:37 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c6fa44a0b6 | |||
| 26da24dbc4 | |||
| 6014ab54d0 | |||
| dbdb99b52a | |||
| 3b095bcebd | |||
| 2a900987f5 | |||
| 974e3e8769 | |||
| 909281c66b | |||
| 75ed355e27 | |||
| a0dd316df6 | |||
| 4f66bbfb4d | |||
| 91d5519356 | |||
| 76be0fc860 |
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,24 @@ ShaderVariantCollection:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: UIEffectShaderVariants
|
||||
m_Shaders:
|
||||
- first: {fileID: 4800000, guid: d1cb940e3804b4adcaf9b22083fadfad, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 63a1dba10bff94661a909d63808a9a3b, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: e65241fa80a374114b3f55ed746c04d9, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 935b7be1c88464d2eb87204fdfab5a38, type: 3}
|
||||
second:
|
||||
variants:
|
||||
@@ -49,6 +67,9 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_REPLACE TRANSITION_MELT UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 96246b1ead49a4c5a996fd477bc5a117, type: 3}
|
||||
second:
|
||||
variants:
|
||||
@@ -66,6 +87,10 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY DETAIL_MASKING EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_SHINY
|
||||
SAMPLING_BLUR_FAST SHADOW_COLOR_REPLACE TARGET_HUE TONE_GRAYSCALE TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY SHADOW_COLOR_REPLACE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_ADDITIVE
|
||||
@@ -133,10 +158,18 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TONE_RETRO UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TRANSITION_COLOR_MULTIPLY TRANSITION_PATTERN
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: SAMPLING_RGB_SHIFT
|
||||
passType: 0
|
||||
- keywords: SAMPLING_RGB_SHIFT TRANSITION_COLOR_MULTIPLY TRANSITION_PATTERN
|
||||
passType: 0
|
||||
- keywords: SHADOW_COLOR_REPLACE
|
||||
passType: 0
|
||||
- keywords: SHADOW_COLOR_REPLACE TRANSITION_COLOR_REPLACE TRANSITION_MELT
|
||||
passType: 0
|
||||
- keywords: TONE_GRAYSCALE
|
||||
passType: 0
|
||||
- keywords: TONE_NEGATIVE
|
||||
@@ -177,6 +210,30 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: TRANSITION_FADE
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 03ea49e29b5ad4fbe8e340af208fe8e7, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 16f26337621974eaf998b9857bac39c6, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 2c69b4dabb5c24ae99889f581c8b556a, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 26b66f9b09b8d4ac6a2790c3fa8b21c1, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -1,3 +1,34 @@
|
||||
## [5.6.4](https://github.com/mob-sakai/UIEffect/compare/5.6.3...5.6.4) (2025-04-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* avoid potential allocations ([26da24d](https://github.com/mob-sakai/UIEffect/commit/26da24dbc4022dcd71e7a58e5f02a6922ba2ddff))
|
||||
* optional shaders do not support all shader combinations ([6014ab5](https://github.com/mob-sakai/UIEffect/commit/6014ab54d010872f8fee63fc961ac5ab2edd08e1))
|
||||
|
||||
## [5.6.3](https://github.com/mob-sakai/UIEffect/compare/5.6.2...5.6.3) (2025-04-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix a potential `ArgumentOutOfRangeException` that could occur when changing the FontAsset in TextMeshPro ([3b095bc](https://github.com/mob-sakai/UIEffect/commit/3b095bcebd8b1264c373b8b71c27d3c35f673f3b)), closes [#327](https://github.com/mob-sakai/UIEffect/issues/327)
|
||||
|
||||
## [5.6.2](https://github.com/mob-sakai/UIEffect/compare/5.6.1...5.6.2) (2025-04-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix a potential `ArgumentOutOfRangeException` that could occur when changing the FontAsset in TextMeshPro ([909281c](https://github.com/mob-sakai/UIEffect/commit/909281c66b702d8497e9f847c91b688716b9c6a7)), closes [#327](https://github.com/mob-sakai/UIEffect/issues/327)
|
||||
* Remove unnecessary vertex expansion ([974e3e8](https://github.com/mob-sakai/UIEffect/commit/974e3e8769d456c5cdd8eb1767a7cf57ab4d52fc))
|
||||
* undo now works correctly after clicking the 'Clear' button in the inspector ([75ed355](https://github.com/mob-sakai/UIEffect/commit/75ed355e27faf8962390eb6788e1887ffd1b5f89))
|
||||
|
||||
## [5.6.1](https://github.com/mob-sakai/UIEffect/compare/5.6.0...5.6.1) (2025-03-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* changes were not correctly marked as dirty when loading presets ([76be0fc](https://github.com/mob-sakai/UIEffect/commit/76be0fc860c27b89235b7fb9a766dcc38b3d9924))
|
||||
|
||||
# [5.6.0](https://github.com/mob-sakai/UIEffect/compare/5.5.3...5.6.0) (2025-03-28)
|
||||
|
||||
|
||||
|
||||
@@ -665,6 +665,7 @@ namespace Coffee.UIEffects.Editors
|
||||
r.width = 55;
|
||||
if (GUI.Button(r, EditorGUIUtility.TrTempContent("Clear"), "MiniButton"))
|
||||
{
|
||||
Undo.RecordObjects(targets, "Clear UIEffect");
|
||||
Array.ForEach(targets.OfType<UIEffect>().ToArray(), Unsupported.SmartReset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ Combine various filters, such as grayscale, blur, and dissolve, to decorate your
|
||||
- **UIEffectTweener Component**: A simple tweener component to play, stop, pause, and resume effects.
|
||||
- **AnimationClip support**: Allows control of effect animations using `AnimationClips`.
|
||||
- **v4 compatible components (optional)**: For easy upgrading with minimal changes, compatible v4 components are available optionally.
|
||||
- **SoftMaskForUGUI support (optional)**: Compatible with SoftMaskForUGUI for creating soft masks for UI elements. See for more details [here](#usage-with-softmaskforugui).
|
||||
|
||||
<br><br>
|
||||
|
||||
@@ -339,7 +340,7 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||

|
||||
|
||||
- **Detail Filter**: `None`, `Masking`, `Multiply`, `Additive`, `Replace`, `MuliplyAdditive`
|
||||

|
||||

|
||||
- **Detail Intensity**: 0.0 (no effect) - 1.0 (full effect).
|
||||
- **Detail Threshold** (`Masking` only): The minimum and maximum alpha values used for masking. The larger the gap
|
||||
between these values, the stronger the softness effect.
|
||||
@@ -362,7 +363,8 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||
- `Horizontal`
|
||||
- `Vertical`
|
||||
- `Effect`: Flip with the effect.
|
||||
- `Shadow`: Flip with the shadow.
|
||||
- `Shadow`: Flip with the shadow.
|
||||

|
||||
|
||||
> [!TIP]
|
||||
> `Transition Filter`, `Gradation Filter`, and `Detail Filter` usually refer to their own `RectTransform` when applying effects.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -110,10 +111,12 @@ namespace Coffee.UIEffectInternal
|
||||
dst.Clear();
|
||||
for (var i = 0; i < vertexCount; i++)
|
||||
{
|
||||
dst.AddVert(positions[i], colors[i], uv0[i], uv1[i], normals[i], tangents[i]);
|
||||
dst.AddVert(positions.GetOrDefault(i), colors.GetOrDefault(i), uv0.GetOrDefault(i), uv1.GetOrDefault(i),
|
||||
normals.GetOrDefault(i), tangents.GetOrDefault(i));
|
||||
}
|
||||
|
||||
for (var i = 0; i < indexCount; i += 3)
|
||||
var count = Mathf.Clamp(indexCount, 0, indices.Count);
|
||||
for (var i = 0; i < count - 2; i += 3)
|
||||
{
|
||||
dst.AddTriangle(indices[i], indices[i + 1], indices[i + 2]);
|
||||
}
|
||||
@@ -126,5 +129,12 @@ namespace Coffee.UIEffectInternal
|
||||
InternalListPool<Color32>.Return(ref colors);
|
||||
InternalListPool<int>.Return(ref indices);
|
||||
}
|
||||
|
||||
private static T GetOrDefault<T>(this List<T> self, int index)
|
||||
{
|
||||
return 0 <= index && index < self.Count
|
||||
? self[index]
|
||||
: default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace Coffee.UIEffectInternal
|
||||
var rKey = new Rect(r.x, r.y + 2, r.width, h);
|
||||
if (GUI.Button(rKey, key.stringValue, EditorStyles.popup))
|
||||
{
|
||||
ShowShaderDropdown(key, optionName, false);
|
||||
ShowShaderDropdown(key);
|
||||
}
|
||||
|
||||
var rArrow = new Rect(r.x, r.y + h + 4, 20, h);
|
||||
@@ -324,7 +324,7 @@ namespace Coffee.UIEffectInternal
|
||||
var rValue = new Rect(r.x + 20, r.y + h + 4, r.width - 20, h);
|
||||
if (GUI.Button(rValue, value.stringValue, EditorStyles.popup))
|
||||
{
|
||||
ShowShaderDropdown(value, optionName, true);
|
||||
ShowShaderDropdown(value);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -444,12 +444,11 @@ namespace Coffee.UIEffectInternal
|
||||
return expand;
|
||||
}
|
||||
|
||||
private static void ShowShaderDropdown(SerializedProperty property, string option, bool required)
|
||||
private static void ShowShaderDropdown(SerializedProperty property)
|
||||
{
|
||||
var menu = new GenericMenu();
|
||||
var current = property.stringValue;
|
||||
var allShaderNames = ShaderUtil.GetAllShaderInfo()
|
||||
.Where(s => !required || s.name.Contains(option))
|
||||
.Select(s => s.name);
|
||||
|
||||
foreach (var shaderName in allShaderNames)
|
||||
|
||||
@@ -1409,21 +1409,21 @@ namespace Coffee.UIEffects
|
||||
public override void SetVerticesDirty()
|
||||
{
|
||||
base.SetVerticesDirty();
|
||||
replicas.ForEach(c =>
|
||||
for (var i = 0; i < replicas.Count; i++)
|
||||
{
|
||||
if (!c) return;
|
||||
c.SetVerticesDirty();
|
||||
});
|
||||
if (!replicas[i]) continue;
|
||||
replicas[i].SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetMaterialDirty()
|
||||
{
|
||||
base.SetMaterialDirty();
|
||||
replicas.ForEach(c =>
|
||||
for (var i = 0; i < replicas.Count; i++)
|
||||
{
|
||||
if (!c) return;
|
||||
c.SetMaterialDirty();
|
||||
});
|
||||
if (!replicas[i]) continue;
|
||||
replicas[i].SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1522,11 +1522,12 @@ namespace Coffee.UIEffects
|
||||
public override void ApplyContextToMaterial(Material material)
|
||||
{
|
||||
base.ApplyContextToMaterial(material);
|
||||
replicas.ForEach(c =>
|
||||
|
||||
for (var i = 0; i < replicas.Count; i++)
|
||||
{
|
||||
if (!c) return;
|
||||
c.ApplyContextToMaterial(material);
|
||||
});
|
||||
if (!replicas[i]) continue;
|
||||
replicas[i].ApplyContextToMaterial(material);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetRate(float rate, UIEffectTweener.CullingMask mask)
|
||||
@@ -1724,6 +1725,7 @@ namespace Coffee.UIEffects
|
||||
m_DetailTexSpeed = preset.m_DetailTexSpeed;
|
||||
}
|
||||
|
||||
Misc.SetDirty(this);
|
||||
UpdateContext(context);
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
@@ -1811,6 +1813,7 @@ namespace Coffee.UIEffects
|
||||
m_DetailTexOffset = c.detailTexOffset;
|
||||
m_DetailTexSpeed = c.detailTexSpeed;
|
||||
|
||||
Misc.SetDirty(this);
|
||||
UpdateContext(context);
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
|
||||
@@ -749,37 +749,36 @@ namespace Coffee.UIEffects
|
||||
UIVertexUtil.Flip(verts, flipHorizontal, flipVertical);
|
||||
}
|
||||
|
||||
private Vector2 GetExpandSize(bool canModifyShape)
|
||||
private Vector4 GetExpandSize(bool canModifyShape)
|
||||
{
|
||||
if (!canModifyShape) return Vector2.zero;
|
||||
if (!canModifyShape) return Vector4.zero;
|
||||
|
||||
var expandSize = Vector2.zero;
|
||||
var expandSize = Vector4.zero;
|
||||
switch (samplingFilter)
|
||||
{
|
||||
case SamplingFilter.BlurFast:
|
||||
expandSize.x += 10;
|
||||
expandSize.y += 10;
|
||||
expandSize += Vector4.one * 10;
|
||||
break;
|
||||
case SamplingFilter.BlurMedium:
|
||||
expandSize.x += 15;
|
||||
expandSize.y += 15;
|
||||
expandSize += Vector4.one * 15;
|
||||
break;
|
||||
case SamplingFilter.BlurDetail:
|
||||
expandSize.x += 20;
|
||||
expandSize.y += 20;
|
||||
expandSize += Vector4.one * 20;
|
||||
break;
|
||||
case SamplingFilter.RgbShift:
|
||||
expandSize.x += 40;
|
||||
expandSize.y += 40;
|
||||
expandSize.z += 40;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (transitionFilter)
|
||||
{
|
||||
case TransitionFilter.Melt:
|
||||
case TransitionFilter.Burn:
|
||||
expandSize.y += 40;
|
||||
break;
|
||||
case TransitionFilter.Burn:
|
||||
expandSize.w += 40;
|
||||
break;
|
||||
}
|
||||
|
||||
return expandSize;
|
||||
|
||||
@@ -72,9 +72,9 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
}
|
||||
|
||||
public virtual Vector4 ModifyExpandSize(Graphic graphic, Vector2 expandSize)
|
||||
public virtual Vector4 ModifyExpandSize(Graphic graphic, Vector4 expandSize)
|
||||
{
|
||||
return new Vector4(expandSize.x, expandSize.y, expandSize.x, expandSize.y);
|
||||
return expandSize;
|
||||
}
|
||||
|
||||
private static readonly Func<UIVertex, UIVertex, UIVertex, float, UIVertex> s_OnLerpVertex =
|
||||
|
||||
@@ -33,25 +33,22 @@ namespace Coffee.UIEffects
|
||||
return false;
|
||||
}
|
||||
|
||||
public override Vector4 ModifyExpandSize(Graphic graphic, Vector2 expandSize)
|
||||
public override Vector4 ModifyExpandSize(Graphic graphic, Vector4 expandSize)
|
||||
{
|
||||
var image = graphic as Image;
|
||||
var ret = new Vector4(expandSize.x, expandSize.y, expandSize.x, expandSize.y);
|
||||
|
||||
if (image
|
||||
if (graphic is Image image
|
||||
&& image.type == Image.Type.Filled
|
||||
&& image.fillMethod == Image.FillMethod.Radial360
|
||||
&& image.fillAmount <= 0.5f)
|
||||
{
|
||||
ret[(image.fillOrigin + (image.fillClockwise ? 2 : 0)) % 4] = 0;
|
||||
expandSize[(image.fillOrigin + (image.fillClockwise ? 2 : 0)) % 4] = 0;
|
||||
|
||||
if (image.fillAmount <= 0.25f)
|
||||
{
|
||||
ret[(image.fillOrigin + 3) % 4] = 0;
|
||||
expandSize[(image.fillOrigin + 3) % 4] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return expandSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5411,7 +5411,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1887047859}
|
||||
m_Enabled: 0
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3312d7739989d2b4e91e6319e9a96d76, type: 3}
|
||||
m_Name:
|
||||
|
||||
@@ -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.6.0",
|
||||
"version": "5.6.4",
|
||||
"unity": "2020.3",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user