Compare commits

..

33 Commits

Author SHA1 Message Date
semantic-release-bot a2c550c523 chore(release): 5.10.9 [skip ci]
## [5.10.9](https://github.com/mob-sakai/UIEffect/compare/5.10.8...5.10.9) (2026-06-08)

### Bug Fixes

* ambiguous call to 'lerp' in shader ([cd68b36](https://github.com/mob-sakai/UIEffect/commit/cd68b364c48e979d6ef227e53a522f096e0df47a)), closes [#390](https://github.com/mob-sakai/UIEffect/issues/390)
* Clarify that the `ShaderGraph support` is available only in Unity 2023.2/6.0 or later ([57031c3](https://github.com/mob-sakai/UIEffect/commit/57031c3e3c2d64ee76d3e568d378cd54a5e84af5)), closes [#391](https://github.com/mob-sakai/UIEffect/issues/391)
* support Unity 6.5 or later ([2d6f7ed](https://github.com/mob-sakai/UIEffect/commit/2d6f7ed63dd83b3f90c2fa6d93a3c84afd6de866)), closes [#392](https://github.com/mob-sakai/UIEffect/issues/392) [#398](https://github.com/mob-sakai/UIEffect/issues/398)
* UIEffect.detailColor is not working ([f3da972](https://github.com/mob-sakai/UIEffect/commit/f3da972c0cba526f7784207c2d8ab48b5dd692f3)), closes [#399](https://github.com/mob-sakai/UIEffect/issues/399)
2026-06-08 09:57:55 +00:00
mob-sakai 44cf12173f chore: ignore alpha for test 2026-06-08 17:41:24 +09:00
mob-sakai d7abcc47f1 update internal code 2026-06-08 17:41:24 +09:00
mob-sakai 57031c3e3c fix: Clarify that the ShaderGraph support is available only in Unity 2023.2/6.0 or later
close #391
2026-06-08 11:05:40 +09:00
mob-sakai cd68b364c4 fix: ambiguous call to 'lerp' in shader
close #390
2026-06-07 20:29:24 +09:00
mob-sakai f3da972c0c fix: UIEffect.detailColor is not working
close #399
2026-06-07 20:11:51 +09:00
mob-sakai 2d6f7ed63d fix: support Unity 6.5 or later
close #392, close #398
2026-06-07 20:06:44 +09:00
semantic-release-bot 70937d2ce3 chore(release): 5.10.8 [skip ci]
## [5.10.8](https://github.com/mob-sakai/UIEffect/compare/5.10.7...5.10.8) (2026-01-16)

### Bug Fixes

* Canvas not properly cached when objects are outside Canvas ([4a4e50e](https://github.com/mob-sakai/UIEffect/commit/4a4e50e01fb50925352c73b27901024494ae933c))
2026-01-16 02:26:09 +00:00
mob-sakai 4a4e50e01f fix: Canvas not properly cached when objects are outside Canvas 2026-01-16 11:24:57 +09:00
semantic-release-bot 815162eab9 chore(release): 5.10.7 [skip ci]
## [5.10.7](https://github.com/mob-sakai/UIEffect/compare/5.10.6...5.10.7) (2025-12-18)

### Bug Fixes

* support Unity 6000.4 ([7fc0c73](https://github.com/mob-sakai/UIEffect/commit/7fc0c7364d8dc39e26eac3c3b79797b139f09817))
2025-12-18 11:20:51 +00:00
mob-sakai 7fc0c7364d fix: support Unity 6000.4 2025-12-18 18:58:52 +09:00
semantic-release-bot 20e7f2fa61 chore(release): 5.10.6 [skip ci]
## [5.10.6](https://github.com/mob-sakai/UIEffect/compare/5.10.5...5.10.6) (2025-12-18)

### Bug Fixes

* fixed an issue where shader variants were not registered automatically ([6b79864](https://github.com/mob-sakai/UIEffect/commit/6b79864a394d79e6ad13f64af1d521fab1f781a7)), closes [#383](https://github.com/mob-sakai/UIEffect/issues/383)
2025-12-18 09:37:32 +00:00
mob-sakai 1b292febb7 chore: update package for development 2025-12-18 18:09:16 +09:00
mob-sakai 6b79864a39 fix: fixed an issue where shader variants were not registered automatically
close #383
2025-12-18 17:27:32 +09:00
semantic-release-bot 4e30651290 chore(release): 5.10.5 [skip ci]
## [5.10.5](https://github.com/mob-sakai/UIEffect/compare/5.10.4...5.10.5) (2025-11-20)

### Bug Fixes

* graphic disappears when changing filters from code ([8776057](https://github.com/mob-sakai/UIEffect/commit/87760570ec7f4e2ca395cfaa0d2ab5d28c9cf9f3)), closes [#382](https://github.com/mob-sakai/UIEffect/issues/382)
2025-11-20 08:12:42 +00:00
mob-sakai 87760570ec fix: graphic disappears when changing filters from code
close #382
2025-11-20 16:56:23 +09:00
semantic-release-bot ef7ac0aaad chore(release): 5.10.4 [skip ci]
## [5.10.4](https://github.com/mob-sakai/UIEffect/compare/5.10.3...5.10.4) (2025-10-27)

### Bug Fixes

* remove `sealed` from `UIEffect` and `UIEffectReplica` ([2fd87e9](https://github.com/mob-sakai/UIEffect/commit/2fd87e909af65bf88a9c39cd157dfb06a56b3af0)), closes [#379](https://github.com/mob-sakai/UIEffect/issues/379)
2025-10-27 10:51:01 +00:00
mob-sakai 2fd87e909a fix: remove sealed from UIEffect and UIEffectReplica
close #379
2025-10-27 19:15:42 +09:00
semantic-release-bot 2cc5c5b68e chore(release): 5.10.3 [skip ci]
## [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)
2025-10-22 11:29:36 +00:00
mob-sakai 4a8d341625 fix: displays as black rectangle when opening editor
close #376
2025-10-22 19:32:54 +09:00
semantic-release-bot a885fc5bc1 chore(release): 5.10.2 [skip ci]
## [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))
2025-10-16 08:11:18 +00:00
mob-sakai 4fdd9636fa chore: update workflow 2025-10-15 18:25:44 +09:00
mob-sakai 06a280ec5a style: format 2025-10-15 17:33:55 +09:00
45375dfhg e6fb78a0f6 fix: [improve performance] code optimization 2025-10-15 12:40:14 +09:00
semantic-release-bot 451cbe4302 chore(release): 5.10.1 [skip ci]
## [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)
2025-10-06 07:00:33 +00:00
mob-sakai 3cae638bdd chore: game-ci/unity-builder action no longer supports .Net3.5 2025-10-06 15:06:00 +09:00
mob-sakai 533d7b8c0a fix: [improve performance] UpdateViewMatrix is called even though (direct-)parent canvas is disabled
close #373
2025-10-06 10:23:40 +09:00
semantic-release-bot 9380f96572 chore(release): 5.10.0 [skip ci]
# [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))
2025-09-26 08:30:19 +00:00
mob-sakai b4adb32512 fix: display may disappear when using TMP SubMesh (multi-language or sprites, etc.)
close #372
2025-09-26 09:17:33 +09:00
mob-sakai 59874ddffe fix: TMP Text sprite submesh lost when changing fontMaterial
close #368
2025-09-25 19:26:50 +09:00
mob-sakai c4202b45d2 fix: TmpProxy causes loss of modifications from other IMeshModifiers
close #371
2025-09-25 19:25:58 +09:00
mob-sakai ce692580a3 feat: [improve performance] merged apply_color function and reduced shader compilation size 2025-09-01 19:06:48 +09:00
mob-sakai 6c808aa341 feat: [improve performance] various view matrices are only updated when necessary 2025-09-01 19:05:02 +09:00
32 changed files with 420 additions and 393 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ jobs:
find _site -name __MACOSX | xargs rm -rf
- name: 📦 Upload '_site'
uses: actions/upload-pages-artifact@v3
uses: actions/upload-pages-artifact@v5
- name: 🚀 Deploy To GitHub Pages
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v5
+2 -2
View File
@@ -25,10 +25,10 @@ jobs:
tag: ${{ steps.release.outputs.new_release_git_tag }}
steps:
- name: 🚚 Checkout (${{ github.ref_name }})
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: 🔖 Run semantic release
uses: cycjimmy/semantic-release-action@v4
uses: cycjimmy/semantic-release-action@v6
id: release
with:
working_directory: Packages/src
+13 -12
View File
@@ -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,9 +46,9 @@ 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 --ignore-alpha`
if [ "${{ inputs.usePeriodVersions }}" = "true" ]; then
ADDITIONAL_VERSIONS=`npx unity-changeset list --versions --grep '0f' --min ${MINIMUM_VERSION} --json`
ADDITIONAL_VERSIONS=`npx unity-changeset list --versions --grep '0f' --min ${MINIMUM_VERSION} --json --ignore-alpha`
else
ADDITIONAL_VERSIONS=[]
fi
@@ -72,11 +72,11 @@ jobs:
steps:
- name: 🚚 Checkout ($${{ github.ref }})
if: github.event_name == 'push'
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: 🚚 Checkout pull request (pull_request_target)
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
uses: actions/checkout@v6
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
uses: actions/cache@v5
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@v5
timeout-minutes: 45
with:
customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unityVersion }}
+11 -11
View File
@@ -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,9 +46,9 @@ 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 --ignore-alpha`
if [ "${{ inputs.usePeriodVersions }}" = "true" ]; then
ADDITIONAL_VERSIONS=`npx unity-changeset list --versions --grep '0f' --min ${MINIMUM_VERSION} --json`
ADDITIONAL_VERSIONS=`npx unity-changeset list --versions --grep '0f' --min ${MINIMUM_VERSION} --json --ignore-alpha`
else
ADDITIONAL_VERSIONS=[]
fi
@@ -72,11 +72,11 @@ jobs:
steps:
- name: 🚚 Checkout ($${{ github.ref }})
if: github.event_name == 'push'
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: 🚚 Checkout pull request (pull_request_target)
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
@@ -90,16 +90,16 @@ jobs:
git log --oneline -n 10
- name: 📥 Cache library
uses: actions/cache@v4
uses: actions/cache@v5
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@v5
timeout-minutes: 45
with:
customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unityVersion }}
+1 -1
View File
@@ -4,7 +4,7 @@
"com.coffee.minimal-resource": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/MinimalResource",
"com.coffee.nano-monitor": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/NanoMonitor",
"com.coffee.symbolic-linker": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/SymbolicLinker",
"com.unity.ide.rider": "3.0.36",
"com.unity.ide.rider": "3.0.38",
"com.unity.test-framework": "1.1.33",
"com.unity.textmeshpro": "3.0.9",
"com.unity.modules.animation": "1.0.0"
+1 -1
View File
@@ -46,7 +46,7 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "3.0.36",
"version": "3.0.38",
"depth": 0,
"source": "registry",
"dependencies": {
+81
View File
@@ -1,3 +1,84 @@
## [5.10.9](https://github.com/mob-sakai/UIEffect/compare/5.10.8...5.10.9) (2026-06-08)
### Bug Fixes
* ambiguous call to 'lerp' in shader ([cd68b36](https://github.com/mob-sakai/UIEffect/commit/cd68b364c48e979d6ef227e53a522f096e0df47a)), closes [#390](https://github.com/mob-sakai/UIEffect/issues/390)
* Clarify that the `ShaderGraph support` is available only in Unity 2023.2/6.0 or later ([57031c3](https://github.com/mob-sakai/UIEffect/commit/57031c3e3c2d64ee76d3e568d378cd54a5e84af5)), closes [#391](https://github.com/mob-sakai/UIEffect/issues/391)
* support Unity 6.5 or later ([2d6f7ed](https://github.com/mob-sakai/UIEffect/commit/2d6f7ed63dd83b3f90c2fa6d93a3c84afd6de866)), closes [#392](https://github.com/mob-sakai/UIEffect/issues/392) [#398](https://github.com/mob-sakai/UIEffect/issues/398)
* UIEffect.detailColor is not working ([f3da972](https://github.com/mob-sakai/UIEffect/commit/f3da972c0cba526f7784207c2d8ab48b5dd692f3)), closes [#399](https://github.com/mob-sakai/UIEffect/issues/399)
## [5.10.8](https://github.com/mob-sakai/UIEffect/compare/5.10.7...5.10.8) (2026-01-16)
### Bug Fixes
* Canvas not properly cached when objects are outside Canvas ([4a4e50e](https://github.com/mob-sakai/UIEffect/commit/4a4e50e01fb50925352c73b27901024494ae933c))
## [5.10.7](https://github.com/mob-sakai/UIEffect/compare/5.10.6...5.10.7) (2025-12-18)
### Bug Fixes
* support Unity 6000.4 ([7fc0c73](https://github.com/mob-sakai/UIEffect/commit/7fc0c7364d8dc39e26eac3c3b79797b139f09817))
## [5.10.6](https://github.com/mob-sakai/UIEffect/compare/5.10.5...5.10.6) (2025-12-18)
### Bug Fixes
* fixed an issue where shader variants were not registered automatically ([6b79864](https://github.com/mob-sakai/UIEffect/commit/6b79864a394d79e6ad13f64af1d521fab1f781a7)), closes [#383](https://github.com/mob-sakai/UIEffect/issues/383)
## [5.10.5](https://github.com/mob-sakai/UIEffect/compare/5.10.4...5.10.5) (2025-11-20)
### Bug Fixes
* graphic disappears when changing filters from code ([8776057](https://github.com/mob-sakai/UIEffect/commit/87760570ec7f4e2ca395cfaa0d2ab5d28c9cf9f3)), closes [#382](https://github.com/mob-sakai/UIEffect/issues/382)
## [5.10.4](https://github.com/mob-sakai/UIEffect/compare/5.10.3...5.10.4) (2025-10-27)
### Bug Fixes
* remove `sealed` from `UIEffect` and `UIEffectReplica` ([2fd87e9](https://github.com/mob-sakai/UIEffect/commit/2fd87e909af65bf88a9c39cd157dfb06a56b3af0)), closes [#379](https://github.com/mob-sakai/UIEffect/issues/379)
## [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)
+2
View File
@@ -514,6 +514,8 @@ Click the `Import` button.
### Usage with ShaderGraph
⚠️ ShaderGraph support is available only in Unity 2023.2/6.0 or later.
![](https://github.com/mob-sakai/mob-sakai/releases/download/docs/1744307236288.png)
To use UIEffect with ShaderGraph, you need to import additional resources.
@@ -38,7 +38,7 @@ namespace Coffee.UIEffectInternal
private static void GetComponentsInChildren_Internal<T>(this Component self, List<T> results, int depth)
where T : Component
{
if (!self || results == null || depth < 0) return;
if (self == null || results == null || depth < 0) return;
var tr = self.transform;
if (tr.TryGetComponent<T>(out var t))
@@ -59,7 +59,7 @@ namespace Coffee.UIEffectInternal
/// </summary>
public static T GetOrAddComponent<T>(this Component self) where T : Component
{
if (!self) return null;
if (self == null) return null;
return self.TryGetComponent<T>(out var component)
? component
: self.gameObject.AddComponent<T>();
@@ -166,7 +166,7 @@ namespace Coffee.UIEffectInternal
#if !UNITY_2021_2_OR_NEWER && !UNITY_2020_3_45 && !UNITY_2020_3_46 && !UNITY_2020_3_47 && !UNITY_2020_3_48
public static T GetComponentInParent<T>(this Component self, bool includeInactive) where T : Component
{
if (!self) return null;
if (self == null) return null;
if (!includeInactive) return self.GetComponentInParent<T>();
var current = self.transform;
@@ -186,7 +186,7 @@ namespace Coffee.UIEffectInternal
/// </summary>
internal static bool CanConvertTo<T>(this Object context) where T : MonoBehaviour
{
return context && context.GetType() != typeof(T);
return context != null && context.GetType() != typeof(T);
}
/// <summary>
@@ -37,7 +37,7 @@ namespace Coffee.UIEffectInternal
foreach (var t in TypeCache.GetTypesDerivedFrom(typeof(PreloadedProjectSettings<>)))
{
var defaultSettings = GetDefaultSettings(t);
if (!defaultSettings)
if (defaultSettings == null)
{
// When create a new instance, automatically set it as default settings.
defaultSettings = CreateInstance(t) as PreloadedProjectSettings;
@@ -48,7 +48,7 @@ namespace Coffee.UIEffectInternal
SetDefaultSettings(defaultSettings);
}
if (defaultSettings)
if (defaultSettings != null)
{
defaultSettings.OnInitialize();
}
@@ -66,7 +66,7 @@ namespace Coffee.UIEffectInternal
private static Object[] GetPreloadedSettings(Type type)
{
return PlayerSettings.GetPreloadedAssets()
.Where(x => x && x.GetType() == type)
.Where(x => x != null && x.GetType() == type)
.ToArray();
}
@@ -76,12 +76,12 @@ namespace Coffee.UIEffectInternal
?? AssetDatabase.FindAssets($"t:{nameof(PreloadedProjectSettings)}")
.Select(AssetDatabase.GUIDToAssetPath)
.Select(AssetDatabase.LoadAssetAtPath<PreloadedProjectSettings>)
.FirstOrDefault(x => x && x.GetType() == type);
.FirstOrDefault(x => x != null && x.GetType() == type);
}
protected static void SetDefaultSettings(PreloadedProjectSettings asset)
{
if (!asset) return;
if (asset == null) return;
var type = asset.GetType();
if (string.IsNullOrEmpty(AssetDatabase.GetAssetPath(asset)))
@@ -103,7 +103,7 @@ namespace Coffee.UIEffectInternal
var preloadedAssets = PlayerSettings.GetPreloadedAssets();
var projectSettings = GetPreloadedSettings(type);
PlayerSettings.SetPreloadedAssets(preloadedAssets
.Where(x => x)
.Where(x => x != null)
.Except(projectSettings.Except(new[] { asset }))
.Append(asset)
.Distinct()
@@ -133,19 +133,19 @@ namespace Coffee.UIEffectInternal
#if UNITY_EDITOR
private string _jsonText;
public static bool hasInstance => s_Instance;
public static bool hasInstance => s_Instance != null;
public static T instance
{
get
{
if (s_Instance) return s_Instance;
if (s_Instance != null) return s_Instance;
s_Instance = GetDefaultSettings(typeof(T)) as T;
if (s_Instance) return s_Instance;
if (s_Instance != null) return s_Instance;
s_Instance = CreateInstance<T>();
if (!s_Instance)
if (s_Instance == null)
{
s_Instance = null;
return s_Instance;
@@ -176,7 +176,7 @@ namespace Coffee.UIEffectInternal
}
}
#else
public static T instance => s_Instance ? s_Instance : s_Instance = CreateInstance<T>();
public static T instance => s_Instance != null ? s_Instance : s_Instance = CreateInstance<T>();
#endif
/// <summary>
@@ -185,7 +185,7 @@ namespace Coffee.UIEffectInternal
protected virtual void OnEnable()
{
#if UNITY_EDITOR
var isDefaultSettings = !s_Instance || s_Instance == this || GetDefaultSettings(typeof(T)) == this;
var isDefaultSettings = s_Instance == null || s_Instance == this || GetDefaultSettings(typeof(T)) == this;
if (!isDefaultSettings)
{
DestroyImmediate(this, true);
@@ -195,7 +195,7 @@ namespace Coffee.UIEffectInternal
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
#endif
if (s_Instance) return;
if (s_Instance != null) return;
s_Instance = this as T;
}
@@ -224,7 +224,7 @@ namespace Coffee.UIEffectInternal
public override void OnGUI(string searchContext)
{
if (!_target)
if (_target == null)
{
if (_editor)
{
@@ -11,7 +11,7 @@ using Conditional = System.Diagnostics.ConditionalAttribute;
namespace Coffee.UIEffectInternal
{
internal static class Logging
internal static class Logger
{
#if !ENABLE_COFFEE_LOGGER
private const string k_DisableSymbol = "DISABLE_COFFEE_LOGGER";
@@ -48,7 +48,7 @@ namespace Coffee.UIEffectInternal
public static void LogIf(bool enable, object tag, object message, Object context = null)
{
if (!enable) return;
Log_Internal(LogType.Log, tag, message, context ? context : tag as Object);
Log_Internal(LogType.Log, tag, message, context != null ? context : tag as Object);
}
#if !ENABLE_COFFEE_LOGGER
@@ -56,7 +56,7 @@ namespace Coffee.UIEffectInternal
#endif
public static void Log(object tag, object message, Object context = null)
{
Log_Internal(LogType.Log, tag, message, context ? context : tag as Object);
Log_Internal(LogType.Log, tag, message, context != null ? context : tag as Object);
}
#if !ENABLE_COFFEE_LOGGER
@@ -64,13 +64,13 @@ namespace Coffee.UIEffectInternal
#endif
public static void LogWarning(object tag, object message, Object context = null)
{
Log_Internal(LogType.Warning, tag, message, context ? context : tag as Object);
Log_Internal(LogType.Warning, tag, message, context != null ? context : tag as Object);
}
public static void LogError(object tag, object message, Object context = null)
{
#if ENABLE_COFFEE_LOGGER
Log_Internal(LogType.Error, tag, message, context ? context : tag as Object);
Log_Internal(LogType.Error, tag, message, context != null ? context : tag as Object);
#else
Debug.LogError($"{tag}: {message}", context);
#endif
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a2fa34e76bcd14489a1af18b393c3e65
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 7f0dee01a862040a58ac6b6057944cd3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -20,7 +20,9 @@ namespace Coffee.UIEffectInternal
{
public static T[] FindObjectsOfType<T>() where T : Object
{
#if UNITY_2023_1_OR_NEWER
#if UNITY_6000_4_OR_NEWER
return Object.FindObjectsByType<T>(FindObjectsInactive.Include);
#elif UNITY_2023_1_OR_NEWER
return Object.FindObjectsByType<T>(FindObjectsInactive.Include, FindObjectsSortMode.None);
#else
return Object.FindObjectsOfType<T>();
@@ -29,7 +31,7 @@ namespace Coffee.UIEffectInternal
public static void Destroy(Object obj)
{
if (!obj) return;
if (obj == null) return;
#if UNITY_EDITOR
if (!Application.isPlaying)
{
@@ -44,7 +46,7 @@ namespace Coffee.UIEffectInternal
public static void DestroyImmediate(Object obj)
{
if (!obj) return;
if (obj == null) return;
#if UNITY_EDITOR
if (Application.isEditor)
{
@@ -61,7 +63,7 @@ namespace Coffee.UIEffectInternal
public static void SetDirty(Object obj)
{
#if UNITY_EDITOR
if (!obj) return;
if (obj == null) return;
EditorUtility.SetDirty(obj);
#endif
}
@@ -117,11 +119,11 @@ namespace Coffee.UIEffectInternal
foreach (var type in types)
{
var script = scripts.FirstOrDefault(x => x.GetClass() == type);
if (!script) continue;
if (script == null) continue;
var path = type.GetCustomAttribute<IconAttribute>()?._path;
var icon = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
if (!icon) continue;
if (icon == null) continue;
s_SetIconForObject(script, icon);
}
@@ -34,7 +34,7 @@ namespace Coffee.UIEffectInternal
}
// If there are no instances in the pool, create a new one.
Logging.Log(this, $"A new instance is created (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
Logger.Log(this, $"A new instance is created (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
return _pool.Get();
}
@@ -47,7 +47,7 @@ namespace Coffee.UIEffectInternal
if (instance == null) return; // Ignore if already pooled or null.
_pool.Release(instance);
Logging.Log(this, $"An instance is released (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
Logger.Log(this, $"An instance is released (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
instance = default; // Set the reference to null.
}
#else
@@ -80,7 +80,7 @@ namespace Coffee.UIEffectInternal
}
// If there are no instances in the pool, create a new one.
Logging.Log(this, $"A new instance is created (pooled: {_pool.Count}, created: {++_count}).");
Logger.Log(this, $"A new instance is created (pooled: {_pool.Count}, created: {++_count}).");
return _onCreate();
}
@@ -94,7 +94,7 @@ namespace Coffee.UIEffectInternal
_onReturn(instance); // Return the instance to the pool.
_pool.Push(instance);
Logging.Log(this, $"An instance is released (pooled: {_pool.Count}, created: {_count}).");
Logger.Log(this, $"An instance is released (pooled: {_pool.Count}, created: {_count}).");
instance = default; // Set the reference to null.
}
#endif
@@ -90,7 +90,7 @@ namespace Coffee.UIEffectInternal
Profiler.BeginSample("(COF)[ObjectRepository] GetFromCache");
if (_cache.TryGetValue(hash, out var entry))
{
if (!entry.storedObject)
if (entry.storedObject == null)
{
Release(ref entry.storedObject);
Profiler.EndSample();
@@ -103,7 +103,7 @@ namespace Coffee.UIEffectInternal
Release(ref obj);
++entry.reference;
obj = entry.storedObject;
Logging.Log(_name, $"Get(total#{count}): {entry}");
Logger.Log(_name, $"Get(total#{count}): {entry}");
}
Profiler.EndSample();
@@ -116,7 +116,7 @@ namespace Coffee.UIEffectInternal
private void Add(Hash128 hash, ref T obj, T newObject)
{
if (!newObject)
if (newObject == null)
{
Release(ref obj);
obj = newObject;
@@ -130,8 +130,8 @@ namespace Coffee.UIEffectInternal
newEntry.hash = hash;
newEntry.reference = 1;
_cache[hash] = newEntry;
_objectKey[newObject.GetInstanceID()] = hash;
Logging.Log(_name, $"<color=#03c700>Add</color>(total#{count}): {newEntry}");
_objectKey[newObject.GetHashCode()] = hash;
Logger.Log(_name, $"<color=#03c700>Add</color>(total#{count}): {newEntry}");
Release(ref obj);
obj = newObject;
Profiler.EndSample();
@@ -146,23 +146,23 @@ namespace Coffee.UIEffectInternal
// Find and release the entry.
Profiler.BeginSample("(COF)[ObjectRepository] Release");
var id = obj.GetInstanceID();
var id = obj.GetHashCode();
if (_objectKey.TryGetValue(id, out var hash)
&& _cache.TryGetValue(hash, out var entry))
{
entry.reference--;
if (entry.reference <= 0 || !entry.storedObject)
if (entry.reference <= 0 || entry.storedObject == null)
{
Remove(entry);
}
else
{
Logging.Log(_name, $"Release(total#{_cache.Count}): {entry}");
Logger.Log(_name, $"Release(total#{_cache.Count}): {entry}");
}
}
else
{
Logging.Log(_name, $"Release(total#{_cache.Count}): <color=red>Already released: {obj}</color>");
Logger.Log(_name, $"Release(total#{_cache.Count}): <color=red>Already released: {obj}</color>");
}
obj = null;
@@ -175,10 +175,10 @@ namespace Coffee.UIEffectInternal
Profiler.BeginSample("(COF)[ObjectRepository] Remove");
_cache.Remove(entry.hash);
_objectKey.Remove(entry.storedObject.GetInstanceID());
_objectKey.Remove(entry.storedObject.GetHashCode());
_pool.Push(entry);
entry.reference = 0;
Logging.Log(_name, $"<color=#f29e03>Remove</color>(total#{_cache.Count}): {entry}");
Logger.Log(_name, $"<color=#f29e03>Remove</color>(total#{_cache.Count}): {entry}");
entry.Release(_onRelease);
Profiler.EndSample();
}
@@ -192,7 +192,7 @@ namespace Coffee.UIEffectInternal
public void Release(Action<T> onRelease)
{
reference = 0;
if (storedObject)
if (storedObject != null)
{
onRelease?.Invoke(storedObject);
}
@@ -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)
@@ -72,7 +71,7 @@ namespace Coffee.UIEffectInternal
if (!shader) return null;
// Already cached.
var id = shader.GetInstanceID();
var id = shader.GetHashCode();
if (_cachedOptionalShaders.TryGetValue(id, out var optionalShaderName))
{
return Shader.Find(optionalShaderName);
@@ -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,55 @@ 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.GetHashCode(), (uint)GetContentsHashCode(_sb), 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);
}
private static int GetContentsHashCode(StringBuilder sb)
{
var hash = 17;
for (var i = 0; i < sb.Length; i++)
{
hash = unchecked(hash * 31 + sb[i]);
}
return hash;
}
#endif
}
@@ -1,8 +1,8 @@
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using System.Reflection;
namespace Coffee.UIEffectInternal
{
@@ -21,7 +21,7 @@ namespace Coffee.UIEffectInternal
static UIExtraCallbacks()
{
Canvas.willRenderCanvases += OnBeforeCanvasRebuild;
Logging.LogMulticast(typeof(Canvas), "willRenderCanvases", message: "ctor");
Logger.LogMulticast(typeof(Canvas), "willRenderCanvases", message: "ctor");
}
/// <summary>
@@ -78,7 +78,7 @@ namespace Coffee.UIEffectInternal
#endif
Canvas.willRenderCanvases -= OnAfterCanvasRebuild;
Canvas.willRenderCanvases += OnAfterCanvasRebuild;
Logging.LogMulticast(typeof(Canvas), "willRenderCanvases",
Logger.LogMulticast(typeof(Canvas), "willRenderCanvases",
message: "InitializeAfterCanvasRebuild");
}
+19 -6
View File
@@ -282,6 +282,7 @@ namespace Coffee.UIEffects
{
if (m_ToneFilter == value) return;
context.m_ToneFilter = m_ToneFilter = value;
SetVerticesDirty();
SetMaterialDirty();
}
}
@@ -311,6 +312,7 @@ namespace Coffee.UIEffects
{
if (m_ColorFilter == value) return;
context.m_ColorFilter = m_ColorFilter = value;
SetVerticesDirty();
SetMaterialDirty();
}
}
@@ -794,6 +796,7 @@ namespace Coffee.UIEffects
(m_SrcBlendMode, m_DstBlendMode) = (m_BlendType, m_SrcBlendMode, m_DstBlendMode).Convert();
context.m_SrcBlendMode = m_SrcBlendMode;
context.m_DstBlendMode = m_DstBlendMode;
SetVerticesDirty();
SetMaterialDirty();
}
}
@@ -810,6 +813,7 @@ namespace Coffee.UIEffects
if (m_SrcBlendMode == value) return;
context.m_SrcBlendMode = m_SrcBlendMode = value;
m_BlendType = (m_SrcBlendMode, m_DstBlendMode).Convert();
SetVerticesDirty();
SetMaterialDirty();
}
}
@@ -826,6 +830,7 @@ namespace Coffee.UIEffects
if (m_DstBlendMode == value) return;
context.m_DstBlendMode = m_DstBlendMode = value;
m_BlendType = (m_SrcBlendMode, m_DstBlendMode).Convert();
SetVerticesDirty();
SetMaterialDirty();
}
}
@@ -838,6 +843,7 @@ namespace Coffee.UIEffects
if (m_ShadowMode == value) return;
context.m_ShadowMode = m_ShadowMode = value;
SetVerticesDirty();
SetVerticesDirty();
}
}
@@ -1013,6 +1019,7 @@ namespace Coffee.UIEffects
{
if (m_EdgeMode == value) return;
context.m_EdgeMode = m_EdgeMode = value;
SetVerticesDirty();
SetMaterialDirty();
}
}
@@ -1182,6 +1189,7 @@ namespace Coffee.UIEffects
{
if (m_GradationMode == value) return;
context.m_GradationMode = m_GradationMode = value;
SetVerticesDirty();
SetMaterialDirty();
}
}
@@ -1321,6 +1329,7 @@ namespace Coffee.UIEffects
{
if (m_DetailFilter == value) return;
context.m_DetailFilter = m_DetailFilter = value;
SetVerticesDirty();
SetMaterialDirty();
}
}
@@ -1350,11 +1359,11 @@ namespace Coffee.UIEffects
public Color detailColor
{
get => m_EdgeColor;
get => m_DetailColor;
set
{
if (m_EdgeColor == value) return;
context.m_DetailColor = m_EdgeColor = value;
if (m_DetailColor == value) return;
context.m_DetailColor = m_DetailColor = value;
SetMaterialDirty();
}
}
@@ -1494,7 +1503,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 +1514,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();
@@ -1579,7 +1590,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);
@@ -1799,6 +1811,7 @@ namespace Coffee.UIEffects
if (!append || src.m_DetailFilter != DetailFilter.None)
{
dst.m_DetailColor = src.m_DetailColor;
dst.m_DetailFilter = src.m_DetailFilter;
dst.m_DetailIntensity = src.m_DetailIntensity;
dst.m_DetailThreshold = src.m_DetailThreshold;
+36 -8
View File
@@ -32,13 +32,33 @@ 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>();
public virtual uint effectId => (uint)GetInstanceID();
public virtual uint effectId => (uint)GetHashCode();
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;
_canvasCached = false;
}
return _canvas;
}
}
public virtual UIEffectContext context
{
get
@@ -104,7 +124,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 +134,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 +159,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;
@@ -160,8 +188,8 @@ namespace Coffee.UIEffects
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
var samplingScaleId = (uint)(Mathf.InverseLerp(0.01f, 100, actualSamplingScale) * uint.MaxValue);
var rootId = (uint)(transitionRoot ? transitionRoot.GetInstanceID() : 0);
var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, samplingScaleId, rootId);
var rootId = (uint)(transitionRoot ? transitionRoot.GetHashCode() : 0);
var hash = new Hash128((uint)baseMaterial.GetHashCode(), effectId, samplingScaleId, rootId);
if (!MaterialRepository.Valid(hash, _material))
{
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial > Get or create material");
+45 -35
View File
@@ -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;
@@ -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);
@@ -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,26 +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.WorldSpace)
{
material.SetMatrix(s_CanvasToWorldMatrix, Matrix4x4.identity);
}
else 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()
@@ -686,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);
@@ -711,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));
@@ -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();
}
};
}
}
+15 -14
View File
@@ -102,8 +102,8 @@ namespace Coffee.UIEffects
public override uint effectId => target
? target.effectId
: preset
? (uint)preset.GetInstanceID()
: (uint)GetInstanceID();
? (uint)preset.GetHashCode()
: (uint)GetHashCode();
public override UIEffectContext context
@@ -124,19 +124,20 @@ namespace Coffee.UIEffects
{
get
{
if (preset && useTargetTransform && !m_CustomRoot && graphic && graphic.canvas)
if (useTargetTransform)
{
return graphic.canvas.transform as RectTransform;
if (preset && !m_CustomRoot && graphic && canvas)
{
return canvas.transform as RectTransform;
}
if (isTargetInScene)
{
return target.transitionRoot;
}
}
if (useTargetTransform && isTargetInScene)
{
return target.transitionRoot;
}
return m_CustomRoot
? m_CustomRoot
: transform as RectTransform;
return m_CustomRoot ? m_CustomRoot : transform as RectTransform;
}
}
@@ -186,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;
+1 -1
View File
@@ -4,7 +4,7 @@ using UnityEngine.UI;
namespace Coffee.UIEffects
{
internal class ImageProxy : GraphicProxy
internal sealed class ImageProxy : GraphicProxy
{
#if UNITY_EDITOR
[InitializeOnLoadMethod]
+30 -6
View File
@@ -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);
}
@@ -229,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;
}
@@ -257,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;
@@ -1,6 +1,11 @@
using System;
using UnityEditor.Rendering.BuiltIn.ShaderGraph;
using UnityEditor.ShaderGraph;
#if UNITY_6000_4_OR_NEWER
using GUID = UnityEngine.GUID;
#else
using GUID = UnityEditor.GUID;
#endif
namespace UnityEditor.Rendering.Universal.ShaderGraph
{
+17 -202
View File
@@ -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;
@@ -518,8 +368,8 @@ half4 apply_transition_filter(half4 color, const float alpha, const float2 uvLoc
const float softness = max(0.0001, _TransitionWidth * _TransitionSoftness);
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
@@ -605,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)
@@ -750,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
}
@@ -793,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;
@@ -833,7 +648,7 @@ half4 uieffect(half4 origin, float2 uv, float4 uvMask, float4 wpos)
half sobel_v = v00 * -1.0 + v10 * -2.0 + v20 * -1.0 + v02 * 1.0 + v12 * 2.0 + v22 * 1.0;
const half sobel = sqrt(sobel_h * sobel_h + sobel_v * sobel_v) * _SamplingIntensity;
return lerp(0, uieffect_internal(uv, uvMask, uvLocal, uvGrad, isShadow), inv_lerp(0.5, 1, sobel));
return lerp(half4(0, 0, 0, 0), uieffect_internal(uv, uvMask, uvLocal, uvGrad, isShadow), inv_lerp(0.5, 1, sobel));
}
#endif
@@ -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)
+1 -1
View File
@@ -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.7",
"version": "5.10.9",
"unity": "2020.3",
"license": "MIT",
"repository": {
+1 -1
View File
@@ -5,7 +5,7 @@
"com.coffee.nano-monitor": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/NanoMonitor",
"com.coffee.symbolic-linker": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/SymbolicLinker",
"com.coffee.ui-effect": "file:../../Packages/src",
"com.unity.ide.rider": "3.0.35",
"com.unity.ide.rider": "3.0.38",
"com.unity.render-pipelines.universal": "17.0.4",
"com.unity.test-framework": "1.5.1",
"com.unity.timeline": "1.8.8",
+1 -1
View File
@@ -67,7 +67,7 @@
"dependencies": {}
},
"com.unity.ide.rider": {
"version": "3.0.35",
"version": "3.0.38",
"depth": 0,
"source": "registry",
"dependencies": {