mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-20 01:42:37 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3eb775dcf5 | |||
| 1af89af2c5 | |||
| f0a76424e6 | |||
| f2753e9a3d |
@@ -1,5 +1,6 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@@ -31,17 +32,23 @@ internal static class ImportSample
|
||||
|
||||
private static void Run(string sample)
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
var bash = @"C:\Program Files\Git\bin\bash.exe";
|
||||
if (!File.Exists(bash))
|
||||
{
|
||||
bash = @"C:\Program Files (x86)\Git\bin\bash.exe";
|
||||
}
|
||||
#else
|
||||
var bash = "/bin/bash";
|
||||
#endif
|
||||
|
||||
var p = new Process()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
Arguments = $"import-tmp-support.sh '{sample}'",
|
||||
CreateNoWindow = true,
|
||||
#if UNITY_EDITOR_WIN
|
||||
FileName = @"C:\Program Files (x86)\Git\bin\bash.exe",
|
||||
#else
|
||||
FileName = "/bin/bash",
|
||||
#endif
|
||||
FileName = bash,
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardOutput = true,
|
||||
WorkingDirectory = $"{Application.dataPath}/..",
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "2045eaab5b485827cef8bf0bb9e1552dce4f8d6d"
|
||||
"hash": "2bd2bf356dd692a39de9db2ff11faaf79fbfaea3"
|
||||
},
|
||||
"com.coffee.nano-monitor": {
|
||||
"version": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/NanoMonitor",
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
## [5.5.3](https://github.com/mob-sakai/UIEffect/compare/5.5.2...5.5.3) (2025-03-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* blur with 'Filled' Image type may cause error ([f0a7642](https://github.com/mob-sakai/UIEffect/commit/f0a76424e690355c101cc2e12183d1a7e77b16c3)), closes [#313](https://github.com/mob-sakai/UIEffect/issues/313)
|
||||
* IL2CPP build fails on older versions of Unity ([1af89af](https://github.com/mob-sakai/UIEffect/commit/1af89af2c58320f67b8d753767b3b4cf905f844d)), closes [#315](https://github.com/mob-sakai/UIEffect/issues/315)
|
||||
|
||||
## [5.5.2](https://github.com/mob-sakai/UIEffect/compare/5.5.1...5.5.2) (2025-02-28)
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -447,7 +447,7 @@ namespace Coffee.UIEffects
|
||||
effectProxy.OnPreModifyMesh(graphic);
|
||||
|
||||
var verts = s_WorkingVertices;
|
||||
var expandSize = GetExpandSize(canModifyShape);
|
||||
var expandSize = effectProxy.ModifyExpandSize(graphic, GetExpandSize(canModifyShape));
|
||||
var count = vh.currentIndexCount;
|
||||
|
||||
// Get the rectangle to calculate the normalized position.
|
||||
|
||||
@@ -72,6 +72,11 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
}
|
||||
|
||||
public virtual Vector4 ModifyExpandSize(Graphic graphic, Vector2 expandSize)
|
||||
{
|
||||
return new Vector4(expandSize.x, expandSize.y, expandSize.x, expandSize.y);
|
||||
}
|
||||
|
||||
private static readonly Func<UIVertex, UIVertex, UIVertex, float, UIVertex> s_OnLerpVertex =
|
||||
null;
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
internal class ImageProxy : GraphicProxy
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[InitializeOnLoadMethod]
|
||||
#endif
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
private static void InitializeOnLoad()
|
||||
{
|
||||
Register(new ImageProxy());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the graphic is valid for this proxy.
|
||||
/// </summary>
|
||||
protected override bool IsValid(Graphic graphic)
|
||||
{
|
||||
if (!graphic) return false;
|
||||
if (graphic is Image) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the graphic is a text.
|
||||
/// </summary>
|
||||
public override bool IsText(Graphic graphic)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override Vector4 ModifyExpandSize(Graphic graphic, Vector2 expandSize)
|
||||
{
|
||||
var image = graphic as Image;
|
||||
var ret = new Vector4(expandSize.x, expandSize.y, expandSize.x, expandSize.y);
|
||||
|
||||
if (image
|
||||
&& image.type == Image.Type.Filled
|
||||
&& image.fillMethod == Image.FillMethod.Radial360
|
||||
&& image.fillAmount <= 0.5f)
|
||||
{
|
||||
ret[(image.fillOrigin + (image.fillClockwise ? 2 : 0)) % 4] = 0;
|
||||
|
||||
if (image.fillAmount <= 0.25f)
|
||||
{
|
||||
ret[(image.fillOrigin + 3) % 4] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cddfadaf298c14befb49972983c16f2d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,56 +18,62 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public static void Expand(List<UIVertex> verts, int start, int bundleSize, Vector2 expandSize, Rect bounds)
|
||||
public static void Expand(List<UIVertex> verts, int start, int bundleSize, Vector4 expandSize, Rect bounds)
|
||||
{
|
||||
if (expandSize == Vector2.zero) return;
|
||||
if (expandSize == Vector4.zero) return;
|
||||
|
||||
// Quad (6 vertices)
|
||||
for (var j = 0; j < bundleSize; j += 6)
|
||||
for (var j = 0; j < bundleSize; j += 3)
|
||||
{
|
||||
var size = default(Vector3);
|
||||
var extendPos = default(Vector3);
|
||||
var extendUV = default(Vector3);
|
||||
var posLB = verts[start + j + 1].position;
|
||||
var posRT = verts[start + j + 4].position;
|
||||
var willExpand = bundleSize == 6 // Text or simple quad
|
||||
|| !bounds.Contains(posLB)
|
||||
|| !bounds.Contains(posRT); // Outer 9-sliced quad
|
||||
if (willExpand)
|
||||
if (bounds.Contains(verts[start + j + 0].position)
|
||||
&& bounds.Contains(verts[start + j + 1].position)
|
||||
&& bounds.Contains(verts[start + j + 2].position))
|
||||
{
|
||||
var uvLB = verts[start + j + 1].uv0;
|
||||
var uvRT = verts[start + j + 4].uv0;
|
||||
var posCenter = (posLB + posRT) / 2;
|
||||
var uvCenter = (uvLB + uvRT) / 2;
|
||||
size = posLB - posRT;
|
||||
size.x = 1 + expandSize.x / Mathf.Abs(size.x);
|
||||
size.y = 1 + expandSize.y / Mathf.Abs(size.y);
|
||||
size.z = 1;
|
||||
extendPos = posCenter - Vector3.Scale(size, posCenter);
|
||||
extendUV = uvCenter - Vector4.Scale(size, uvCenter);
|
||||
continue;
|
||||
}
|
||||
|
||||
GetBounds(verts, start + j, 3, out var posBounds, out var uvBounds);
|
||||
var posCenter = (Vector4)posBounds.center;
|
||||
posCenter.z = posCenter.x;
|
||||
posCenter.w = posCenter.y;
|
||||
var uvCenter = (Vector4)uvBounds.center;
|
||||
uvCenter.z = uvCenter.x;
|
||||
uvCenter.w = uvCenter.y;
|
||||
var size = (Vector4)posBounds.size;
|
||||
size.z = 1 + expandSize.z / Mathf.Abs(size.x);
|
||||
size.w = 1 + expandSize.w / Mathf.Abs(size.y);
|
||||
size.x = 1 + expandSize.x / Mathf.Abs(size.x);
|
||||
size.y = 1 + expandSize.y / Mathf.Abs(size.y);
|
||||
var extendPos = posCenter - Vector4.Scale(size, posCenter);
|
||||
var extendUV = uvCenter - Vector4.Scale(size, uvCenter);
|
||||
|
||||
// Set vertex position, uv, uvMask and local normalized position.
|
||||
for (var k = 0; k < 6; k++)
|
||||
for (var k = 0; k < 3; k++)
|
||||
{
|
||||
var vt = verts[start + j + k];
|
||||
var pos = vt.position;
|
||||
var uv0 = vt.uv0;
|
||||
|
||||
// Expand edge vertex
|
||||
if (willExpand)
|
||||
if (pos.x < bounds.xMin)
|
||||
{
|
||||
if (pos.x < bounds.xMin || bounds.xMax < pos.x)
|
||||
{
|
||||
pos.x = pos.x * size.x + extendPos.x;
|
||||
uv0.x = uv0.x * size.x + extendUV.x;
|
||||
}
|
||||
pos.x = pos.x * size.x + extendPos.x;
|
||||
uv0.x = uv0.x * size.x + extendUV.x;
|
||||
}
|
||||
else if (bounds.xMax < pos.x)
|
||||
{
|
||||
pos.x = pos.x * size.z + extendPos.z;
|
||||
uv0.x = uv0.x * size.z + extendUV.z;
|
||||
}
|
||||
|
||||
if (pos.y < bounds.yMin || bounds.yMax < pos.y)
|
||||
{
|
||||
pos.y = pos.y * size.y + extendPos.y;
|
||||
uv0.y = uv0.y * size.y + extendUV.y;
|
||||
}
|
||||
if (pos.y < bounds.yMin)
|
||||
{
|
||||
pos.y = pos.y * size.y + extendPos.y;
|
||||
uv0.y = uv0.y * size.y + extendUV.y;
|
||||
}
|
||||
else if (bounds.yMax < pos.y)
|
||||
{
|
||||
pos.y = pos.y * size.w + extendPos.w;
|
||||
uv0.y = uv0.y * size.w + extendUV.w;
|
||||
}
|
||||
|
||||
vt.position = pos;
|
||||
|
||||
@@ -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.5.2",
|
||||
"version": "5.5.3",
|
||||
"unity": "2020.3",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user