mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-20 01:42:37 +08:00
Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cc5c5b68e | |||
| 4a8d341625 | |||
| a885fc5bc1 | |||
| 4fdd9636fa | |||
| 06a280ec5a | |||
| e6fb78a0f6 | |||
| 451cbe4302 | |||
| 3cae638bdd | |||
| 533d7b8c0a | |||
| 9380f96572 | |||
| b4adb32512 | |||
| 59874ddffe | |||
| c4202b45d2 | |||
| ce692580a3 | |||
| 6c808aa341 | |||
| a975cf347a | |||
| 3207105a06 | |||
| 4cca2fb5ab | |||
| d1adb33884 | |||
| b077d97ed7 | |||
| 6f90044ec8 | |||
| 83128ebb09 | |||
| 9dffdb0ed8 | |||
| 16be53e145 | |||
| fd2d1b8059 | |||
| cf43bfffb9 | |||
| a2f4a2d5c9 | |||
| 0d7fb1eb63 | |||
| 145f56968a | |||
| cadbb8d68d | |||
| a0c3e4997a | |||
| ec57c2a994 | |||
| 804b48c73e | |||
| 01be18bb28 | |||
| 8addbad494 | |||
| dc5b3805d7 |
@@ -25,7 +25,7 @@ jobs:
|
||||
tag: ${{ steps.release.outputs.new_release_git_tag }}
|
||||
steps:
|
||||
- name: 🚚 Checkout (${{ github.ref_name }})
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: 🔖 Run semantic release
|
||||
uses: cycjimmy/semantic-release-action@v4
|
||||
|
||||
@@ -9,7 +9,7 @@ env:
|
||||
# MINIMUM_VERSION: The minimum version of Unity.
|
||||
MINIMUM_VERSION: 6000.0
|
||||
# EXCLUDE_FILTER: The excluded versions of Unity.
|
||||
EXCLUDE_FILTER: "(2020.2.0|2021.1|2023.2|2023.3)"
|
||||
EXCLUDE_FILTER: "(2017|2018)"
|
||||
PROJECT_PATH: UIEffectURP
|
||||
|
||||
on:
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
id: setup
|
||||
run: |
|
||||
echo "==== Target Unity Versions ===="
|
||||
LATEST_VERSIONS=`npx unity-changeset list --versions --latest-patch --min ${MINIMUM_VERSION} --json --all`
|
||||
LATEST_VERSIONS=`npx unity-changeset@latest list --versions --latest-patch --min ${MINIMUM_VERSION} --json --all`
|
||||
if [ "${{ inputs.usePeriodVersions }}" = "true" ]; then
|
||||
ADDITIONAL_VERSIONS=`npx unity-changeset list --versions --grep '0f' --min ${MINIMUM_VERSION} --json`
|
||||
else
|
||||
@@ -72,11 +72,11 @@ jobs:
|
||||
steps:
|
||||
- name: 🚚 Checkout ($${{ github.ref }})
|
||||
if: github.event_name == 'push'
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: 🚚 Checkout pull request (pull_request_target)
|
||||
if: github.event_name == 'pull_request_target'
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
@@ -86,19 +86,20 @@ jobs:
|
||||
run: |
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git merge origin/${{ github.event.pull_request.base.ref }} --no-edit
|
||||
git rebase ${{ github.event.pull_request.base.sha }}
|
||||
git log --oneline -n 10
|
||||
|
||||
- name: 📥 Cache library
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.unityVersion }}-${{ github.event.pull_request.head.sha || github.sha }}
|
||||
path: ${{ env.PROJECT_PATH }}/Library
|
||||
key: ${{ env.PROJECT_PATH }}-Library-${{ matrix.unityVersion }}-${{ github.event.pull_request.head.sha || github.sha }}
|
||||
restore-keys: |
|
||||
Library-${{ matrix.unityVersion }}-
|
||||
Library-
|
||||
${{ env.PROJECT_PATH }}-Library-${{ matrix.unityVersion }}-
|
||||
${{ env.PROJECT_PATH }}-Library-
|
||||
|
||||
- name: 🛠️ Build Unity Project (Test)
|
||||
uses: game-ci/unity-builder@v4
|
||||
uses: game-ci/unity-builder@main
|
||||
timeout-minutes: 45
|
||||
with:
|
||||
customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unityVersion }}
|
||||
|
||||
@@ -9,7 +9,7 @@ env:
|
||||
# MINIMUM_VERSION: The minimum version of Unity.
|
||||
MINIMUM_VERSION: 2020.3
|
||||
# EXCLUDE_FILTER: The excluded versions of Unity.
|
||||
EXCLUDE_FILTER: "(2020.2.0|2021.1|2023.2|2023.3)"
|
||||
EXCLUDE_FILTER: "(2017|2018|2023.3)"
|
||||
PROJECT_PATH: .
|
||||
|
||||
on:
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
id: setup
|
||||
run: |
|
||||
echo "==== Target Unity Versions ===="
|
||||
LATEST_VERSIONS=`npx unity-changeset list --versions --latest-patch --min ${MINIMUM_VERSION} --json --all`
|
||||
LATEST_VERSIONS=`npx unity-changeset@latest list --versions --latest-patch --min ${MINIMUM_VERSION} --json --all`
|
||||
if [ "${{ inputs.usePeriodVersions }}" = "true" ]; then
|
||||
ADDITIONAL_VERSIONS=`npx unity-changeset list --versions --grep '0f' --min ${MINIMUM_VERSION} --json`
|
||||
else
|
||||
@@ -72,11 +72,11 @@ jobs:
|
||||
steps:
|
||||
- name: 🚚 Checkout ($${{ github.ref }})
|
||||
if: github.event_name == 'push'
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: 🚚 Checkout pull request (pull_request_target)
|
||||
if: github.event_name == 'pull_request_target'
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
@@ -92,14 +92,14 @@ jobs:
|
||||
- name: 📥 Cache library
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.unityVersion }}-${{ github.event.pull_request.head.sha || github.sha }}
|
||||
path: ${{ env.PROJECT_PATH }}/Library
|
||||
key: ${{ env.PROJECT_PATH }}-Library-${{ matrix.unityVersion }}-${{ github.event.pull_request.head.sha || github.sha }}
|
||||
restore-keys: |
|
||||
Library-${{ matrix.unityVersion }}-
|
||||
Library-
|
||||
${{ env.PROJECT_PATH }}-Library-${{ matrix.unityVersion }}-
|
||||
${{ env.PROJECT_PATH }}-Library-
|
||||
|
||||
- name: 🛠️ Build Unity Project (Test)
|
||||
uses: game-ci/unity-builder@v4
|
||||
uses: game-ci/unity-builder@main
|
||||
timeout-minutes: 45
|
||||
with:
|
||||
customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unityVersion }}
|
||||
|
||||
@@ -1,3 +1,93 @@
|
||||
## [5.10.3](https://github.com/mob-sakai/UIEffect/compare/5.10.2...5.10.3) (2025-10-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* displays as black rectangle when opening editor ([4a8d341](https://github.com/mob-sakai/UIEffect/commit/4a8d341625f73d70c512f7e6f0b864be1adbf459)), closes [#376](https://github.com/mob-sakai/UIEffect/issues/376)
|
||||
|
||||
## [5.10.2](https://github.com/mob-sakai/UIEffect/compare/5.10.1...5.10.2) (2025-10-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [improve performance] code optimization ([e6fb78a](https://github.com/mob-sakai/UIEffect/commit/e6fb78a0f67ed6f70be08259f674ab2f83364bd7))
|
||||
|
||||
## [5.10.1](https://github.com/mob-sakai/UIEffect/compare/5.10.0...5.10.1) (2025-10-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [improve performance] `UpdateViewMatrix` is called even though (direct-)parent canvas is disabled ([533d7b8](https://github.com/mob-sakai/UIEffect/commit/533d7b8c0a33871b1849fbda862d4fa1899822f4)), closes [#373](https://github.com/mob-sakai/UIEffect/issues/373)
|
||||
|
||||
# [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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* prefabs will be deselected when editing them ([8addbad](https://github.com/mob-sakai/UIEffect/commit/8addbad4941340807d824e295280473d197d889f)), closes [#354](https://github.com/mob-sakai/UIEffect/issues/354)
|
||||
|
||||
# [5.9.0](https://github.com/mob-sakai/UIEffect/compare/5.8.7...5.9.0) (2025-06-09)
|
||||
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||

|
||||
|
||||
- **Transition Filter**: `None`, `Fade`, `Cutoff`, `Dissolve`, `Shiny`, `Mask`, `Melt`, `Burn`, `Blaze`, `Pattern`
|
||||

|
||||

|
||||
- **Transition Rate**: 0.0 (no effect) - 1.0 (full effect).
|
||||
- **Transition Tex**: The texture used for the transition filter.
|
||||
- **Scale**, **Offset**, **Speed**, **Rotation**, **Keep Aspect Ratio**, **Reverse**: Additional properties for the texture.
|
||||
@@ -339,7 +339,7 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||

|
||||
|
||||
- **Gradation Mode**: `None`, `Horizontal`, `HorizontalGradient`, `Vertical`, `VerticalGradient`, `Radial`, `RadialGradient`, `Diagonal`, `DiagonalToRightBottom`, `DiagonalToLeftBottom`, `Angle`, `AngleGradient`
|
||||

|
||||

|
||||
- **Gradation Color Filter**: `None`, `Multiply`, `Additive`, `Subtractive`, `Replace`, `Multiply Luminance`, `Multiply Additive`
|
||||
- **Gradation Gradient**: The gradient of the gradation. HDR colors are supported.
|
||||
- `Blend` and `Fixed` modes are available.
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -20,16 +20,18 @@ namespace Coffee.UIEffectInternal
|
||||
UpdateTmpCgincPath();
|
||||
}
|
||||
|
||||
private static void OnPostprocessAllAssets(string[] _, string[] __, string[] ___, string[] ____)
|
||||
private static void OnPostprocessAllAssets(string[] imported, string[] __, string[] ___, string[] ____)
|
||||
{
|
||||
UpdateTmpCgincPath();
|
||||
if (imported.Any(x => x.EndsWith(".cginc") || x.EndsWith(".shader")))
|
||||
{
|
||||
UpdateTmpCgincPath();
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateTmpCgincPath()
|
||||
{
|
||||
if (s_CgincPattern == null || s_ShaderNames == null || s_ShaderNames.Length == 0) return;
|
||||
|
||||
AssetDatabase.StartAssetEditing();
|
||||
string[] cgincs = null;
|
||||
foreach (var shaderName in s_ShaderNames)
|
||||
{
|
||||
@@ -47,8 +49,6 @@ namespace Coffee.UIEffectInternal
|
||||
|
||||
UpdateTmpCgincPath(shader, cgincs);
|
||||
}
|
||||
|
||||
AssetDatabase.StopAssetEditing();
|
||||
}
|
||||
|
||||
private static void UpdateTmpCgincPath(Shader shader, string[] cgincs)
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Coffee.UIEffectInternal
|
||||
/// <summary>
|
||||
/// Object pool.
|
||||
/// </summary>
|
||||
internal class InternalObjectPool<T> where T : class
|
||||
internal sealed class InternalObjectPool<T> where T : class
|
||||
{
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
private readonly Predicate<T> _onValid; // Delegate for checking if instances are valid
|
||||
|
||||
@@ -6,6 +6,7 @@ using UnityEngine.Profiling;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
@@ -16,7 +17,7 @@ using Object = UnityEngine.Object;
|
||||
namespace Coffee.UIEffectInternal
|
||||
{
|
||||
[Serializable]
|
||||
public class ShaderVariantRegistry
|
||||
public sealed class ShaderVariantRegistry
|
||||
{
|
||||
[Serializable]
|
||||
internal class StringPair : IEquatable<StringPair>
|
||||
@@ -26,9 +27,7 @@ namespace Coffee.UIEffectInternal
|
||||
|
||||
public bool Equals(StringPair other)
|
||||
{
|
||||
if (other == null) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return key == other.key && value == other.value;
|
||||
return other != null && key == other.key && value == other.value;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
@@ -88,15 +87,15 @@ namespace Coffee.UIEffectInternal
|
||||
|
||||
// Find optional shader.
|
||||
Shader optionalShader;
|
||||
foreach (var pair in m_OptionalShaders)
|
||||
var count = m_OptionalShaders.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var pair = m_OptionalShaders[i];
|
||||
if (pair.key != shaderName) continue;
|
||||
optionalShader = Shader.Find(pair.value);
|
||||
if (optionalShader)
|
||||
{
|
||||
_cachedOptionalShaders[id] = pair.value;
|
||||
return optionalShader;
|
||||
}
|
||||
if (!optionalShader) continue;
|
||||
_cachedOptionalShaders[id] = pair.value;
|
||||
return optionalShader;
|
||||
}
|
||||
|
||||
// Find optional shader by format.
|
||||
@@ -122,10 +121,15 @@ namespace Coffee.UIEffectInternal
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private readonly HashSet<StringPair> _logVariants = new HashSet<StringPair>();
|
||||
private readonly StringBuilder _sb = new StringBuilder(1024);
|
||||
|
||||
private readonly Dictionary<Hash128, (ShaderVariantCollection.ShaderVariant, StringPair)> _cachedVariants =
|
||||
new Dictionary<Hash128, (ShaderVariantCollection.ShaderVariant, StringPair)>();
|
||||
|
||||
public void ClearCache()
|
||||
{
|
||||
_cachedOptionalShaders.Clear();
|
||||
_cachedVariants.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -213,21 +217,10 @@ namespace Coffee.UIEffectInternal
|
||||
if (!material || !material.shader || !m_Asset) return;
|
||||
|
||||
Profiler.BeginSample("(EDITOR/COF)[ShaderVariantRegistry] RegisterVariant");
|
||||
var shaderName = material.shader.name;
|
||||
var validKeywords = material.shaderKeywords
|
||||
.Where(x => !Regex.IsMatch(x, "(_EDITOR|EDITOR_)"))
|
||||
.ToArray();
|
||||
var keywords = string.Join(" ", validKeywords);
|
||||
var variant = new ShaderVariantCollection.ShaderVariant
|
||||
{
|
||||
shader = material.shader,
|
||||
keywords = validKeywords
|
||||
};
|
||||
|
||||
// Already registered.
|
||||
var pair = new StringPair() { key = shaderName, value = keywords };
|
||||
var (variant, pair) = GetVariant(material);
|
||||
if (m_Asset.Contains(variant))
|
||||
{
|
||||
// Already registered.
|
||||
m_UnregisteredVariants.Remove(pair);
|
||||
Profiler.EndSample();
|
||||
return;
|
||||
@@ -243,7 +236,8 @@ namespace Coffee.UIEffectInternal
|
||||
|
||||
if (_logVariants.Add(pair))
|
||||
{
|
||||
keywords = string.IsNullOrEmpty(keywords) ? "no keywords" : keywords;
|
||||
var shaderName = pair.key;
|
||||
var keywords = string.IsNullOrEmpty(pair.value) ? "no keywords" : pair.value;
|
||||
Debug.LogError($"Shader variant '{shaderName} <{keywords}>' is not registered.\n" +
|
||||
$"Register it in 'ProjectSettings > {path}' to use it in player.", m_Asset);
|
||||
}
|
||||
@@ -256,6 +250,44 @@ namespace Coffee.UIEffectInternal
|
||||
m_UnregisteredVariants.Remove(pair);
|
||||
Profiler.EndSample();
|
||||
}
|
||||
|
||||
private (ShaderVariantCollection.ShaderVariant, StringPair) GetVariant(Material material)
|
||||
{
|
||||
Profiler.BeginSample("(EDITOR/COF)[ShaderVariantRegistry] GetVariant");
|
||||
var shader = material.shader;
|
||||
_sb.Length = 0;
|
||||
foreach (var keyword in material.shaderKeywords)
|
||||
{
|
||||
// Ignore editor keyword.
|
||||
if (keyword.Contains("_EDITOR") || keyword.Contains("EDITOR_")) continue;
|
||||
|
||||
_sb.Append(keyword);
|
||||
_sb.Append(' ');
|
||||
}
|
||||
|
||||
if (0 < _sb.Length)
|
||||
{
|
||||
_sb.Length--; // Remove last space.
|
||||
}
|
||||
|
||||
var hash = new Hash128((uint)shader.GetInstanceID(), (uint)_sb.GetHashCode(), 0, 0);
|
||||
if (_cachedVariants.TryGetValue(hash, out var result))
|
||||
{
|
||||
Profiler.EndSample();
|
||||
return result;
|
||||
}
|
||||
|
||||
var pair = new StringPair() { key = shader.name, value = _sb.ToString() };
|
||||
var variant = new ShaderVariantCollection.ShaderVariant
|
||||
{
|
||||
shader = shader,
|
||||
keywords = pair.value.Split(' ')
|
||||
};
|
||||
|
||||
_cachedVariants.Add(hash, (variant, pair));
|
||||
Profiler.EndSample();
|
||||
return (variant, pair);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Coffee.UIEffects
|
||||
[Icon("Packages/com.coffee.ui-effect/Editor/UIEffectIconIcon.png")]
|
||||
[ExecuteAlways]
|
||||
[DisallowMultipleComponent]
|
||||
public class UIEffect : UIEffectBase
|
||||
public sealed class UIEffect : UIEffectBase
|
||||
{
|
||||
[SerializeField]
|
||||
protected ToneFilter m_ToneFilter = ToneFilter.None;
|
||||
@@ -1494,7 +1494,8 @@ namespace Coffee.UIEffects
|
||||
public override void SetVerticesDirty()
|
||||
{
|
||||
base.SetVerticesDirty();
|
||||
for (var i = 0; i < replicas.Count; i++)
|
||||
var count = replicas.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
if (!replicas[i]) continue;
|
||||
replicas[i].SetVerticesDirty();
|
||||
@@ -1504,7 +1505,8 @@ namespace Coffee.UIEffects
|
||||
public override void SetMaterialDirty()
|
||||
{
|
||||
base.SetMaterialDirty();
|
||||
for (var i = 0; i < replicas.Count; i++)
|
||||
var count = replicas.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
if (!replicas[i]) continue;
|
||||
replicas[i].SetMaterialDirty();
|
||||
@@ -1519,6 +1521,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 +1540,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>
|
||||
@@ -1557,7 +1581,8 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
base.ApplyContextToMaterial(material);
|
||||
|
||||
for (var i = 0; i < replicas.Count; i++)
|
||||
var count = replicas.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
if (!replicas[i]) continue;
|
||||
replicas[i].ApplyContextToMaterial(material);
|
||||
|
||||
@@ -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 =
|
||||
@@ -32,6 +32,8 @@ namespace Coffee.UIEffects
|
||||
private Action _onAfterCanvasRebuild;
|
||||
private bool _canModifyMesh;
|
||||
private Matrix4x4 _prevTransformHash;
|
||||
private Canvas _canvas;
|
||||
private bool _canvasCached = false;
|
||||
|
||||
public Material effectMaterial => _material;
|
||||
public Graphic graphic => _graphic ? _graphic : _graphic = GetComponent<Graphic>();
|
||||
@@ -39,6 +41,23 @@ namespace Coffee.UIEffects
|
||||
public virtual float actualSamplingScale => 1;
|
||||
public virtual bool canModifyShape => true;
|
||||
|
||||
protected Canvas canvas
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_canvasCached) return _canvas;
|
||||
|
||||
_canvasCached = true;
|
||||
_canvas = GetComponentInParent<Canvas>();
|
||||
if (!_canvas || !_canvas.isActiveAndEnabled)
|
||||
{
|
||||
_canvas = null;
|
||||
}
|
||||
|
||||
return _canvas;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual UIEffectContext context
|
||||
{
|
||||
get
|
||||
@@ -104,7 +123,7 @@ namespace Coffee.UIEffects
|
||||
s_ContextPool.Return(ref _context);
|
||||
}
|
||||
|
||||
protected virtual void OnBeforeCanvasRebuild()
|
||||
private void OnBeforeCanvasRebuild()
|
||||
{
|
||||
// If the mesh is not modified in the previous frame, try to modify it if possible.
|
||||
if (!_canModifyMesh && CanModifyMesh())
|
||||
@@ -114,11 +133,18 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnAfterCanvasRebuild()
|
||||
private void OnAfterCanvasRebuild()
|
||||
{
|
||||
if (!_material || !graphic || !graphic.canvas || context == null) return;
|
||||
if (!_material || !graphic || !canvas || context == null) return;
|
||||
if (!context.useViewMatrix) return;
|
||||
|
||||
context.UpdateViewMatrix(GetCurrentMaterial(), transitionRoot, graphic.canvas.rootCanvas);
|
||||
context.UpdateViewMatrix(GetCurrentMaterial(), transitionRoot, canvas.rootCanvas);
|
||||
}
|
||||
|
||||
protected override void OnCanvasHierarchyChanged()
|
||||
{
|
||||
_canvasCached = false;
|
||||
_canvas = null;
|
||||
}
|
||||
|
||||
public void ModifyMesh(Mesh mesh)
|
||||
@@ -132,13 +158,14 @@ namespace Coffee.UIEffects
|
||||
_canModifyMesh = CanModifyMesh();
|
||||
if (_canModifyMesh)
|
||||
{
|
||||
context.ModifyMesh(graphic, transitionRoot, vh, canModifyShape);
|
||||
context.ModifyMesh(graphic, canvas, transitionRoot, vh, canModifyShape);
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanModifyMesh()
|
||||
{
|
||||
if (!graphic || !graphic.isActiveAndEnabled) return false;
|
||||
if (!isActiveAndEnabled) return false;
|
||||
|
||||
// The transitionRoot is same as the transform => true.
|
||||
var root = transitionRoot;
|
||||
|
||||
@@ -8,7 +8,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
public class UIEffectContext
|
||||
public sealed class UIEffectContext
|
||||
{
|
||||
private static readonly UIEffectContext s_DefaultContext = new UIEffectContext();
|
||||
private static readonly List<UIVertex> s_WorkingVertices = new List<UIVertex>(1024 * 8);
|
||||
@@ -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;
|
||||
@@ -446,7 +451,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (!material) return;
|
||||
|
||||
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
|
||||
Profiler.BeginSample("(UIE)[UIEffect] ApplyToMaterial");
|
||||
|
||||
material.SetInt(s_SrcBlend, (int)m_SrcBlendMode);
|
||||
material.SetInt(s_DstBlend, (int)m_DstBlendMode);
|
||||
@@ -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,
|
||||
@@ -597,16 +602,17 @@ namespace Coffee.UIEffects
|
||||
scale.y = 0 != (m_Flip & Flip.Vertical) ? -scale.y : scale.y;
|
||||
}
|
||||
|
||||
var pivot = new Vector2(0.5f, 0.5f);
|
||||
var offset = (transitionRoot.pivot - pivot) * size;
|
||||
var pivot = new Vector3(0.5f, 0.5f);
|
||||
var offset = (transitionRoot.pivot - (Vector2)pivot) * size;
|
||||
var w2LMat = Matrix4x4.Translate(offset) * transitionRoot.worldToLocalMatrix;
|
||||
|
||||
var rootRotation = Quaternion.Euler(0, 0, m_TransitionRotation);
|
||||
var rootScale = 1f / GetMultiplier(m_TransitionRotation);
|
||||
material.SetMatrix(s_RootViewMatrix, Matrix4x4.TRS(pivot, rootRotation, scale * rootScale) * w2LMat);
|
||||
|
||||
var gradRotation = Quaternion.Euler(0, 0, GetGradationRotation());
|
||||
var gradScale = 1f / GetMultiplier(GetGradationRotation());
|
||||
var rotation = GetGradationRotation();
|
||||
var gradRotation = Quaternion.Euler(0, 0, rotation);
|
||||
var gradScale = 1f / GetMultiplier(rotation);
|
||||
material.SetMatrix(s_GradViewMatrix, Matrix4x4.TRS(pivot, gradRotation, scale * gradScale) * w2LMat);
|
||||
|
||||
if (m_ShadowMode == ShadowMode.Mirror)
|
||||
@@ -615,22 +621,25 @@ namespace Coffee.UIEffects
|
||||
var mirrorOffset = new Vector3(0, size.y / 2 * (mirrorInv + 1) - m_ShadowDistance.y * mirrorInv, 0);
|
||||
var mirrorScale = new Vector3(1, mirrorInv, 1);
|
||||
var udScale = new Vector3(scale.x, -scale.y, scale.z);
|
||||
material.SetMatrix(s_MirrorRootViewMatrix,
|
||||
Matrix4x4.TRS(pivot, rootRotation, udScale * rootScale)
|
||||
* Matrix4x4.TRS(mirrorOffset, Quaternion.identity, mirrorScale) * w2LMat);
|
||||
material.SetMatrix(s_MirrorGradViewMatrix,
|
||||
Matrix4x4.TRS(pivot, gradRotation, udScale * gradScale)
|
||||
* Matrix4x4.TRS(mirrorOffset, Quaternion.identity, mirrorScale) * w2LMat);
|
||||
var mirrorTranslation = Matrix4x4.TRS(mirrorOffset, Quaternion.identity, mirrorScale) * w2LMat;
|
||||
material.SetMatrix(
|
||||
s_MirrorRootViewMatrix,
|
||||
Matrix4x4.TRS(pivot, rootRotation, udScale * rootScale) * mirrorTranslation
|
||||
);
|
||||
material.SetMatrix(
|
||||
s_MirrorGradViewMatrix,
|
||||
Matrix4x4.TRS(pivot, gradRotation, udScale * gradScale) * mirrorTranslation
|
||||
);
|
||||
}
|
||||
|
||||
if (canvas.renderMode == RenderMode.ScreenSpaceOverlay || !canvas.worldCamera)
|
||||
{
|
||||
material.SetMatrix(s_CanvasToWorldMatrix, canvas.transform.localToWorldMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.SetMatrix(s_CanvasToWorldMatrix, Matrix4x4.identity);
|
||||
}
|
||||
var useIdentity =
|
||||
canvas.renderMode == RenderMode.WorldSpace ||
|
||||
(canvas.renderMode != RenderMode.ScreenSpaceOverlay && canvas.worldCamera);
|
||||
|
||||
material.SetMatrix(
|
||||
s_CanvasToWorldMatrix,
|
||||
useIdentity ? Matrix4x4.identity : canvas.transform.localToWorldMatrix
|
||||
);
|
||||
}
|
||||
|
||||
private Vector4 GetGradationScaleAndOffset()
|
||||
@@ -682,22 +691,27 @@ namespace Coffee.UIEffects
|
||||
return Mathf.Max(Mathf.Abs(cos - sin), Mathf.Abs(cos + sin));
|
||||
}
|
||||
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
private static void SetKeyword(Material material, Span<string> keywords, int index)
|
||||
#else
|
||||
private static void SetKeyword(Material material, string[] keywords, int index)
|
||||
#endif
|
||||
{
|
||||
for (var i = 0; i < keywords.Length; i++)
|
||||
var length = keywords.Length;
|
||||
if (index < length && !string.IsNullOrEmpty(keywords[index]))
|
||||
{
|
||||
if (i != index)
|
||||
{
|
||||
material.DisableKeyword(keywords[i]);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(keywords[i]))
|
||||
{
|
||||
material.EnableKeyword(keywords[i]);
|
||||
}
|
||||
material.EnableKeyword(keywords[index]);
|
||||
}
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
if (i == index) continue;
|
||||
material.DisableKeyword(keywords[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void ModifyMesh(Graphic graphic, RectTransform transitionRoot, VertexHelper vh, bool canModifyShape)
|
||||
public void ModifyMesh(Graphic graphic, Canvas canvas, RectTransform transitionRoot, VertexHelper vh,
|
||||
bool canModifyShape)
|
||||
{
|
||||
// Apply flip (without effect).
|
||||
ApplyFlipWithoutEffect(vh, m_Flip);
|
||||
@@ -707,7 +721,7 @@ namespace Coffee.UIEffects
|
||||
|
||||
var effectProxy = GraphicProxy.Find(graphic);
|
||||
var isText = effectProxy.IsText(graphic);
|
||||
effectProxy.OnPreModifyMesh(graphic);
|
||||
effectProxy.OnPreModifyMesh(graphic, canvas);
|
||||
|
||||
var verts = s_WorkingVertices;
|
||||
var expandSize = effectProxy.ModifyExpandSize(graphic, GetExpandSize(canModifyShape));
|
||||
@@ -830,5 +844,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
|
||||
@@ -191,6 +191,15 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh all UI Graphics in the opened scenes. (#376)
|
||||
EditorApplication.delayCall += () =>
|
||||
{
|
||||
foreach (var g in Misc.FindObjectsOfType<UnityEngine.UI.Graphic>())
|
||||
{
|
||||
g.SetAllDirty();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[Icon("Packages/com.coffee.ui-effect/Editor/UIEffectIconIcon.png")]
|
||||
public class UIEffectReplica : UIEffectBase, ISerializationCallbackReceiver
|
||||
public sealed class UIEffectReplica : UIEffectBase, ISerializationCallbackReceiver
|
||||
{
|
||||
[SerializeField] private UIEffect m_Target;
|
||||
[SerializeField] private UIEffectPreset m_Preset;
|
||||
@@ -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,26 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public override RectTransform transitionRoot => useTargetTransform && isTargetInScene
|
||||
? target.transitionRoot
|
||||
: m_CustomRoot
|
||||
? m_CustomRoot
|
||||
: transform as RectTransform;
|
||||
public override RectTransform transitionRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
if (useTargetTransform)
|
||||
{
|
||||
if (preset && !m_CustomRoot && graphic && canvas)
|
||||
{
|
||||
return canvas.transform as RectTransform;
|
||||
}
|
||||
|
||||
if (isTargetInScene)
|
||||
{
|
||||
return target.transitionRoot;
|
||||
}
|
||||
}
|
||||
|
||||
return m_CustomRoot ? m_CustomRoot : transform as RectTransform;
|
||||
}
|
||||
}
|
||||
|
||||
private bool isTargetInScene => target && target.gameObject.scene.IsValid();
|
||||
|
||||
@@ -167,9 +187,9 @@ namespace Coffee.UIEffects
|
||||
target.SetEnablePreviewIfSelected(selection);
|
||||
}
|
||||
// Following the preset/preset-target.
|
||||
else if (context != null)
|
||||
else
|
||||
{
|
||||
context.SetEnablePreview(selection.Contains(gameObject), effectMaterial);
|
||||
context?.SetEnablePreview(selection.Contains(gameObject), effectMaterial);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -15,8 +15,10 @@ namespace Coffee.UIEffects
|
||||
public static void Register(GraphicProxy proxy)
|
||||
{
|
||||
// Register only once.
|
||||
foreach (var p in s_Proxies)
|
||||
var count = s_Proxies.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var p = s_Proxies[i];
|
||||
if (p.GetType() == proxy.GetType()) return;
|
||||
}
|
||||
|
||||
@@ -27,7 +29,8 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (!graphic) return null;
|
||||
|
||||
for (var i = s_Proxies.Count - 1; i >= 0; i--)
|
||||
var count = s_Proxies.Count;
|
||||
for (var i = count - 1; i >= 0; i--)
|
||||
{
|
||||
var p = s_Proxies[i];
|
||||
if (p.IsValid(graphic)) return p;
|
||||
@@ -55,13 +58,12 @@ namespace Coffee.UIEffects
|
||||
/// <summary>
|
||||
/// Called before modifying the mesh.
|
||||
/// </summary>
|
||||
public virtual void OnPreModifyMesh(Graphic graphic)
|
||||
public virtual void OnPreModifyMesh(Graphic graphic, Canvas canvas)
|
||||
{
|
||||
UIVertexUtil.onLerpVertex = s_OnLerpVertex;
|
||||
ShadowUtil.onMarkAsShadow = s_OnMarkAsShadow;
|
||||
UIEffectContext.onModifyVertex = s_OnModifyVertex;
|
||||
|
||||
var canvas = graphic.canvas;
|
||||
if (canvas)
|
||||
{
|
||||
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord1;
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
internal class ImageProxy : GraphicProxy
|
||||
internal sealed class ImageProxy : GraphicProxy
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[InitializeOnLoadMethod]
|
||||
|
||||
@@ -10,7 +10,7 @@ using Object = UnityEngine.Object;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
internal class TmpProxy : GraphicProxy
|
||||
internal sealed class TmpProxy : GraphicProxy
|
||||
{
|
||||
/// <summary>
|
||||
/// Check if the graphic is valid for this proxy.
|
||||
@@ -40,13 +40,12 @@ namespace Coffee.UIEffects
|
||||
/// <summary>
|
||||
/// Called before modifying the mesh.
|
||||
/// </summary>
|
||||
public override void OnPreModifyMesh(Graphic graphic)
|
||||
public override void OnPreModifyMesh(Graphic graphic, Canvas canvas)
|
||||
{
|
||||
UIVertexUtil.onLerpVertex = s_OnLerpVertex;
|
||||
ShadowUtil.onMarkAsShadow = s_OnMarkAsShadow;
|
||||
UIEffectContext.onModifyVertex = s_OnModifyVertex;
|
||||
|
||||
var canvas = graphic.canvas;
|
||||
if (canvas)
|
||||
{
|
||||
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord2;
|
||||
@@ -131,7 +130,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 +145,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 +231,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 +272,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
|
||||
}
|
||||
@@ -786,7 +608,7 @@ half4 uieffect(half4 origin, float2 uv, float4 uvMask, float4 wpos)
|
||||
uvGrad = saturate(mul(_MirrorGradViewMatrix, wpos)).xy;
|
||||
uvMask.x += 4;
|
||||
}
|
||||
|
||||
|
||||
const float isShadow = uvMask.x < 0 ? 1 : 0;
|
||||
uvMask.x += isShadow * 2;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ Shader "CustomRenderTexture/UIEffect/Multiply (Alpha)"
|
||||
[Header(Main)]
|
||||
_MainTex ("Main Texture", 2D) = "white" {}
|
||||
_MainTex_Speed ("Main Texture Speed", Vector) = (0,0,0,0)
|
||||
|
||||
|
||||
[Header(Detail)]
|
||||
_DetailTex ("Detail Texture", 2D) = "white" {}
|
||||
_DetailTex_Speed ("Detail Texture Speed", Vector) = (0,0,0,0)
|
||||
|
||||
@@ -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.0",
|
||||
"version": "5.10.3",
|
||||
"unity": "2020.3",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user