mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-20 01:42:37 +08:00
Compare commits
86 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| bbb5ae0f3e | |||
| ffdeaa7e2f | |||
| f879424b3f | |||
| effdd6d06e | |||
| b39ba58a85 | |||
| 742a5cd8dc | |||
| 1a923dd72c | |||
| c0fec32d50 | |||
| 4f2c9f12b5 | |||
| 264c453bb6 | |||
| 4c6cd11d86 | |||
| 50f6b3c5d2 | |||
| f98929d7e9 | |||
| 179ec89a02 | |||
| ed4716d7ad | |||
| 6af520ed40 | |||
| 9b1af29cd4 | |||
| 65a00b480f | |||
| f508eb32ca | |||
| ecd265e482 | |||
| 58b197e551 | |||
| 8a0e7d6b26 | |||
| 3b52c3a8fc | |||
| 88261e2af0 | |||
| 791d867076 | |||
| 68ebae28e0 | |||
| 5cd48a4633 | |||
| 3ff52e4735 | |||
| a3773e3302 | |||
| 5a9f335bf8 | |||
| 3807e4c69a | |||
| 184967c120 | |||
| 2cca822413 | |||
| 90ab16c3fd | |||
| e1f3abf7a6 | |||
| 770e61bb12 | |||
| a0820bf847 | |||
| 1a21464c0e | |||
| 1143fbb84a | |||
| eff923493a | |||
| 0898d730ad | |||
| 1106f4bf46 | |||
| 2861b1ce61 | |||
| 6eabdc694e | |||
| ae177a800c | |||
| 88bb76d735 | |||
| 37daad01c4 | |||
| 1ce32f7829 | |||
| 726bb100a0 | |||
| f8682f3c98 | |||
| 99669728cc | |||
| 30bf783320 |
@@ -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 }}
|
||||
|
||||
+11
-10
@@ -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
|
||||
@@ -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 }}
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f70ff0f1e25b4388b9bcb38d619f7bf
|
||||
PrefabImporter:
|
||||
guid: 7b8df35684c964c1da889d4128ed94ed
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
@@ -0,0 +1,63 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-7987516966893236458
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
|
||||
m_Name: Bloom
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
skipIterations:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
threshold:
|
||||
m_OverrideState: 1
|
||||
m_Value: 0.99
|
||||
intensity:
|
||||
m_OverrideState: 1
|
||||
m_Value: 2
|
||||
scatter:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.7
|
||||
clamp:
|
||||
m_OverrideState: 0
|
||||
m_Value: 65472
|
||||
tint:
|
||||
m_OverrideState: 0
|
||||
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||
highQualityFiltering:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
downscale:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
maxIterations:
|
||||
m_OverrideState: 0
|
||||
m_Value: 6
|
||||
dirtTexture:
|
||||
m_OverrideState: 0
|
||||
m_Value: {fileID: 0}
|
||||
dimension: 1
|
||||
dirtIntensity:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
|
||||
m_Name: MultiColorDissolve
|
||||
m_EditorClassIdentifier:
|
||||
components:
|
||||
- {fileID: -7987516966893236458}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57ac8962e3fd34b1ab7016e803973b51
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,80 @@
|
||||
using Coffee.UIEffects;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteAlways]
|
||||
public class MultiColorDissolve : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private UIEffect m_Base;
|
||||
|
||||
[Header("Dissolve 1")]
|
||||
[SerializeField] private UIEffect m_Dissolve1;
|
||||
|
||||
[ColorUsage(true, true)]
|
||||
[SerializeField]
|
||||
private Color m_DissolveColor1 = Color.red;
|
||||
|
||||
[Range(0, 0.1f)]
|
||||
[SerializeField]
|
||||
private float m_Delay1 = 0.05f;
|
||||
|
||||
[Range(0, 0.2f)]
|
||||
[SerializeField]
|
||||
private float m_Width1 = 0.1f;
|
||||
|
||||
[Range(0, 1f)]
|
||||
[SerializeField]
|
||||
private float m_Softness1 = 0.5f;
|
||||
|
||||
[Header("Dissolve 2")]
|
||||
[SerializeField]
|
||||
private UIEffect m_Dissolve2;
|
||||
|
||||
[ColorUsage(true, true)]
|
||||
[SerializeField]
|
||||
private Color m_DissolveColor2 = Color.magenta;
|
||||
|
||||
[Range(0, 0.1f)]
|
||||
[SerializeField]
|
||||
private float m_Delay2 = 0.1f;
|
||||
|
||||
[Range(0, 0.2f)]
|
||||
[SerializeField]
|
||||
private float m_Width2 = 0.1f;
|
||||
|
||||
[Range(0, 1f)]
|
||||
[SerializeField]
|
||||
private float m_Softness2 = 0.5f;
|
||||
|
||||
[Space]
|
||||
[Range(0, 1)] [SerializeField] private float m_Rate;
|
||||
|
||||
public void SetRate(float rate)
|
||||
{
|
||||
m_Rate = rate;
|
||||
if (m_Base)
|
||||
{
|
||||
m_Base.transitionRate = rate;
|
||||
}
|
||||
|
||||
if (m_Dissolve1)
|
||||
{
|
||||
m_Dissolve1.transitionRate = rate - m_Delay1;
|
||||
m_Dissolve1.transitionColor = m_DissolveColor1;
|
||||
m_Dissolve1.transitionWidth = m_Width1;
|
||||
m_Dissolve1.transitionSoftness = m_Softness1;
|
||||
}
|
||||
|
||||
if (m_Dissolve2)
|
||||
{
|
||||
m_Dissolve2.transitionRate = rate - m_Delay2 * 2;
|
||||
m_Dissolve2.transitionColor = m_DissolveColor2;
|
||||
m_Dissolve2.transitionWidth = m_Width2;
|
||||
m_Dissolve2.transitionSoftness = m_Softness2;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
SetRate(m_Rate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1cb0fa86a0fba445092aa81b4974b7cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f02363c499e3488da5755c9b528ab9f
|
||||
PrefabImporter:
|
||||
guid: ba87f0cfb8c4b4eaea328308391c06e5
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
+6789
-10140
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@ using Debug = UnityEngine.Debug;
|
||||
|
||||
internal static class TextMeshProSupport
|
||||
{
|
||||
private const string k_Version = "userData: v5.7.0";
|
||||
private const string k_Version = "userData: v5.8.0";
|
||||
private const string k_VersionUnity6 = k_Version + " (Unity 6)";
|
||||
|
||||
private static readonly Dictionary<string, string> s_FileGuids = new Dictionary<string, string>()
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c00285a6a9d0843f4a7da23d7dda6582
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using UnityEditor;
|
||||
|
||||
internal static class UserDataEditor
|
||||
{
|
||||
[InitializeOnLoadMethod]
|
||||
private static void InitializeOnLoadMethod()
|
||||
{
|
||||
Editor.finishedDefaultHeaderGUI += OnFinishedDefaultHeaderGUI;
|
||||
}
|
||||
|
||||
private static void OnFinishedDefaultHeaderGUI(Editor editor)
|
||||
{
|
||||
var importer = editor.target as AssetImporter;
|
||||
if (!importer)
|
||||
{
|
||||
if (!AssetDatabase.Contains(editor.target)) return;
|
||||
|
||||
importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(editor.target));
|
||||
}
|
||||
|
||||
if (!importer) return;
|
||||
|
||||
EditorGUIUtility.labelWidth = 55;
|
||||
importer.userData = EditorGUILayout.DelayedTextField("userdata", importer.userData);
|
||||
AssetDatabase.WriteImportSettingsIfDirty(importer.assetPath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92afd1c51675640e88e3abb238cd225f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,32 +8,16 @@ ShaderVariantCollection:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: UIEffectShaderVariants
|
||||
m_Shaders:
|
||||
- first: {fileID: 4800000, guid: d1cb940e3804b4adcaf9b22083fadfad, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 63a1dba10bff94661a909d63808a9a3b, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: e65241fa80a374114b3f55ed746c04d9, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 935b7be1c88464d2eb87204fdfab5a38, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: COLOR_HSV_MODIFIER GLOW_ON UNDERLAY_ON
|
||||
- keywords: COLOR_FILTER GLOW_ON GRADATION_GRADIENT UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY GLOW_ON UNDERLAY_ON
|
||||
- keywords: COLOR_FILTER GLOW_ON TRANSITION_BURN UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: EDGE_COLOR_REPLACE EDGE_PLAIN GLOW_ON UNDERLAY_ON
|
||||
- keywords: COLOR_FILTER GLOW_ON UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: EDGE_PLAIN GLOW_ON UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON SAMPLING_BLUR_DETAIL UNDERLAY_ON
|
||||
passType: 0
|
||||
@@ -45,64 +29,44 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: GLOW_ON SAMPLING_RGB_SHIFT UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON SHADOW_COLOR_REPLACE TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON SHADOW_COLOR_REPLACE UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TONE_RETRO UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE UNDERLAY_ON
|
||||
- keywords: GLOW_ON TRANSITION_BLAZE UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_MULTIPLY TRANSITION_PATTERN UNDERLAY_ON
|
||||
- keywords: GLOW_ON TRANSITION_BURN UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE
|
||||
UNDERLAY_ON
|
||||
- keywords: GLOW_ON TRANSITION_DISSOLVE UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MELT UNDERLAY_ON
|
||||
- keywords: GLOW_ON TRANSITION_MELT UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_PATTERN UNDERLAY_ON
|
||||
- keywords: GLOW_ON TRANSITION_PATTERN UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_SHINY UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_REPLACE TRANSITION_MELT UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
- keywords: GLOW_ON TRANSITION_SHINY UNDERLAY_ON
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 96246b1ead49a4c5a996fd477bc5a117, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords:
|
||||
passType: 0
|
||||
- keywords: COLOR_ADDITIVE
|
||||
- keywords: COLOR_FILTER
|
||||
passType: 0
|
||||
- keywords: COLOR_CONTRAST
|
||||
- keywords: COLOR_FILTER EDGE_PLAIN
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER
|
||||
- keywords: COLOR_FILTER EDGE_PLAIN TRANSITION_PATTERN
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER TARGET_HUE
|
||||
- keywords: COLOR_FILTER EDGE_SHINY
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER TARGET_LUMINANCE
|
||||
- keywords: COLOR_FILTER SAMPLING_BLUR_FAST
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY
|
||||
- keywords: COLOR_FILTER SAMPLING_BLUR_FAST TONE_GRAYSCALE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY DETAIL_MASKING EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_SHINY
|
||||
SAMPLING_BLUR_FAST SHADOW_COLOR_REPLACE TARGET_HUE TONE_GRAYSCALE TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_DISSOLVE
|
||||
- keywords: COLOR_FILTER SAMPLING_BLUR_FAST TONE_GRAYSCALE TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY SHADOW_COLOR_REPLACE
|
||||
- keywords: COLOR_FILTER TARGET_HUE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_ADDITIVE
|
||||
- keywords: COLOR_FILTER TARGET_LUMINANCE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_ADDITIVE SAMPLING_BLUR_FAST TONE_GRAYSCALE TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_LUMINANCE
|
||||
passType: 0
|
||||
- keywords: COLOR_REPLACE
|
||||
passType: 0
|
||||
- keywords: COLOR_SUBTRACTIVE
|
||||
- keywords: COLOR_FILTER TRANSITION_MELT
|
||||
passType: 0
|
||||
- keywords: DETAIL_ADDITIVE
|
||||
passType: 0
|
||||
@@ -110,47 +74,43 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: DETAIL_MULTIPLY
|
||||
passType: 0
|
||||
- keywords: DETAIL_MULTIPLY EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_SHINY
|
||||
- keywords: DETAIL_MULTIPLY GRADATION_GRADIENT
|
||||
passType: 0
|
||||
- keywords: DETAIL_MULTIPLY_ADDITIVE
|
||||
passType: 0
|
||||
- keywords: DETAIL_REPLACE
|
||||
passType: 0
|
||||
- keywords: EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_PLAIN
|
||||
- keywords: DETAIL_SUBTRACTIVE
|
||||
passType: 0
|
||||
- keywords: EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_PLAIN SHADOW_COLOR_MULTIPLY_ADDITIVE
|
||||
- keywords: EDGE_PLAIN
|
||||
passType: 0
|
||||
- keywords: EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_SHINY
|
||||
- keywords: EDGE_PLAIN TRANSITION_PATTERN
|
||||
passType: 0
|
||||
- keywords: EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_SHINY SAMPLING_EDGE_ALPHA
|
||||
- keywords: EDGE_SHINY
|
||||
passType: 0
|
||||
- keywords: EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_SHINY SHADOW_COLOR_MULTIPLY_ADDITIVE
|
||||
- keywords: EDGE_SHINY SAMPLING_EDGE_ALPHA
|
||||
passType: 0
|
||||
- keywords: EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_SHINY TRANSITION_COLOR_MULTIPLY
|
||||
TRANSITION_PATTERN
|
||||
- keywords: EDGE_SHINY TRANSITION_PATTERN
|
||||
passType: 0
|
||||
- keywords: EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_SHINY TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_PATTERN
|
||||
- keywords: GRADATION_COLOR2
|
||||
passType: 0
|
||||
- keywords: EDGE_PLAIN SHADOW_COLOR_REPLACE TRANSITION_COLOR_MULTIPLY TRANSITION_PATTERN
|
||||
- keywords: GRADATION_COLOR4
|
||||
passType: 0
|
||||
- keywords: EDGE_PLAIN TRANSITION_COLOR_MULTIPLY TRANSITION_PATTERN
|
||||
- keywords: GRADATION_GRADIENT
|
||||
passType: 0
|
||||
- keywords: GRADATION_RADIAL
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_DETAIL
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_FAST
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_FAST SHADOW_COLOR_MULTIPLY_ADDITIVE TONE_GRAYSCALE
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_FAST SHADOW_COLOR_REPLACE
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_MEDIUM
|
||||
passType: 0
|
||||
- keywords: SAMPLING_EDGE_ALPHA
|
||||
passType: 0
|
||||
- keywords: SAMPLING_EDGE_LUMINANCE
|
||||
passType: 0
|
||||
- keywords: SAMPLING_EDGE_LUMINANCE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MASK
|
||||
- keywords: SAMPLING_EDGE_LUMINANCE TRANSITION_MASK
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION
|
||||
passType: 0
|
||||
@@ -158,18 +118,8 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TONE_RETRO UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TRANSITION_COLOR_MULTIPLY TRANSITION_PATTERN
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: SAMPLING_RGB_SHIFT
|
||||
passType: 0
|
||||
- keywords: SAMPLING_RGB_SHIFT TRANSITION_COLOR_MULTIPLY TRANSITION_PATTERN
|
||||
passType: 0
|
||||
- keywords: SHADOW_COLOR_REPLACE
|
||||
passType: 0
|
||||
- keywords: SHADOW_COLOR_REPLACE TRANSITION_COLOR_REPLACE TRANSITION_MELT
|
||||
passType: 0
|
||||
- keywords: TONE_GRAYSCALE
|
||||
passType: 0
|
||||
- keywords: TONE_NEGATIVE
|
||||
@@ -180,59 +130,35 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: TONE_SEPIA
|
||||
passType: 0
|
||||
- keywords: TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
- keywords: TRANSITION_BLAZE
|
||||
passType: 0
|
||||
- keywords: TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE UNITY_UI_CLIP_RECT
|
||||
- keywords: TRANSITION_BLAZE UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY TRANSITION_PATTERN
|
||||
- keywords: TRANSITION_BURN
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY TRANSITION_PATTERN UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MASK
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MELT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MELT UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_PATTERN
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_SHINY
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_SHINY UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_REPLACE TRANSITION_MELT
|
||||
- keywords: TRANSITION_BURN UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_CUTOFF
|
||||
passType: 0
|
||||
- keywords: TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: TRANSITION_DISSOLVE UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_FADE
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 03ea49e29b5ad4fbe8e340af208fe8e7, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
- keywords: TRANSITION_MASK
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 16f26337621974eaf998b9857bac39c6, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
- keywords: TRANSITION_MELT
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 2c69b4dabb5c24ae99889f581c8b556a, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
- keywords: TRANSITION_MELT UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 26b66f9b09b8d4ac6a2790c3fa8b21c1, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TONE_RETRO TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_SHINY
|
||||
- keywords: TRANSITION_PATTERN
|
||||
passType: 0
|
||||
- keywords: TRANSITION_PATTERN UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_SHINY
|
||||
passType: 0
|
||||
- keywords: TRANSITION_SHINY UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
@@ -246,10 +172,10 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 7d43f626d9b5f4d729097092ded48bdb, type: 3}
|
||||
m_Name: UIEffectProjectSettings
|
||||
m_EditorClassIdentifier:
|
||||
m_TransformSensitivity: 1
|
||||
m_RuntimePresets:
|
||||
- {fileID: 1645081683573595507, guid: 3b09ad143990c4c8795c6e93760e132a, type: 3}
|
||||
- {fileID: 1645081683573595507, guid: 4f70ff0f1e25b4388b9bcb38d619f7bf, type: 3}
|
||||
m_RuntimePresets: []
|
||||
m_RuntimePresetsV2:
|
||||
- {fileID: 11400000, guid: 460881a8263ce454799a8c689c28d8c9, type: 2}
|
||||
- {fileID: 11400000, guid: b919bc84de9254bcf8f614d392db83bb, type: 2}
|
||||
m_UseHDRColorPicker: 1
|
||||
m_ShaderVariantCollection: {fileID: -8740588384831342173}
|
||||
m_ShaderVariantRegistry:
|
||||
|
||||
@@ -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.34",
|
||||
"com.unity.ide.rider": "3.0.36",
|
||||
"com.unity.test-framework": "1.1.33",
|
||||
"com.unity.textmeshpro": "3.0.9",
|
||||
"com.unity.modules.animation": "1.0.0"
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "2045eaab5b485827cef8bf0bb9e1552dce4f8d6d"
|
||||
"hash": "4a182298bd6293c4e6e33dd40bb7a050847190d8"
|
||||
},
|
||||
"com.coffee.minimal-resource": {
|
||||
"version": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/MinimalResource",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "2bd2bf356dd692a39de9db2ff11faaf79fbfaea3"
|
||||
"hash": "4a182298bd6293c4e6e33dd40bb7a050847190d8"
|
||||
},
|
||||
"com.coffee.nano-monitor": {
|
||||
"version": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/NanoMonitor",
|
||||
@@ -21,14 +21,14 @@
|
||||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0"
|
||||
},
|
||||
"hash": "2045eaab5b485827cef8bf0bb9e1552dce4f8d6d"
|
||||
"hash": "4a182298bd6293c4e6e33dd40bb7a050847190d8"
|
||||
},
|
||||
"com.coffee.symbolic-linker": {
|
||||
"version": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/SymbolicLinker",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "3c280f1a8f4db5038b881ff07f270efd9638fa31"
|
||||
"hash": "4a182298bd6293c4e6e33dd40bb7a050847190d8"
|
||||
},
|
||||
"com.coffee.ui-effect": {
|
||||
"version": "file:src",
|
||||
@@ -46,7 +46,7 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ide.rider": {
|
||||
"version": "3.0.34",
|
||||
"version": "3.0.36",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,3 +1,180 @@
|
||||
## [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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `GradationMode.RadialFast` and `GradationMode.RadialDetail` are obsolete ([1a923dd](https://github.com/mob-sakai/UIEffect/commit/1a923dd72c263de5480d71bd17b697feca317ef1))
|
||||
* soft masking not working with `DetailFilter.Masking` ([ffdeaa7](https://github.com/mob-sakai/UIEffect/commit/ffdeaa7e2f1c2a9ccb7eb21d5674e2c19021aef9))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* `GradationGradient` supports HDR color ([50f6b3c](https://github.com/mob-sakai/UIEffect/commit/50f6b3c5d20b93a2245f6d54b6eb4bc13565c3b5))
|
||||
* add `Clear` method to reset properties via script ([264c453](https://github.com/mob-sakai/UIEffect/commit/264c453bb6ebad08ef950b0cec2f38e60a1710d8)), closes [#337](https://github.com/mob-sakai/UIEffect/issues/337)
|
||||
* add `GradationMode.RadialGradient` feature ([179ec89](https://github.com/mob-sakai/UIEffect/commit/179ec89a0215af9d8046e150d98fa06371155e93)), closes [#348](https://github.com/mob-sakai/UIEffect/issues/348)
|
||||
* add `GradationReverse` option for gradient ([c0fec32](https://github.com/mob-sakai/UIEffect/commit/c0fec32d502ec1f9d03172ed200f4d9233506eb9)), closes [#348](https://github.com/mob-sakai/UIEffect/issues/348)
|
||||
* add `GradationWrapMode` option ([f98929d](https://github.com/mob-sakai/UIEffect/commit/f98929d7e9656b4c02d5545b3893748c963d1118))
|
||||
* add `TransitionFilter.Blaze` feature ([ed4716d](https://github.com/mob-sakai/UIEffect/commit/ed4716d7ada102fe0053480941925e9f27b1c2c3))
|
||||
* add new built-in presets ([4f2c9f1](https://github.com/mob-sakai/UIEffect/commit/4f2c9f12b5e115bab1418a7a0b1187269a041fc4))
|
||||
* improve performance for TextMeshPro ([6af520e](https://github.com/mob-sakai/UIEffect/commit/6af520ed408f2e5eb4d84ec0df484338719ebc8e))
|
||||
* timeline package support ([742a5cd](https://github.com/mob-sakai/UIEffect/commit/742a5cd8dc47500de4b111a132d7a8b242844342)), closes [#347](https://github.com/mob-sakai/UIEffect/issues/347)
|
||||
* update shaders in samples ([4c6cd11](https://github.com/mob-sakai/UIEffect/commit/4c6cd11d86582f2351c40374180828ad1c8955c3))
|
||||
|
||||
## [5.8.7](https://github.com/mob-sakai/UIEffect/compare/5.8.6...5.8.7) (2025-06-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `GradationGradient` and `TransitionGradient` in reprica will be not dirty (editor) ([58b197e](https://github.com/mob-sakai/UIEffect/commit/58b197e551aea8efca10e12da8df132853d4a24e))
|
||||
* changes not reflected in rendering when TextMeshPro is cleared ([f508eb3](https://github.com/mob-sakai/UIEffect/commit/f508eb32caf6757eb4c27b98ac29a1582dcd14b4)), closes [#351](https://github.com/mob-sakai/UIEffect/issues/351)
|
||||
* setting `gradationScale` to 0 throws `DivideByZeroException` ([ecd265e](https://github.com/mob-sakai/UIEffect/commit/ecd265e4828c7f81c96a76c16df147b6c4804429))
|
||||
|
||||
## [5.8.6](https://github.com/mob-sakai/UIEffect/compare/5.8.5...5.8.6) (2025-05-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* some methods may be called multiple times when domain reload on play is disabled (editor) ([3b52c3a](https://github.com/mob-sakai/UIEffect/commit/3b52c3a8fc67980d426b8e4e2ed2067c725ca262))
|
||||
|
||||
## [5.8.5](https://github.com/mob-sakai/UIEffect/compare/5.8.4...5.8.5) (2025-05-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* skip processing when graphic is invalid ([5cd48a4](https://github.com/mob-sakai/UIEffect/commit/5cd48a463309270ec3d6501bde2add9944bbaf02))
|
||||
* TextMeshPro strikethrough and underline not displaying ([68ebae2](https://github.com/mob-sakai/UIEffect/commit/68ebae28e02045cb45996bf5b77d7d93d2f0ca82)), closes [#344](https://github.com/mob-sakai/UIEffect/issues/344)
|
||||
* TMP SubMeshUI generates overhead every frame (since 5.6.0) ([791d867](https://github.com/mob-sakai/UIEffect/commit/791d8670761902466d81412d832cddf013cd28cd)), closes [#343](https://github.com/mob-sakai/UIEffect/issues/343) [#345](https://github.com/mob-sakai/UIEffect/issues/345)
|
||||
|
||||
## [5.8.4](https://github.com/mob-sakai/UIEffect/compare/5.8.3...5.8.4) (2025-04-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* NRE while canvas is disabled ([a3773e3](https://github.com/mob-sakai/UIEffect/commit/a3773e33028c60517fb4e6c534f6280194df8e64)), closes [#342](https://github.com/mob-sakai/UIEffect/issues/342)
|
||||
|
||||
## [5.8.3](https://github.com/mob-sakai/UIEffect/compare/5.8.2...5.8.3) (2025-04-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* the alpha of the gradation color and gradient was being ignored ([3807e4c](https://github.com/mob-sakai/UIEffect/commit/3807e4c69aefaef04b2245522e7c5085ccc65a36)), closes [#341](https://github.com/mob-sakai/UIEffect/issues/341)
|
||||
|
||||
## [5.8.2](https://github.com/mob-sakai/UIEffect/compare/5.8.1...5.8.2) (2025-04-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `Flip` is ignored when loading a preset ([e1f3abf](https://github.com/mob-sakai/UIEffect/commit/e1f3abf7a65b62718b28e33ac2f7d700c3ae3f5a))
|
||||
* fix detail color ([90ab16c](https://github.com/mob-sakai/UIEffect/commit/90ab16c3fd46435ebf7c8e47ffb4ec521d2f61c9))
|
||||
* indicate in the inspector using tooltips and asterisks that `Rotation` and `Keep Aspect Ratio` are shared properties ([2cca822](https://github.com/mob-sakai/UIEffect/commit/2cca822413aa7580e1eb777c3295d1de928cd65f))
|
||||
|
||||
## [5.8.1](https://github.com/mob-sakai/UIEffect/compare/5.8.0...5.8.1) (2025-04-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* built-in presets cannot be used with `UIEffectReplica` ([1106f4b](https://github.com/mob-sakai/UIEffect/commit/1106f4bf4632e1372d44ced9a38e98209a6b55e8))
|
||||
* New presets ignore `DetailColor` property ([1143fbb](https://github.com/mob-sakai/UIEffect/commit/1143fbb84a1e08817de93f1349ee5cdad0972db5)), closes [#336](https://github.com/mob-sakai/UIEffect/issues/336)
|
||||
* prevent built-in preset assets from being editable ([0898d73](https://github.com/mob-sakai/UIEffect/commit/0898d730add42970fb74bf2ad8aca9809bf6dd39))
|
||||
|
||||
# [5.8.0](https://github.com/mob-sakai/UIEffect/compare/5.7.0...5.8.0) (2025-04-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `ShadowMode.Mirror` does not flip the effect ([37daad0](https://github.com/mob-sakai/UIEffect/commit/37daad01c4f3f4c259650b1493aeae204e0bd247))
|
||||
* fix alpha clipping for ShaderGraph ([ae177a8](https://github.com/mob-sakai/UIEffect/commit/ae177a800cba1561b523292279d7986d4eff9f9c))
|
||||
* unable to add editor presets as runtime presets to project settings ([726bb10](https://github.com/mob-sakai/UIEffect/commit/726bb100a0ad327619634ea73ccdccc36276d0d0)), closes [#330](https://github.com/mob-sakai/UIEffect/issues/330)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add `DetailColor` property ([30bf783](https://github.com/mob-sakai/UIEffect/commit/30bf783320398d68b90b09b0dcf93738b4683e00)), closes [#332](https://github.com/mob-sakai/UIEffect/issues/332)
|
||||
* ScriptableObject based preset system ([f8682f3](https://github.com/mob-sakai/UIEffect/commit/f8682f3c9889fb56ff3cd9010934f998e121553a)), closes [#333](https://github.com/mob-sakai/UIEffect/issues/333)
|
||||
|
||||
# [5.7.0](https://github.com/mob-sakai/UIEffect/compare/5.6.4...5.7.0) (2025-04-11)
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:735c8f008d0ad4caa9cdc4306f1c3042"
|
||||
"GUID:735c8f008d0ad4caa9cdc4306f1c3042",
|
||||
"GUID:f06555f75b070af458a003d92f9efb00",
|
||||
"GUID:02f771204943f4a40949438e873e3eff"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
@@ -24,6 +26,11 @@
|
||||
"name": "com.unity.ugui",
|
||||
"expression": "2.0.0",
|
||||
"define": "TMP_ENABLE"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.timeline",
|
||||
"expression": "1.0.0",
|
||||
"define": "TIMELINE_ENABLE"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3150c4c70d45b46d389368100b181ee4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,183 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Timeline;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects.Timeline
|
||||
{
|
||||
public abstract class UIEffectClipEditor : ClipEditor
|
||||
{
|
||||
public override void DrawBackground(TimelineClip clip, ClipBackgroundRegion region)
|
||||
{
|
||||
var director = TimelineEditor.inspectedDirector;
|
||||
if (!director) return;
|
||||
|
||||
var viewDuration = region.endTime - region.startTime;
|
||||
var inDuration = (float)Math.Max(clip.easeInDuration, clip.blendInDuration);
|
||||
var outDuration = (float)Math.Max(clip.easeOutDuration, clip.blendOutDuration);
|
||||
inDuration = 0 < inDuration ? Mathf.Max(inDuration - (float)region.startTime, 0) : 0f;
|
||||
outDuration = 0 < outDuration ? Mathf.Max(outDuration - (float)(clip.duration - region.endTime), 0) : 0f;
|
||||
|
||||
var p = region.position;
|
||||
p.x += p.width * (float)(inDuration / viewDuration);
|
||||
p.width -= p.width * (float)((inDuration + outDuration) / viewDuration);
|
||||
|
||||
DrawBackground(p, clip);
|
||||
}
|
||||
|
||||
public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom)
|
||||
{
|
||||
clip.displayName = ObjectNames.NicifyVariableName(track.GetType().Name.Replace("Track", ""));
|
||||
if (clip.asset is UIEffectClip uiEffectClip)
|
||||
{
|
||||
uiEffectClip.timelineClip = clip;
|
||||
}
|
||||
|
||||
var floatClip = clip.asset as UIEffectFloatClip;
|
||||
if (floatClip)
|
||||
{
|
||||
if (track is GradationRotationTrack || track is GradationOffsetTrack)
|
||||
{
|
||||
floatClip.m_Data.m_From = 0f;
|
||||
floatClip.m_Data.m_Value = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void DrawBackground(Rect rect, TimelineClip clip);
|
||||
}
|
||||
|
||||
[CustomTimelineEditor(typeof(UIEffectFloatClip))]
|
||||
public class UIEffectFloatClipEditor : UIEffectClipEditor
|
||||
{
|
||||
private static GUIStyle s_FromStyle;
|
||||
private static GUIStyle s_ToStyle;
|
||||
|
||||
protected override void DrawBackground(Rect rect, TimelineClip clip)
|
||||
{
|
||||
var asset = clip.asset as UIEffectFloatClip;
|
||||
if (!asset) return;
|
||||
|
||||
if (s_FromStyle == null)
|
||||
{
|
||||
s_FromStyle = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperLeft, fontSize = 9 };
|
||||
s_ToStyle = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperRight, fontSize = 9 };
|
||||
}
|
||||
|
||||
var d = asset.m_Data;
|
||||
if (d.m_Tween)
|
||||
{
|
||||
DrawLabelWithShadow(rect, asset.m_Data.m_From.ToString("F2"), s_FromStyle);
|
||||
DrawLabelWithShadow(rect, asset.m_Data.m_Value.ToString("F2"), s_ToStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawLabelWithShadow(rect, asset.m_Data.m_Value.ToString("F2"), s_FromStyle);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawLabelWithShadow(Rect position, string text, GUIStyle style)
|
||||
{
|
||||
GUI.color = Color.black;
|
||||
EditorGUI.LabelField(position, text, style);
|
||||
GUI.color = Color.white;
|
||||
position.x -= 1f;
|
||||
position.y -= 1f;
|
||||
EditorGUI.LabelField(position, text, style);
|
||||
}
|
||||
}
|
||||
|
||||
[CustomTimelineEditor(typeof(UIEffectColorClip))]
|
||||
public class UIEffectColorClipEditor : UIEffectClipEditor
|
||||
{
|
||||
protected override void DrawBackground(Rect p, TimelineClip clip)
|
||||
{
|
||||
var asset = clip.asset as UIEffectColorClip;
|
||||
if (!asset) return;
|
||||
|
||||
var d = asset.m_Data;
|
||||
if (d.m_Tween)
|
||||
{
|
||||
EditorGUIUtility.DrawColorSwatch(new Rect(p.x + 2, p.y, 8, 8), d.m_From);
|
||||
EditorGUIUtility.DrawColorSwatch(new Rect(p.x + p.width - 8, p.y, 8, 8), d.m_Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUIUtility.DrawColorSwatch(new Rect(p.x + 2, p.y, 8, 8), d.m_Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CustomEditor(typeof(UIEffectClip<>), true)]
|
||||
public class UIEffectClipAssetEditor : Editor
|
||||
{
|
||||
private SerializedProperty _tween;
|
||||
private SerializedProperty _from;
|
||||
private SerializedProperty _curve;
|
||||
private SerializedProperty _value;
|
||||
private FloatClipUsageAttribute _floatUsage;
|
||||
private ColorClipUsageAttribute _colorUsage;
|
||||
private GUIContent _label;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
var data = serializedObject.FindProperty("m_Data");
|
||||
_tween = data.FindPropertyRelative("m_Tween");
|
||||
_from = data.FindPropertyRelative("m_From");
|
||||
_curve = data.FindPropertyRelative("m_Curve");
|
||||
_value = data.FindPropertyRelative("m_Value");
|
||||
|
||||
var clip = target as UIEffectClip;
|
||||
var type = clip.timelineClip.GetParentTrack().GetType();
|
||||
_floatUsage = type.GetCustomAttribute<FloatClipUsageAttribute>();
|
||||
_colorUsage = type.GetCustomAttribute<ColorClipUsageAttribute>();
|
||||
_label = new GUIContent(ObjectNames.NicifyVariableName(type.Name).Replace(" Track", ""));
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(_tween);
|
||||
|
||||
if (_tween.boolValue)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
DrawProperty(_from, EditorGUIUtility.TrTempContent("From"));
|
||||
EditorGUILayout.PropertyField(_curve);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
DrawProperty(_value, _label);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DrawProperty(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (_floatUsage != null)
|
||||
{
|
||||
EditorGUILayout.Slider(property, _floatUsage.min, _floatUsage.max, label);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Color)
|
||||
{
|
||||
var hdr = UIEffectProjectSettings.useHdrColorPicker;
|
||||
var alpha = _colorUsage?.alpha ?? true;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var color = EditorGUILayout.ColorField(label, property.colorValue, true, alpha, hdr);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
property.colorValue = color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(property, label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d108727fec4d48d28c1609b01a3a8c6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,7 +2,6 @@
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Coffee.UIEffects.Editors
|
||||
@@ -12,109 +11,16 @@ namespace Coffee.UIEffects.Editors
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIEffect), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIEffectEditor : Editor
|
||||
public class UIEffectEditor : UIEffectPropertyEditor
|
||||
{
|
||||
private class UIEffectEditorSettings : ScriptableSingleton<UIEffectEditorSettings>
|
||||
{
|
||||
public bool m_ExpandOthers = true;
|
||||
}
|
||||
|
||||
private static readonly PropertyInfo s_PiGradient = typeof(SerializedProperty)
|
||||
.GetProperty("gradientValue", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
private static readonly Func<SerializedProperty, Gradient> s_GetGradient =
|
||||
(Func<SerializedProperty, Gradient>)Delegate.CreateDelegate(typeof(Func<SerializedProperty, Gradient>),
|
||||
s_PiGradient.GetMethod);
|
||||
|
||||
private static readonly Action<SerializedProperty, Gradient> s_SetGradient =
|
||||
(Action<SerializedProperty, Gradient>)Delegate.CreateDelegate(typeof(Action<SerializedProperty, Gradient>),
|
||||
s_PiGradient.SetMethod);
|
||||
|
||||
private SerializedProperty _toneFilter;
|
||||
private SerializedProperty _toneIntensity;
|
||||
|
||||
private SerializedProperty _colorFilter;
|
||||
private SerializedProperty _color;
|
||||
private SerializedProperty _colorIntensity;
|
||||
private SerializedProperty _colorGlow;
|
||||
|
||||
private SerializedProperty _samplingFilter;
|
||||
private SerializedProperty _samplingIntensity;
|
||||
private SerializedProperty _samplingWidth;
|
||||
private SerializedProperty _samplingScale;
|
||||
|
||||
private SerializedProperty _transitionFilter;
|
||||
private SerializedProperty _transitionRate;
|
||||
private SerializedProperty _transitionTex;
|
||||
private SerializedProperty _transitionTexScale;
|
||||
private SerializedProperty _transitionTexOffset;
|
||||
private SerializedProperty _transitionTexSpeed;
|
||||
private SerializedProperty _transitionReverse;
|
||||
private SerializedProperty _transitionRotation;
|
||||
private SerializedProperty _transitionKeepAspectRatio;
|
||||
private SerializedProperty _transitionWidth;
|
||||
private SerializedProperty _transitionSoftness;
|
||||
private SerializedProperty _transitionRange;
|
||||
private SerializedProperty _transitionColorFilter;
|
||||
private SerializedProperty _transitionColor;
|
||||
private SerializedProperty _transitionColorGlow;
|
||||
private SerializedProperty _transitionPatternReverse;
|
||||
private SerializedProperty _transitionAutoPlaySpeed;
|
||||
|
||||
private SerializedProperty _targetMode;
|
||||
private SerializedProperty _targetColor;
|
||||
private SerializedProperty _targetRange;
|
||||
private SerializedProperty _targetSoftness;
|
||||
|
||||
private SerializedProperty _blendType;
|
||||
private SerializedProperty _srcBlendMode;
|
||||
private SerializedProperty _dstBlendMode;
|
||||
|
||||
private SerializedProperty _shadowMode;
|
||||
private SerializedProperty _shadowDistance;
|
||||
private SerializedProperty _shadowDistanceX;
|
||||
private SerializedProperty _shadowDistanceY;
|
||||
private SerializedProperty _shadowIteration;
|
||||
private SerializedProperty _shadowFade;
|
||||
private SerializedProperty _shadowMirrorScale;
|
||||
private SerializedProperty _shadowBlurIntensity;
|
||||
private SerializedProperty _shadowColorFilter;
|
||||
private SerializedProperty _shadowColor;
|
||||
private SerializedProperty _shadowColorGlow;
|
||||
|
||||
private SerializedProperty _gradationMode;
|
||||
private SerializedProperty _gradationIntensity;
|
||||
private SerializedProperty _gradationColorFilter;
|
||||
private SerializedProperty _gradationColor1;
|
||||
private SerializedProperty _gradationColor2;
|
||||
private SerializedProperty _gradationColor3;
|
||||
private SerializedProperty _gradationColor4;
|
||||
private SerializedProperty _gradationGradient;
|
||||
private SerializedProperty _gradationOffset;
|
||||
private SerializedProperty _gradationScale;
|
||||
private SerializedProperty _gradationRotation;
|
||||
|
||||
private SerializedProperty _edgeMode;
|
||||
private SerializedProperty _edgeWidth;
|
||||
private SerializedProperty _edgeColorFilter;
|
||||
private SerializedProperty _edgeColor;
|
||||
private SerializedProperty _edgeColorGlow;
|
||||
private SerializedProperty _edgeShinyRate;
|
||||
private SerializedProperty _edgeShinyWidth;
|
||||
private SerializedProperty _edgeShinyAutoPlaySpeed;
|
||||
private SerializedProperty _patternArea;
|
||||
|
||||
private SerializedProperty _detailFilter;
|
||||
private SerializedProperty _detailIntensity;
|
||||
private SerializedProperty _detailThreshold;
|
||||
private SerializedProperty _detailTex;
|
||||
private SerializedProperty _detailTexScale;
|
||||
private SerializedProperty _detailTexOffset;
|
||||
private SerializedProperty _detailTexSpeed;
|
||||
|
||||
private SerializedProperty _allowToModifyMeshShape;
|
||||
private SerializedProperty _customRoot;
|
||||
private SerializedProperty _flip;
|
||||
|
||||
private static bool expandOthers
|
||||
{
|
||||
@@ -122,358 +28,27 @@ namespace Coffee.UIEffects.Editors
|
||||
get => UIEffectEditorSettings.instance.m_ExpandOthers;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
protected override void OnEnable()
|
||||
{
|
||||
if (target == null) return;
|
||||
base.OnEnable();
|
||||
|
||||
_toneFilter = serializedObject.FindProperty("m_ToneFilter");
|
||||
_toneIntensity = serializedObject.FindProperty("m_ToneIntensity");
|
||||
|
||||
_colorFilter = serializedObject.FindProperty("m_ColorFilter");
|
||||
_color = serializedObject.FindProperty("m_Color");
|
||||
_colorIntensity = serializedObject.FindProperty("m_ColorIntensity");
|
||||
_colorGlow = serializedObject.FindProperty("m_ColorGlow");
|
||||
|
||||
_samplingFilter = serializedObject.FindProperty("m_SamplingFilter");
|
||||
_samplingIntensity = serializedObject.FindProperty("m_SamplingIntensity");
|
||||
_samplingWidth = serializedObject.FindProperty("m_SamplingWidth");
|
||||
_samplingScale = serializedObject.FindProperty("m_SamplingScale");
|
||||
|
||||
_transitionFilter = serializedObject.FindProperty("m_TransitionFilter");
|
||||
_transitionRate = serializedObject.FindProperty("m_TransitionRate");
|
||||
_transitionTex = serializedObject.FindProperty("m_TransitionTex");
|
||||
_transitionTexScale = serializedObject.FindProperty("m_TransitionTexScale");
|
||||
_transitionTexOffset = serializedObject.FindProperty("m_TransitionTexOffset");
|
||||
_transitionTexSpeed = serializedObject.FindProperty("m_TransitionTexSpeed");
|
||||
_transitionReverse = serializedObject.FindProperty("m_TransitionReverse");
|
||||
_transitionRotation = serializedObject.FindProperty("m_TransitionRotation");
|
||||
_transitionKeepAspectRatio = serializedObject.FindProperty("m_TransitionKeepAspectRatio");
|
||||
_transitionWidth = serializedObject.FindProperty("m_TransitionWidth");
|
||||
_transitionSoftness = serializedObject.FindProperty("m_TransitionSoftness");
|
||||
_transitionRange = serializedObject.FindProperty("m_TransitionRange");
|
||||
_transitionColorFilter = serializedObject.FindProperty("m_TransitionColorFilter");
|
||||
_transitionColor = serializedObject.FindProperty("m_TransitionColor");
|
||||
_transitionColorGlow = serializedObject.FindProperty("m_TransitionColorGlow");
|
||||
_transitionPatternReverse = serializedObject.FindProperty("m_TransitionPatternReverse");
|
||||
_transitionAutoPlaySpeed = serializedObject.FindProperty("m_TransitionAutoPlaySpeed");
|
||||
|
||||
_targetMode = serializedObject.FindProperty("m_TargetMode");
|
||||
_targetColor = serializedObject.FindProperty("m_TargetColor");
|
||||
_targetRange = serializedObject.FindProperty("m_TargetRange");
|
||||
_targetSoftness = serializedObject.FindProperty("m_TargetSoftness");
|
||||
|
||||
_blendType = serializedObject.FindProperty("m_BlendType");
|
||||
_srcBlendMode = serializedObject.FindProperty("m_SrcBlendMode");
|
||||
_dstBlendMode = serializedObject.FindProperty("m_DstBlendMode");
|
||||
|
||||
_shadowMode = serializedObject.FindProperty("m_ShadowMode");
|
||||
_shadowDistance = serializedObject.FindProperty("m_ShadowDistance");
|
||||
_shadowDistanceX = _shadowDistance.FindPropertyRelative("x");
|
||||
_shadowDistanceY = _shadowDistance.FindPropertyRelative("y");
|
||||
_shadowIteration = serializedObject.FindProperty("m_ShadowIteration");
|
||||
_shadowFade = serializedObject.FindProperty("m_ShadowFade");
|
||||
_shadowMirrorScale = serializedObject.FindProperty("m_ShadowMirrorScale");
|
||||
_shadowBlurIntensity = serializedObject.FindProperty("m_ShadowBlurIntensity");
|
||||
_shadowColorFilter = serializedObject.FindProperty("m_ShadowColorFilter");
|
||||
_shadowColor = serializedObject.FindProperty("m_ShadowColor");
|
||||
_shadowColorGlow = serializedObject.FindProperty("m_ShadowColorGlow");
|
||||
|
||||
_edgeMode = serializedObject.FindProperty("m_EdgeMode");
|
||||
_edgeWidth = serializedObject.FindProperty("m_EdgeWidth");
|
||||
_edgeColorFilter = serializedObject.FindProperty("m_EdgeColorFilter");
|
||||
_edgeColor = serializedObject.FindProperty("m_EdgeColor");
|
||||
_edgeColorGlow = serializedObject.FindProperty("m_EdgeColorGlow");
|
||||
_edgeShinyRate = serializedObject.FindProperty("m_EdgeShinyRate");
|
||||
_edgeShinyWidth = serializedObject.FindProperty("m_EdgeShinyWidth");
|
||||
_edgeShinyAutoPlaySpeed = serializedObject.FindProperty("m_EdgeShinyAutoPlaySpeed");
|
||||
_patternArea = serializedObject.FindProperty("m_PatternArea");
|
||||
|
||||
_gradationMode = serializedObject.FindProperty("m_GradationMode");
|
||||
_gradationIntensity = serializedObject.FindProperty("m_GradationIntensity");
|
||||
_gradationColorFilter = serializedObject.FindProperty("m_GradationColorFilter");
|
||||
_gradationColor1 = serializedObject.FindProperty("m_GradationColor1");
|
||||
_gradationColor2 = serializedObject.FindProperty("m_GradationColor2");
|
||||
_gradationColor3 = serializedObject.FindProperty("m_GradationColor3");
|
||||
_gradationColor4 = serializedObject.FindProperty("m_GradationColor4");
|
||||
_gradationGradient = serializedObject.FindProperty("m_GradationGradient");
|
||||
_gradationOffset = serializedObject.FindProperty("m_GradationOffset");
|
||||
_gradationScale = serializedObject.FindProperty("m_GradationScale");
|
||||
_gradationRotation = serializedObject.FindProperty("m_GradationRotation");
|
||||
|
||||
_detailFilter = serializedObject.FindProperty("m_DetailFilter");
|
||||
_detailIntensity = serializedObject.FindProperty("m_DetailIntensity");
|
||||
_detailThreshold = serializedObject.FindProperty("m_DetailThreshold");
|
||||
_detailTex = serializedObject.FindProperty("m_DetailTex");
|
||||
_detailTexScale = serializedObject.FindProperty("m_DetailTexScale");
|
||||
_detailTexOffset = serializedObject.FindProperty("m_DetailTexOffset");
|
||||
_detailTexSpeed = serializedObject.FindProperty("m_DetailTexSpeed");
|
||||
|
||||
_allowToModifyMeshShape = serializedObject.FindProperty("m_AllowToModifyMeshShape");
|
||||
_customRoot = serializedObject.FindProperty("m_CustomRoot");
|
||||
_flip = serializedObject.FindProperty("m_Flip");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
// Preset
|
||||
DrawPresetMenu(targets);
|
||||
DrawSeparator();
|
||||
|
||||
// Properties
|
||||
DrawProperties();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
public void DrawProperties()
|
||||
{
|
||||
// Tone filter
|
||||
if (DrawHeaderPopup(_toneFilter))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_toneIntensity);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Color filter
|
||||
DrawSeparator();
|
||||
var prevColorFilter = (ColorFilter)_colorFilter.intValue;
|
||||
if (DrawHeaderPopup(_colorFilter))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_colorIntensity);
|
||||
DrawColor(_color, (ColorFilter)_colorFilter.intValue, prevColorFilter, false);
|
||||
EditorGUILayout.PropertyField(_colorGlow);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUI.EndChangeCheck();
|
||||
|
||||
// Sampling filter
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_samplingFilter))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_samplingIntensity);
|
||||
if (_samplingFilter.intValue == (int)SamplingFilter.EdgeAlpha
|
||||
|| _samplingFilter.intValue == (int)SamplingFilter.EdgeLuminance)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_samplingWidth);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Transition filter
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_transitionFilter))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_transitionRate);
|
||||
EditorGUILayout.PropertyField(_transitionTex);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_transitionTexScale, EditorGUIUtility.TrTempContent("Scale"));
|
||||
EditorGUILayout.PropertyField(_transitionTexOffset, EditorGUIUtility.TrTempContent("Offset"));
|
||||
EditorGUILayout.PropertyField(_transitionTexSpeed, EditorGUIUtility.TrTempContent("Speed"));
|
||||
if (_transitionTexSpeed.vector2Value != Vector2.zero)
|
||||
{
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_transitionRotation, EditorGUIUtility.TrTempContent("Rotation"));
|
||||
EditorGUILayout.PropertyField(_transitionKeepAspectRatio,
|
||||
EditorGUIUtility.TrTempContent("Keep Aspect Ratio"));
|
||||
EditorGUILayout.PropertyField(_transitionReverse, EditorGUIUtility.TrTempContent("Reverse"));
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
if (_transitionFilter.intValue == (int)TransitionFilter.Pattern)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_transitionWidth, EditorGUIUtility.TrTempContent("Pattern Size"));
|
||||
EditorGUILayout.PropertyField(_transitionRange, EditorGUIUtility.TrTempContent("Pattern Range"));
|
||||
EditorGUILayout.PropertyField(_transitionPatternReverse,
|
||||
EditorGUIUtility.TrTempContent("Pattern Reverse"));
|
||||
DrawColor(_transitionColorFilter, _transitionColor, null);
|
||||
}
|
||||
else if (2 < _transitionFilter.intValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_transitionWidth);
|
||||
EditorGUILayout.PropertyField(_transitionSoftness);
|
||||
DrawColor(_transitionColorFilter, _transitionColor, _transitionColorGlow);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_transitionAutoPlaySpeed);
|
||||
if (0 < _transitionFilter.intValue && !Mathf.Approximately(0, _transitionAutoPlaySpeed.floatValue))
|
||||
{
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Target
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_targetMode))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_targetColor);
|
||||
EditorGUILayout.PropertyField(_targetRange);
|
||||
EditorGUILayout.PropertyField(_targetSoftness);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Blending
|
||||
DrawSeparator();
|
||||
if (!DrawHeaderPopup(_blendType))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_srcBlendMode);
|
||||
EditorGUILayout.PropertyField(_dstBlendMode);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Shadow
|
||||
DrawSeparator();
|
||||
var prevShadowMode = (ShadowMode)_shadowMode.intValue;
|
||||
if (DrawHeaderPopup(_shadowMode))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
if ((ShadowMode)_shadowMode.intValue == ShadowMode.Mirror)
|
||||
{
|
||||
if (prevShadowMode != ShadowMode.Mirror)
|
||||
{
|
||||
_shadowDistanceX.floatValue = 0.5f;
|
||||
_shadowDistanceY.floatValue = 0f;
|
||||
}
|
||||
|
||||
EditorGUILayout.Slider(_shadowDistanceX, 0, 1, "Reflection");
|
||||
EditorGUILayout.PropertyField(_shadowDistanceY, EditorGUIUtility.TrTempContent("Offset"));
|
||||
EditorGUILayout.PropertyField(_shadowMirrorScale);
|
||||
EditorGUILayout.PropertyField(_shadowFade);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prevShadowMode == ShadowMode.Mirror)
|
||||
{
|
||||
_shadowDistanceX.floatValue = 1f;
|
||||
_shadowDistanceY.floatValue = -1f;
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_shadowDistance);
|
||||
EditorGUILayout.PropertyField(_shadowIteration);
|
||||
DrawColor(_shadowColorFilter, _shadowColor, _shadowColorGlow, false);
|
||||
EditorGUILayout.PropertyField(_shadowFade);
|
||||
}
|
||||
|
||||
// Shadow blur intensity
|
||||
switch ((SamplingFilter)_samplingFilter.intValue)
|
||||
{
|
||||
case SamplingFilter.BlurFast:
|
||||
case SamplingFilter.BlurMedium:
|
||||
case SamplingFilter.BlurDetail:
|
||||
EditorGUILayout.PropertyField(_shadowBlurIntensity);
|
||||
break;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Gradient
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_gradationMode))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_gradationColorFilter);
|
||||
switch ((GradationMode)_gradationMode.intValue)
|
||||
{
|
||||
case GradationMode.HorizontalGradient:
|
||||
case GradationMode.VerticalGradient:
|
||||
case GradationMode.AngleGradient:
|
||||
DrawGradientField(_gradationGradient);
|
||||
break;
|
||||
case GradationMode.Diagonal:
|
||||
DrawColorPickerField("Top", _gradationColor1, _gradationColor2);
|
||||
DrawColorPickerField("Bottom", _gradationColor3, _gradationColor4);
|
||||
break;
|
||||
default:
|
||||
DrawColorPickerField(EditorGUILayout.GetControlRect(), _gradationColor1, true);
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
r.width -= 24;
|
||||
DrawColorPickerField(r, _gradationColor2, true);
|
||||
|
||||
r.x += r.width + 4;
|
||||
r.width = 20;
|
||||
SwapColorsButton(r, _gradationColor1, _gradationColor2);
|
||||
break;
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_gradationIntensity);
|
||||
EditorGUILayout.PropertyField(_gradationOffset);
|
||||
EditorGUILayout.PropertyField(_gradationScale);
|
||||
|
||||
if ((GradationMode)_gradationMode.intValue == GradationMode.Angle
|
||||
|| (GradationMode)_gradationMode.intValue == GradationMode.AngleGradient)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_gradationRotation);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_transitionKeepAspectRatio,
|
||||
EditorGUIUtility.TrTempContent("Keep Aspect Ratio"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Edge Mode
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_edgeMode))
|
||||
{
|
||||
EditorGUILayout.PropertyField(_edgeWidth);
|
||||
DrawColor(_edgeColorFilter, _edgeColor, _edgeColorGlow);
|
||||
|
||||
if ((EdgeMode)_edgeMode.intValue == EdgeMode.Shiny)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_edgeShinyRate);
|
||||
EditorGUILayout.PropertyField(_edgeShinyWidth);
|
||||
EditorGUILayout.PropertyField(_edgeShinyAutoPlaySpeed);
|
||||
|
||||
if (!Mathf.Approximately(0, _edgeShinyAutoPlaySpeed.floatValue))
|
||||
{
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
if (_transitionFilter.intValue == (int)TransitionFilter.Pattern)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_patternArea);
|
||||
}
|
||||
}
|
||||
|
||||
// Detail filter
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_detailFilter))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
if ((DetailFilter)_detailFilter.intValue == DetailFilter.Masking)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_detailThreshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(_detailIntensity);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_detailTex);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_detailTexScale, EditorGUIUtility.TrTempContent("Scale"));
|
||||
EditorGUILayout.PropertyField(_detailTexOffset, EditorGUIUtility.TrTempContent("Offset"));
|
||||
EditorGUILayout.PropertyField(_detailTexSpeed, EditorGUIUtility.TrTempContent("Speed"));
|
||||
if (_detailTexSpeed.vector2Value != Vector2.zero)
|
||||
{
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_transitionRotation, EditorGUIUtility.TrTempContent("Rotation"));
|
||||
EditorGUILayout.PropertyField(_transitionKeepAspectRatio,
|
||||
EditorGUIUtility.TrTempContent("Keep Aspect Ratio"));
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Others
|
||||
DrawSeparator();
|
||||
expandOthers = EditorGUILayout.BeginFoldoutHeaderGroup(expandOthers, "Others");
|
||||
if (expandOthers)
|
||||
@@ -481,143 +56,11 @@ namespace Coffee.UIEffects.Editors
|
||||
EditorGUILayout.PropertyField(_samplingScale);
|
||||
EditorGUILayout.PropertyField(_allowToModifyMeshShape);
|
||||
EditorGUILayout.PropertyField(_customRoot);
|
||||
EditorGUILayout.PropertyField(_flip);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawColorPickerField(string label, SerializedProperty color1, SerializedProperty color2)
|
||||
{
|
||||
var labelWidth = EditorGUIUtility.labelWidth;
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
r.width -= 24;
|
||||
EditorGUI.PrefixLabel(new Rect(r.x, r.y, labelWidth, r.height), EditorGUIUtility.TrTempContent(label));
|
||||
|
||||
var indentLevel = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
var rPos = new Rect(r.x + labelWidth, r.y, (r.width - labelWidth) / 2, r.height);
|
||||
DrawColorPickerField(rPos, GUIContent.none, color1, true);
|
||||
|
||||
rPos.x += rPos.width;
|
||||
DrawColorPickerField(rPos, GUIContent.none, color2, true);
|
||||
|
||||
// Swap colors button
|
||||
SwapColorsButton(new Rect(r.x + r.width + 4, r.y, 20, 20), color1, color2);
|
||||
EditorGUI.indentLevel = indentLevel;
|
||||
}
|
||||
|
||||
private static void DrawColorPickerField(Rect rect, SerializedProperty color, bool showAlpha)
|
||||
{
|
||||
var label = EditorGUIUtility.TrTempContent(color.displayName);
|
||||
label.tooltip = color.tooltip;
|
||||
DrawColorPickerField(rect, label, color, showAlpha);
|
||||
}
|
||||
|
||||
private static void DrawColorPickerField(Rect rect, GUIContent label, SerializedProperty color, bool showAlpha)
|
||||
{
|
||||
var hdr = UIEffectProjectSettings.useHdrColorPicker;
|
||||
EditorGUI.showMixedValue = color.hasMultipleDifferentValues;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var colorValue = EditorGUI.ColorField(rect, label, color.colorValue, true, showAlpha, hdr);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
color.colorValue = colorValue;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawGradientField(SerializedProperty gradient)
|
||||
{
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
var label = EditorGUIUtility.TrTempContent(gradient.displayName);
|
||||
label.tooltip = gradient.tooltip;
|
||||
var hdr = UIEffectProjectSettings.useHdrColorPicker;
|
||||
EditorGUI.showMixedValue = gradient.hasMultipleDifferentValues;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var gradientValue = EditorGUI.GradientField(r, label, s_GetGradient(gradient), hdr);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
s_SetGradient(gradient, gradientValue);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawColor(SerializedProperty color, ColorFilter filter, ColorFilter prevFilter,
|
||||
bool showAlpha = true)
|
||||
{
|
||||
if (filter == ColorFilter.None) return;
|
||||
|
||||
if (filter == ColorFilter.HsvModifier)
|
||||
{
|
||||
if (prevFilter != ColorFilter.HsvModifier)
|
||||
{
|
||||
color.colorValue = Color.black;
|
||||
}
|
||||
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("r"), -0.5f, 0.5f, "Hue");
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("g"), -1f, 1f, "Saturation");
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("b"), -1f, 1f, "Value");
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("a"), 0, 1, "Alpha");
|
||||
}
|
||||
else if (filter == ColorFilter.Contrast)
|
||||
{
|
||||
if (prevFilter != ColorFilter.Contrast)
|
||||
{
|
||||
color.colorValue = Color.black;
|
||||
}
|
||||
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("r"), -1f, 1f, "Contrast");
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("g"), -1f, 1f, "Brightness");
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("a"), 0, 1, "Alpha");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prevFilter == ColorFilter.HsvModifier || prevFilter == ColorFilter.Contrast)
|
||||
{
|
||||
color.colorValue = Color.white;
|
||||
}
|
||||
|
||||
DrawColorPickerField(EditorGUILayout.GetControlRect(), color, showAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawColor(SerializedProperty filter, SerializedProperty color, SerializedProperty glow,
|
||||
bool showAlpha = true)
|
||||
{
|
||||
var prevFilter = (ColorFilter)filter.intValue;
|
||||
EditorGUILayout.PropertyField(filter);
|
||||
if (filter.intValue == (int)ColorFilter.None) return;
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
DrawColor(color, (ColorFilter)filter.intValue, prevFilter, showAlpha);
|
||||
|
||||
if (glow != null)
|
||||
{
|
||||
EditorGUILayout.PropertyField(glow);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
|
||||
private static void SwapColorsButton(Rect rect, SerializedProperty color1, SerializedProperty color2)
|
||||
{
|
||||
if (GUI.Button(rect, EditorGUIUtility.IconContent("preaudioloopoff"), "iconbutton"))
|
||||
{
|
||||
(color1.colorValue, color2.colorValue) = (color2.colorValue, color1.colorValue);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool DrawHeaderPopup(SerializedProperty sp)
|
||||
{
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
var pos = EditorGUI.PrefixLabel(r, EditorGUIUtility.TrTempContent(sp.displayName), EditorStyles.boldLabel);
|
||||
EditorGUI.PropertyField(pos, sp, GUIContent.none);
|
||||
return 0 < sp.intValue;
|
||||
}
|
||||
|
||||
private static void DrawSeparator()
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
GUILayout.Label(GUIContent.none, "sv_iconselector_sep", GUILayout.ExpandWidth(true));
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private static void DrawPresetMenu(Object[] targets)
|
||||
@@ -676,28 +119,23 @@ namespace Coffee.UIEffects.Editors
|
||||
}
|
||||
}
|
||||
|
||||
public static void DropDownPreset(Rect r, Predicate<(string path, bool builtin, UIEffect preset)> valid,
|
||||
Action<UIEffect> callback)
|
||||
public static void DropDownPreset(Rect r, Predicate<(string path, bool builtin, UIEffectPreset preset)> valid,
|
||||
Action<UIEffectPreset> callback)
|
||||
{
|
||||
var menu = new GenericMenu();
|
||||
var separatorAdded = false;
|
||||
foreach (var preset in UIEffectProjectSettings.LoadEditorPresets())
|
||||
foreach (var preset in UIEffectProjectSettings.LoadEditorPresetsV2())
|
||||
{
|
||||
var (path, builtin) = UIEffectProjectSettings.GetPresetPath(preset);
|
||||
if (valid != null && valid.Invoke((path, builtin, preset)) == false) continue;
|
||||
|
||||
if (builtin)
|
||||
if (builtin && !separatorAdded)
|
||||
{
|
||||
if (!separatorAdded)
|
||||
{
|
||||
separatorAdded = true;
|
||||
menu.AddSeparator(string.Empty);
|
||||
}
|
||||
|
||||
path = path.Substring(6).Replace(" - ", "/");
|
||||
separatorAdded = true;
|
||||
menu.AddSeparator(string.Empty);
|
||||
}
|
||||
|
||||
menu.AddItem(new GUIContent(path), false, x => callback(x as UIEffect), preset);
|
||||
menu.AddItem(new GUIContent(path.Replace("-", "/")), false, x => callback(x as UIEffectPreset), preset);
|
||||
}
|
||||
|
||||
menu.DropDown(r);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace Coffee.UIEffects.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIEffectPreset), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIEffectPresetEditor : UIEffectPropertyEditor
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60b661e9d7501483dbd6b02ffa399405
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,8 @@
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Coffee.UIEffectInternal;
|
||||
using UnityEditorInternal;
|
||||
@@ -9,24 +13,29 @@ namespace Coffee.UIEffects.Editors
|
||||
public class UIEffectProjectSettingsEditor : Editor
|
||||
{
|
||||
private ReorderableList _reorderableList;
|
||||
private SerializedProperty _runtimePresets;
|
||||
private SerializedProperty _runtimePresetsV2;
|
||||
private SerializedProperty _useHDRColorPicker;
|
||||
private SerializedProperty _transformSensitivity;
|
||||
private bool _isInitialized;
|
||||
private ShaderVariantRegistryEditor _shaderVariantRegistryEditor;
|
||||
private UIEffect[] _legacyPresets;
|
||||
private bool _expandRuntimePresets;
|
||||
private bool _expandLegacyPrefabs;
|
||||
|
||||
private void InitializeIfNeeded()
|
||||
{
|
||||
if (_isInitialized) return;
|
||||
|
||||
_transformSensitivity = serializedObject.FindProperty("m_TransformSensitivity");
|
||||
_useHDRColorPicker = serializedObject.FindProperty("m_UseHDRColorPicker");
|
||||
var runtimePresets = serializedObject.FindProperty("m_RuntimePresets");
|
||||
_reorderableList = new ReorderableList(serializedObject, runtimePresets, true, true, true, true);
|
||||
_runtimePresets = serializedObject.FindProperty("m_RuntimePresets");
|
||||
_runtimePresetsV2 = serializedObject.FindProperty("m_RuntimePresetsV2");
|
||||
|
||||
_reorderableList = new ReorderableList(serializedObject, _runtimePresetsV2, true, true, true, true);
|
||||
_reorderableList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Runtime Presets");
|
||||
_reorderableList.drawElementCallback = (rect, index, isActive, isFocused) =>
|
||||
{
|
||||
var element = _reorderableList.serializedProperty.GetArrayElementAtIndex(index);
|
||||
var effect = element.objectReferenceValue as UIEffect;
|
||||
var effect = element.objectReferenceValue as UIEffectPreset;
|
||||
rect.y += 2;
|
||||
rect.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
@@ -37,13 +46,18 @@ namespace Coffee.UIEffects.Editors
|
||||
_reorderableList.onAddDropdownCallback = (rect, list) =>
|
||||
{
|
||||
UIEffectEditor.DropDownPreset(rect,
|
||||
x => !x.builtin && !UIEffectProjectSettings.instance.m_RuntimePresets.Contains(x.preset),
|
||||
x => !UIEffectProjectSettings.instance.m_RuntimePresetsV2.Contains(x.preset),
|
||||
UIEffectProjectSettings.RegisterRuntimePreset);
|
||||
};
|
||||
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_legacyPresets = UIEffectProjectSettings.LoadEditorPresets();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_isInitialized = false;
|
||||
@@ -55,12 +69,12 @@ namespace Coffee.UIEffects.Editors
|
||||
InitializeIfNeeded();
|
||||
|
||||
// Settings
|
||||
// Transform sensitivity.
|
||||
EditorGUILayout.PropertyField(_transformSensitivity);
|
||||
|
||||
// Runtime Presets
|
||||
_reorderableList.DoLayoutList();
|
||||
|
||||
// Legacy Presets
|
||||
DrawLegacyPresets();
|
||||
|
||||
// Editor
|
||||
// Use HDR color pickers.
|
||||
EditorGUILayout.PropertyField(_useHDRColorPicker);
|
||||
@@ -84,5 +98,118 @@ namespace Coffee.UIEffects.Editors
|
||||
GUILayout.FlexibleSpace();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DrawLegacyPresets()
|
||||
{
|
||||
for (var i = _runtimePresets.arraySize - 1; 0 <= i; i--)
|
||||
{
|
||||
if (!_runtimePresets.GetArrayElementAtIndex(i).objectReferenceValue)
|
||||
{
|
||||
_runtimePresets.DeleteArrayElementAtIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (_legacyPresets.Length == 0 && _runtimePresets.arraySize == 0) return;
|
||||
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
var title = EditorGUIUtility.TrTextContent("Legacy Presets (Obsolete)", "", "warning");
|
||||
EditorGUILayout.LabelField(title,
|
||||
EditorStyles.boldLabel);
|
||||
|
||||
_expandRuntimePresets = EditorGUILayout.Foldout(_expandRuntimePresets,
|
||||
$"Legacy Runtime Presets ({_runtimePresets.arraySize})");
|
||||
if (_expandRuntimePresets)
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
for (var i = 0; i < _runtimePresets.arraySize; i++)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_runtimePresets.GetArrayElementAtIndex(i), GUIContent.none);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
_expandLegacyPrefabs = EditorGUILayout.Foldout(_expandLegacyPrefabs,
|
||||
$"Legacy Preset Prefabs ({_legacyPresets.Length})");
|
||||
if (_expandLegacyPrefabs)
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
foreach (var legacyPreset in _legacyPresets)
|
||||
{
|
||||
EditorGUILayout.ObjectField(legacyPreset, typeof(UIEffect), false);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
EditorGUILayout.TextArea(
|
||||
"The prefab based presets system is obsolete.\n" +
|
||||
"In the new preset system, UIEffectPreset assets are used.\n" +
|
||||
"Click the button below to convert your legacy preset prefabs into UIEffectPreset assets.\n" +
|
||||
"The UIEffectPreset asset will be saved in the same directory as the prefab, using the same name.\n" +
|
||||
"You can load the new preset via the UIEffect.LoadPreset method.",
|
||||
EditorStyles.miniLabel);
|
||||
if (GUILayout.Button(EditorGUIUtility.TrTempContent("Convert All Legacy Presets in the Project")))
|
||||
{
|
||||
ConvertAllLegacyPresets();
|
||||
_runtimePresets.ClearArray();
|
||||
}
|
||||
|
||||
if (GUILayout.Button(EditorGUIUtility.TrTempContent("Delete All Legacy Presets in the Project")))
|
||||
{
|
||||
foreach (var legacyPreset in _legacyPresets)
|
||||
{
|
||||
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(legacyPreset));
|
||||
}
|
||||
|
||||
_runtimePresets.ClearArray();
|
||||
_legacyPresets = Array.Empty<UIEffect>();
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void ConvertAllLegacyPresets()
|
||||
{
|
||||
var length = _legacyPresets.Length;
|
||||
var converted = new HashSet<string>(UIEffectProjectSettings.LoadEditorPresetsV2()
|
||||
.Select(x => Path.ChangeExtension(AssetDatabase.GetAssetPath(x), ".prefab")));
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
var preset = _legacyPresets[i];
|
||||
var path = AssetDatabase.GetAssetPath(preset);
|
||||
if (converted.Contains(path)) continue;
|
||||
|
||||
EditorUtility.DisplayProgressBar("Convert To UIEffectPreset", path, (float)i / length);
|
||||
var newPath = Path.ChangeExtension(path, ".asset");
|
||||
newPath = AssetDatabase.GenerateUniqueAssetPath(newPath);
|
||||
var newPreset = CreateInstance<UIEffectPreset>();
|
||||
preset.SavePreset(newPreset, false);
|
||||
newPreset.hideFlags = preset.hideFlags;
|
||||
AssetDatabase.CreateAsset(newPreset, newPath);
|
||||
|
||||
var importer = AssetImporter.GetAtPath(path);
|
||||
var newImporter = AssetImporter.GetAtPath(newPath);
|
||||
newImporter.userData = importer.userData;
|
||||
newImporter.SetAssetBundleNameAndVariant(importer.assetBundleName, importer.assetBundleVariant);
|
||||
newImporter.SaveAndReimport();
|
||||
|
||||
// Remove the legacy preset from the project settings and add the new preset.
|
||||
if (UIEffectProjectSettings.instance.m_RuntimePresets.Contains(preset))
|
||||
{
|
||||
var count = _runtimePresetsV2.arraySize;
|
||||
_runtimePresetsV2.InsertArrayElementAtIndex(count);
|
||||
_runtimePresetsV2.GetArrayElementAtIndex(count).objectReferenceValue = newPreset;
|
||||
}
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,610 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Coffee.UIEffects.Editors
|
||||
{
|
||||
public abstract class UIEffectPropertyEditor : Editor
|
||||
{
|
||||
private static readonly PropertyInfo s_PiGradient = typeof(SerializedProperty)
|
||||
.GetProperty("gradientValue", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
private static readonly Func<SerializedProperty, Gradient> s_GetGradient =
|
||||
(Func<SerializedProperty, Gradient>)Delegate.CreateDelegate(typeof(Func<SerializedProperty, Gradient>),
|
||||
s_PiGradient.GetMethod);
|
||||
|
||||
private static readonly Action<SerializedProperty, Gradient> s_SetGradient =
|
||||
(Action<SerializedProperty, Gradient>)Delegate.CreateDelegate(typeof(Action<SerializedProperty, Gradient>),
|
||||
s_PiGradient.SetMethod);
|
||||
|
||||
private SerializedProperty _toneFilter;
|
||||
private SerializedProperty _toneIntensity;
|
||||
|
||||
private SerializedProperty _colorFilter;
|
||||
private SerializedProperty _color;
|
||||
private SerializedProperty _colorIntensity;
|
||||
private SerializedProperty _colorGlow;
|
||||
|
||||
private SerializedProperty _samplingFilter;
|
||||
private SerializedProperty _samplingIntensity;
|
||||
private SerializedProperty _samplingWidth;
|
||||
|
||||
private SerializedProperty _transitionFilter;
|
||||
private SerializedProperty _transitionRate;
|
||||
private SerializedProperty _transitionTex;
|
||||
private SerializedProperty _transitionTexScale;
|
||||
private SerializedProperty _transitionTexOffset;
|
||||
private SerializedProperty _transitionTexSpeed;
|
||||
private SerializedProperty _transitionReverse;
|
||||
private SerializedProperty _transitionRotation;
|
||||
private SerializedProperty _transitionKeepAspectRatio;
|
||||
private SerializedProperty _transitionWidth;
|
||||
private SerializedProperty _transitionSoftness;
|
||||
private SerializedProperty _transitionRange;
|
||||
private SerializedProperty _transitionColorFilter;
|
||||
private SerializedProperty _transitionColor;
|
||||
private SerializedProperty _transitionColorGlow;
|
||||
private SerializedProperty _transitionPatternReverse;
|
||||
private SerializedProperty _transitionAutoPlaySpeed;
|
||||
private SerializedProperty _transitionGradient;
|
||||
|
||||
private SerializedProperty _targetMode;
|
||||
private SerializedProperty _targetColor;
|
||||
private SerializedProperty _targetRange;
|
||||
private SerializedProperty _targetSoftness;
|
||||
|
||||
private SerializedProperty _blendType;
|
||||
private SerializedProperty _srcBlendMode;
|
||||
private SerializedProperty _dstBlendMode;
|
||||
|
||||
private SerializedProperty _shadowMode;
|
||||
private SerializedProperty _shadowDistance;
|
||||
private SerializedProperty _shadowDistanceX;
|
||||
private SerializedProperty _shadowDistanceY;
|
||||
private SerializedProperty _shadowIteration;
|
||||
private SerializedProperty _shadowFade;
|
||||
private SerializedProperty _shadowMirrorScale;
|
||||
private SerializedProperty _shadowBlurIntensity;
|
||||
private SerializedProperty _shadowColorFilter;
|
||||
private SerializedProperty _shadowColor;
|
||||
private SerializedProperty _shadowColorGlow;
|
||||
|
||||
private SerializedProperty _gradationMode;
|
||||
private SerializedProperty _gradationIntensity;
|
||||
private SerializedProperty _gradationColorFilter;
|
||||
private SerializedProperty _gradationColor1;
|
||||
private SerializedProperty _gradationColor2;
|
||||
private SerializedProperty _gradationColor3;
|
||||
private SerializedProperty _gradationColor4;
|
||||
private SerializedProperty _gradationGradient;
|
||||
private SerializedProperty _gradationOffset;
|
||||
private SerializedProperty _gradationScale;
|
||||
private SerializedProperty _gradationRotation;
|
||||
private SerializedProperty _gradationWrapMode;
|
||||
private SerializedProperty _gradationReverse;
|
||||
|
||||
private SerializedProperty _edgeMode;
|
||||
private SerializedProperty _edgeWidth;
|
||||
private SerializedProperty _edgeColorFilter;
|
||||
private SerializedProperty _edgeColor;
|
||||
private SerializedProperty _edgeColorGlow;
|
||||
private SerializedProperty _edgeShinyRate;
|
||||
private SerializedProperty _edgeShinyWidth;
|
||||
private SerializedProperty _edgeShinyAutoPlaySpeed;
|
||||
private SerializedProperty _patternArea;
|
||||
|
||||
private SerializedProperty _detailFilter;
|
||||
private SerializedProperty _detailIntensity;
|
||||
private SerializedProperty _detailColor;
|
||||
private SerializedProperty _detailThreshold;
|
||||
private SerializedProperty _detailTex;
|
||||
private SerializedProperty _detailTexScale;
|
||||
private SerializedProperty _detailTexOffset;
|
||||
private SerializedProperty _detailTexSpeed;
|
||||
|
||||
private SerializedProperty _flip;
|
||||
private static GUIContent s_RotationLabel = new GUIContent("* Rotation");
|
||||
private static GUIContent s_KeepAspectRatioLabel = new GUIContent("* Keep Aspect Ratio");
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
_toneFilter = serializedObject.FindProperty("m_ToneFilter");
|
||||
_toneIntensity = serializedObject.FindProperty("m_ToneIntensity");
|
||||
|
||||
_colorFilter = serializedObject.FindProperty("m_ColorFilter");
|
||||
_color = serializedObject.FindProperty("m_Color");
|
||||
_colorIntensity = serializedObject.FindProperty("m_ColorIntensity");
|
||||
_colorGlow = serializedObject.FindProperty("m_ColorGlow");
|
||||
|
||||
_samplingFilter = serializedObject.FindProperty("m_SamplingFilter");
|
||||
_samplingIntensity = serializedObject.FindProperty("m_SamplingIntensity");
|
||||
_samplingWidth = serializedObject.FindProperty("m_SamplingWidth");
|
||||
|
||||
_transitionFilter = serializedObject.FindProperty("m_TransitionFilter");
|
||||
_transitionRate = serializedObject.FindProperty("m_TransitionRate");
|
||||
_transitionTex = serializedObject.FindProperty("m_TransitionTex");
|
||||
_transitionTexScale = serializedObject.FindProperty("m_TransitionTexScale");
|
||||
_transitionTexOffset = serializedObject.FindProperty("m_TransitionTexOffset");
|
||||
_transitionTexSpeed = serializedObject.FindProperty("m_TransitionTexSpeed");
|
||||
_transitionReverse = serializedObject.FindProperty("m_TransitionReverse");
|
||||
_transitionRotation = serializedObject.FindProperty("m_TransitionRotation");
|
||||
_transitionKeepAspectRatio = serializedObject.FindProperty("m_TransitionKeepAspectRatio");
|
||||
_transitionWidth = serializedObject.FindProperty("m_TransitionWidth");
|
||||
_transitionSoftness = serializedObject.FindProperty("m_TransitionSoftness");
|
||||
_transitionRange = serializedObject.FindProperty("m_TransitionRange");
|
||||
_transitionColorFilter = serializedObject.FindProperty("m_TransitionColorFilter");
|
||||
_transitionColor = serializedObject.FindProperty("m_TransitionColor");
|
||||
_transitionColorGlow = serializedObject.FindProperty("m_TransitionColorGlow");
|
||||
_transitionPatternReverse = serializedObject.FindProperty("m_TransitionPatternReverse");
|
||||
_transitionAutoPlaySpeed = serializedObject.FindProperty("m_TransitionAutoPlaySpeed");
|
||||
_transitionGradient = serializedObject.FindProperty("m_TransitionGradient");
|
||||
|
||||
s_RotationLabel.tooltip = _transitionRotation.tooltip;
|
||||
s_KeepAspectRatioLabel.tooltip = _transitionKeepAspectRatio.tooltip;
|
||||
|
||||
_targetMode = serializedObject.FindProperty("m_TargetMode");
|
||||
_targetColor = serializedObject.FindProperty("m_TargetColor");
|
||||
_targetRange = serializedObject.FindProperty("m_TargetRange");
|
||||
_targetSoftness = serializedObject.FindProperty("m_TargetSoftness");
|
||||
|
||||
_blendType = serializedObject.FindProperty("m_BlendType");
|
||||
_srcBlendMode = serializedObject.FindProperty("m_SrcBlendMode");
|
||||
_dstBlendMode = serializedObject.FindProperty("m_DstBlendMode");
|
||||
|
||||
_shadowMode = serializedObject.FindProperty("m_ShadowMode");
|
||||
_shadowDistance = serializedObject.FindProperty("m_ShadowDistance");
|
||||
_shadowDistanceX = _shadowDistance.FindPropertyRelative("x");
|
||||
_shadowDistanceY = _shadowDistance.FindPropertyRelative("y");
|
||||
_shadowIteration = serializedObject.FindProperty("m_ShadowIteration");
|
||||
_shadowFade = serializedObject.FindProperty("m_ShadowFade");
|
||||
_shadowMirrorScale = serializedObject.FindProperty("m_ShadowMirrorScale");
|
||||
_shadowBlurIntensity = serializedObject.FindProperty("m_ShadowBlurIntensity");
|
||||
_shadowColorFilter = serializedObject.FindProperty("m_ShadowColorFilter");
|
||||
_shadowColor = serializedObject.FindProperty("m_ShadowColor");
|
||||
_shadowColorGlow = serializedObject.FindProperty("m_ShadowColorGlow");
|
||||
|
||||
_edgeMode = serializedObject.FindProperty("m_EdgeMode");
|
||||
_edgeWidth = serializedObject.FindProperty("m_EdgeWidth");
|
||||
_edgeColorFilter = serializedObject.FindProperty("m_EdgeColorFilter");
|
||||
_edgeColor = serializedObject.FindProperty("m_EdgeColor");
|
||||
_edgeColorGlow = serializedObject.FindProperty("m_EdgeColorGlow");
|
||||
_edgeShinyRate = serializedObject.FindProperty("m_EdgeShinyRate");
|
||||
_edgeShinyWidth = serializedObject.FindProperty("m_EdgeShinyWidth");
|
||||
_edgeShinyAutoPlaySpeed = serializedObject.FindProperty("m_EdgeShinyAutoPlaySpeed");
|
||||
_patternArea = serializedObject.FindProperty("m_PatternArea");
|
||||
|
||||
_gradationMode = serializedObject.FindProperty("m_GradationMode");
|
||||
_gradationIntensity = serializedObject.FindProperty("m_GradationIntensity");
|
||||
_gradationColorFilter = serializedObject.FindProperty("m_GradationColorFilter");
|
||||
_gradationColor1 = serializedObject.FindProperty("m_GradationColor1");
|
||||
_gradationColor2 = serializedObject.FindProperty("m_GradationColor2");
|
||||
_gradationColor3 = serializedObject.FindProperty("m_GradationColor3");
|
||||
_gradationColor4 = serializedObject.FindProperty("m_GradationColor4");
|
||||
_gradationGradient = serializedObject.FindProperty("m_GradationGradient");
|
||||
_gradationOffset = serializedObject.FindProperty("m_GradationOffset");
|
||||
_gradationScale = serializedObject.FindProperty("m_GradationScale");
|
||||
_gradationRotation = serializedObject.FindProperty("m_GradationRotation");
|
||||
_gradationWrapMode = serializedObject.FindProperty("m_GradationWrapMode");
|
||||
_gradationReverse = serializedObject.FindProperty("m_GradationReverse");
|
||||
|
||||
_detailFilter = serializedObject.FindProperty("m_DetailFilter");
|
||||
_detailIntensity = serializedObject.FindProperty("m_DetailIntensity");
|
||||
_detailColor = serializedObject.FindProperty("m_DetailColor");
|
||||
_detailThreshold = serializedObject.FindProperty("m_DetailThreshold");
|
||||
_detailTex = serializedObject.FindProperty("m_DetailTex");
|
||||
_detailTexScale = serializedObject.FindProperty("m_DetailTexScale");
|
||||
_detailTexOffset = serializedObject.FindProperty("m_DetailTexOffset");
|
||||
_detailTexSpeed = serializedObject.FindProperty("m_DetailTexSpeed");
|
||||
|
||||
_flip = serializedObject.FindProperty("m_Flip");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
DrawProperties();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
public void DrawProperties()
|
||||
{
|
||||
// Tone filter
|
||||
if (DrawHeaderPopup(_toneFilter))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_toneIntensity);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Color filter
|
||||
DrawSeparator();
|
||||
var prevColorFilter = (ColorFilter)_colorFilter.intValue;
|
||||
if (DrawHeaderPopup(_colorFilter))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_colorIntensity);
|
||||
DrawColor(_color, (ColorFilter)_colorFilter.intValue, prevColorFilter, false);
|
||||
EditorGUILayout.PropertyField(_colorGlow);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUI.EndChangeCheck();
|
||||
|
||||
// Sampling filter
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_samplingFilter))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_samplingIntensity);
|
||||
if (_samplingFilter.intValue == (int)SamplingFilter.EdgeAlpha
|
||||
|| _samplingFilter.intValue == (int)SamplingFilter.EdgeLuminance)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_samplingWidth);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Transition filter
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_transitionFilter))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_transitionRate);
|
||||
EditorGUILayout.PropertyField(_transitionTex);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_transitionTexScale, EditorGUIUtility.TrTempContent("Scale"));
|
||||
EditorGUILayout.PropertyField(_transitionTexOffset, EditorGUIUtility.TrTempContent("Offset"));
|
||||
EditorGUILayout.PropertyField(_transitionTexSpeed, EditorGUIUtility.TrTempContent("Speed"));
|
||||
if (_transitionTexSpeed.vector2Value != Vector2.zero)
|
||||
{
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_transitionRotation, s_RotationLabel);
|
||||
EditorGUILayout.PropertyField(_transitionKeepAspectRatio, s_KeepAspectRatioLabel);
|
||||
EditorGUILayout.PropertyField(_transitionReverse, EditorGUIUtility.TrTempContent("Reverse"));
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
if (_transitionFilter.intValue == (int)TransitionFilter.Pattern)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_transitionWidth, EditorGUIUtility.TrTempContent("Pattern Size"));
|
||||
EditorGUILayout.PropertyField(_transitionRange, EditorGUIUtility.TrTempContent("Pattern Range"));
|
||||
EditorGUILayout.PropertyField(_transitionPatternReverse,
|
||||
EditorGUIUtility.TrTempContent("Pattern Reverse"));
|
||||
DrawColor(_transitionColorFilter, _transitionColor, null);
|
||||
}
|
||||
else if (_transitionFilter.intValue == (int)TransitionFilter.Blaze)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_transitionWidth);
|
||||
DrawGradientField(_transitionGradient);
|
||||
}
|
||||
else if (2 < _transitionFilter.intValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_transitionWidth);
|
||||
EditorGUILayout.PropertyField(_transitionSoftness);
|
||||
DrawColor(_transitionColorFilter, _transitionColor, _transitionColorGlow);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_transitionAutoPlaySpeed);
|
||||
if (0 < _transitionFilter.intValue && !Mathf.Approximately(0, _transitionAutoPlaySpeed.floatValue))
|
||||
{
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Target
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_targetMode))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_targetColor);
|
||||
EditorGUILayout.PropertyField(_targetRange);
|
||||
EditorGUILayout.PropertyField(_targetSoftness);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Blending
|
||||
DrawSeparator();
|
||||
if (!DrawHeaderPopup(_blendType))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_srcBlendMode);
|
||||
EditorGUILayout.PropertyField(_dstBlendMode);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Shadow
|
||||
DrawSeparator();
|
||||
var prevShadowMode = (ShadowMode)_shadowMode.intValue;
|
||||
if (DrawHeaderPopup(_shadowMode))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
if ((ShadowMode)_shadowMode.intValue == ShadowMode.Mirror)
|
||||
{
|
||||
if (prevShadowMode != ShadowMode.Mirror)
|
||||
{
|
||||
_shadowDistanceX.floatValue = 0.5f;
|
||||
_shadowDistanceY.floatValue = 0f;
|
||||
}
|
||||
|
||||
EditorGUILayout.Slider(_shadowDistanceX, 0, 1, "Reflection");
|
||||
EditorGUILayout.PropertyField(_shadowDistanceY, EditorGUIUtility.TrTempContent("Offset"));
|
||||
EditorGUILayout.PropertyField(_shadowMirrorScale);
|
||||
EditorGUILayout.PropertyField(_shadowFade);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prevShadowMode == ShadowMode.Mirror)
|
||||
{
|
||||
_shadowDistanceX.floatValue = 1f;
|
||||
_shadowDistanceY.floatValue = -1f;
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_shadowDistance);
|
||||
EditorGUILayout.PropertyField(_shadowIteration);
|
||||
DrawColor(_shadowColorFilter, _shadowColor, _shadowColorGlow, false);
|
||||
EditorGUILayout.PropertyField(_shadowFade);
|
||||
}
|
||||
|
||||
// Shadow blur intensity
|
||||
switch ((SamplingFilter)_samplingFilter.intValue)
|
||||
{
|
||||
case SamplingFilter.BlurFast:
|
||||
case SamplingFilter.BlurMedium:
|
||||
case SamplingFilter.BlurDetail:
|
||||
EditorGUILayout.PropertyField(_shadowBlurIntensity);
|
||||
break;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Gradient
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_gradationMode))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_gradationColorFilter);
|
||||
switch ((GradationMode)_gradationMode.intValue)
|
||||
{
|
||||
case GradationMode.HorizontalGradient:
|
||||
case GradationMode.VerticalGradient:
|
||||
case GradationMode.AngleGradient:
|
||||
case GradationMode.RadialGradient:
|
||||
DrawGradientField(_gradationGradient);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_gradationWrapMode, EditorGUIUtility.TrTempContent("Wrap Mode"));
|
||||
EditorGUILayout.PropertyField(_gradationReverse, EditorGUIUtility.TrTempContent("Reverse"));
|
||||
EditorGUI.indentLevel--;
|
||||
break;
|
||||
case GradationMode.Diagonal:
|
||||
DrawColorPickerField("Top", _gradationColor1, _gradationColor2);
|
||||
DrawColorPickerField("Bottom", _gradationColor3, _gradationColor4);
|
||||
break;
|
||||
default:
|
||||
DrawColorPickerField(EditorGUILayout.GetControlRect(), _gradationColor1, true);
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
r.width -= 24;
|
||||
DrawColorPickerField(r, _gradationColor2, true);
|
||||
|
||||
r.x += r.width + 4;
|
||||
r.width = 20;
|
||||
SwapColorsButton(r, _gradationColor1, _gradationColor2);
|
||||
break;
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_gradationIntensity);
|
||||
EditorGUILayout.PropertyField(_gradationOffset);
|
||||
EditorGUILayout.PropertyField(_gradationScale);
|
||||
|
||||
if ((GradationMode)_gradationMode.intValue == GradationMode.Angle
|
||||
|| (GradationMode)_gradationMode.intValue == GradationMode.AngleGradient)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_gradationRotation);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_transitionKeepAspectRatio, s_KeepAspectRatioLabel);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Edge Mode
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_edgeMode))
|
||||
{
|
||||
EditorGUILayout.PropertyField(_edgeWidth);
|
||||
DrawColor(_edgeColorFilter, _edgeColor, _edgeColorGlow);
|
||||
|
||||
if ((EdgeMode)_edgeMode.intValue == EdgeMode.Shiny)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_edgeShinyRate);
|
||||
EditorGUILayout.PropertyField(_edgeShinyWidth);
|
||||
EditorGUILayout.PropertyField(_edgeShinyAutoPlaySpeed);
|
||||
|
||||
if (!Mathf.Approximately(0, _edgeShinyAutoPlaySpeed.floatValue))
|
||||
{
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
if (_transitionFilter.intValue == (int)TransitionFilter.Pattern)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_patternArea);
|
||||
}
|
||||
}
|
||||
|
||||
// Detail filter
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_detailFilter))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
if ((DetailFilter)_detailFilter.intValue == DetailFilter.Masking)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_detailThreshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(_detailIntensity);
|
||||
DrawColorPickerField(EditorGUILayout.GetControlRect(), _detailColor, true);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_detailTex);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_detailTexScale, EditorGUIUtility.TrTempContent("Scale"));
|
||||
EditorGUILayout.PropertyField(_detailTexOffset, EditorGUIUtility.TrTempContent("Offset"));
|
||||
EditorGUILayout.PropertyField(_detailTexSpeed, EditorGUIUtility.TrTempContent("Speed"));
|
||||
if (_detailTexSpeed.vector2Value != Vector2.zero)
|
||||
{
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_transitionRotation, s_RotationLabel);
|
||||
EditorGUILayout.PropertyField(_transitionKeepAspectRatio, s_KeepAspectRatioLabel);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Flip
|
||||
DrawSeparator();
|
||||
DrawHeaderPopup(_flip);
|
||||
}
|
||||
|
||||
private static void DrawColorPickerField(string label, SerializedProperty color1, SerializedProperty color2)
|
||||
{
|
||||
var labelWidth = EditorGUIUtility.labelWidth;
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
r.width -= 24;
|
||||
EditorGUI.PrefixLabel(new Rect(r.x, r.y, labelWidth, r.height), EditorGUIUtility.TrTempContent(label));
|
||||
|
||||
var indentLevel = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
var rPos = new Rect(r.x + labelWidth, r.y, (r.width - labelWidth) / 2, r.height);
|
||||
DrawColorPickerField(rPos, GUIContent.none, color1, true);
|
||||
|
||||
rPos.x += rPos.width;
|
||||
DrawColorPickerField(rPos, GUIContent.none, color2, true);
|
||||
|
||||
// Swap colors button
|
||||
SwapColorsButton(new Rect(r.x + r.width + 4, r.y, 20, 20), color1, color2);
|
||||
EditorGUI.indentLevel = indentLevel;
|
||||
}
|
||||
|
||||
private static void DrawColorPickerField(Rect rect, SerializedProperty color, bool showAlpha)
|
||||
{
|
||||
var label = EditorGUIUtility.TrTempContent(color.displayName);
|
||||
label.tooltip = color.tooltip;
|
||||
DrawColorPickerField(rect, label, color, showAlpha);
|
||||
}
|
||||
|
||||
private static void DrawColorPickerField(Rect rect, GUIContent label, SerializedProperty color, bool showAlpha)
|
||||
{
|
||||
var hdr = UIEffectProjectSettings.useHdrColorPicker;
|
||||
EditorGUI.showMixedValue = color.hasMultipleDifferentValues;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var colorValue = EditorGUI.ColorField(rect, label, color.colorValue, true, showAlpha, hdr);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
color.colorValue = colorValue;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawGradientField(SerializedProperty gradient)
|
||||
{
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
var label = EditorGUIUtility.TrTempContent(gradient.displayName);
|
||||
label.tooltip = gradient.tooltip;
|
||||
var hdr = UIEffectProjectSettings.useHdrColorPicker;
|
||||
EditorGUI.showMixedValue = gradient.hasMultipleDifferentValues;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var gradientValue = EditorGUI.GradientField(r, label, s_GetGradient(gradient), hdr);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
s_SetGradient(gradient, gradientValue);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawColor(SerializedProperty color, ColorFilter filter, ColorFilter prevFilter,
|
||||
bool showAlpha = true)
|
||||
{
|
||||
if (filter == ColorFilter.None) return;
|
||||
|
||||
if (filter == ColorFilter.HsvModifier)
|
||||
{
|
||||
if (prevFilter != ColorFilter.HsvModifier)
|
||||
{
|
||||
color.colorValue = Color.black;
|
||||
}
|
||||
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("r"), -0.5f, 0.5f, "Hue");
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("g"), -1f, 1f, "Saturation");
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("b"), -1f, 1f, "Value");
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("a"), 0, 1, "Alpha");
|
||||
}
|
||||
else if (filter == ColorFilter.Contrast)
|
||||
{
|
||||
if (prevFilter != ColorFilter.Contrast)
|
||||
{
|
||||
color.colorValue = Color.black;
|
||||
}
|
||||
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("r"), -1f, 1f, "Contrast");
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("g"), -1f, 1f, "Brightness");
|
||||
EditorGUILayout.Slider(color.FindPropertyRelative("a"), 0, 1, "Alpha");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prevFilter == ColorFilter.HsvModifier || prevFilter == ColorFilter.Contrast)
|
||||
{
|
||||
color.colorValue = Color.white;
|
||||
}
|
||||
|
||||
DrawColorPickerField(EditorGUILayout.GetControlRect(), color, showAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawColor(SerializedProperty filter, SerializedProperty color, SerializedProperty glow,
|
||||
bool showAlpha = true)
|
||||
{
|
||||
var prevFilter = (ColorFilter)filter.intValue;
|
||||
EditorGUILayout.PropertyField(filter);
|
||||
if (filter.intValue == (int)ColorFilter.None) return;
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
DrawColor(color, (ColorFilter)filter.intValue, prevFilter, showAlpha);
|
||||
|
||||
if (glow != null)
|
||||
{
|
||||
EditorGUILayout.PropertyField(glow);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
private static void SwapColorsButton(Rect rect, SerializedProperty color1, SerializedProperty color2)
|
||||
{
|
||||
if (GUI.Button(rect, EditorGUIUtility.IconContent("preaudioloopoff"), "iconbutton"))
|
||||
{
|
||||
(color1.colorValue, color2.colorValue) = (color2.colorValue, color1.colorValue);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool DrawHeaderPopup(SerializedProperty sp)
|
||||
{
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
var pos = EditorGUI.PrefixLabel(r, EditorGUIUtility.TrTempContent(sp.displayName), EditorStyles.boldLabel);
|
||||
EditorGUI.PropertyField(pos, sp, GUIContent.none);
|
||||
return 0 < sp.intValue;
|
||||
}
|
||||
|
||||
protected static void DrawSeparator()
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
GUILayout.Label(GUIContent.none, "sv_iconselector_sep", GUILayout.ExpandWidth(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b54493685c0d4cf49bbc33b1492bed5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -11,6 +11,7 @@ namespace Coffee.UIEffects.Editors
|
||||
public class UIEffectReplicaEditor : Editor
|
||||
{
|
||||
private SerializedProperty _target;
|
||||
private SerializedProperty _preset;
|
||||
private SerializedProperty _useTargetTransform;
|
||||
private SerializedProperty _samplingScale;
|
||||
private SerializedProperty _allowToModifyMeshShape;
|
||||
@@ -20,6 +21,7 @@ namespace Coffee.UIEffects.Editors
|
||||
private void OnEnable()
|
||||
{
|
||||
_target = serializedObject.FindProperty("m_Target");
|
||||
_preset = serializedObject.FindProperty("m_Preset");
|
||||
_useTargetTransform = serializedObject.FindProperty("m_UseTargetTransform");
|
||||
_samplingScale = serializedObject.FindProperty("m_SamplingScale");
|
||||
_allowToModifyMeshShape = serializedObject.FindProperty("m_AllowToModifyMeshShape");
|
||||
@@ -31,27 +33,42 @@ namespace Coffee.UIEffects.Editors
|
||||
serializedObject.Update();
|
||||
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
r.width -= 60;
|
||||
EditorGUI.PropertyField(r, _target);
|
||||
r.width -= 120;
|
||||
if (_preset.objectReferenceValue)
|
||||
{
|
||||
EditorGUI.PropertyField(r, _preset);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.PropertyField(r, _target);
|
||||
}
|
||||
|
||||
// Preset button.
|
||||
r.x += r.width;
|
||||
r.width = 60;
|
||||
if (GUI.Button(r, EditorGUIUtility.TrTempContent("Preset"), "MiniPopup"))
|
||||
{
|
||||
UIEffectEditor.DropDownPreset(r, x => !x.builtin, p =>
|
||||
UIEffectEditor.DropDownPreset(r, null, p =>
|
||||
{
|
||||
_target.objectReferenceValue = p;
|
||||
_target.serializedObject.ApplyModifiedProperties();
|
||||
_target.objectReferenceValue = null;
|
||||
_preset.objectReferenceValue = p;
|
||||
_preset.serializedObject.ApplyModifiedProperties();
|
||||
});
|
||||
}
|
||||
|
||||
// Clear button.
|
||||
r.x += r.width;
|
||||
r.width = 60;
|
||||
if (GUI.Button(r, EditorGUIUtility.TrTempContent("Clear")))
|
||||
{
|
||||
_target.objectReferenceValue = null;
|
||||
_preset.objectReferenceValue = null;
|
||||
}
|
||||
|
||||
// Preset mode warning.
|
||||
if (_target.objectReferenceValue is UIEffect targetEffect && !targetEffect.gameObject.scene.IsValid())
|
||||
{
|
||||
r = EditorGUILayout.GetControlRect();
|
||||
r.width -= EditorGUIUtility.labelWidth;
|
||||
r.x += EditorGUIUtility.labelWidth;
|
||||
EditorGUI.HelpBox(r, "The target effect is not in the scene. (Preset mode)", MessageType.Warning);
|
||||
}
|
||||
|
||||
@@ -63,12 +80,13 @@ namespace Coffee.UIEffects.Editors
|
||||
EditorGUILayout.PropertyField(_samplingScale);
|
||||
EditorGUILayout.PropertyField(_allowToModifyMeshShape);
|
||||
|
||||
if (_target.objectReferenceValue)
|
||||
var parent = _target.objectReferenceValue ?? _preset.objectReferenceValue;
|
||||
if (parent)
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
CreateCachedEditor(_target.objectReferenceValue, null, ref _uiEffectEditor);
|
||||
CreateCachedEditor(parent, null, ref _uiEffectEditor);
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
(_uiEffectEditor as UIEffectEditor)?.DrawProperties();
|
||||
(_uiEffectEditor as UIEffectPropertyEditor)?.DrawProperties();
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
+77
-30
@@ -7,6 +7,7 @@
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
[](https://github.com/mob-sakai/UIEffect/blob/main/LICENSE.md)
|
||||
@@ -20,9 +21,12 @@
|
||||
|
||||
## 📝 Description <!-- omit in toc -->
|
||||
|
||||
**_"Decorate your UI, simply and powerfully."_**
|
||||
UIEffect is an open-source package that allows you to intuitively apply rich Unity UI effects directly from the Inspector or via code.
|
||||
Combine various filters, such as grayscale, blur, and dissolve, to decorate your UI with a unique visual style!
|
||||
**_"Decorate your UI, simply and powerfully."_**
|
||||
|
||||
UIEffect is a powerful, open-source Unity package that transforms your UI with stunning visual effects.
|
||||
Apply professional-grade filters like grayscale, blur, and dissolve directly from the Inspector—no coding required!
|
||||
|
||||
✨ **Perfect for**: Game developers, UI designers, and anyone looking to enhance their Unity UI with minimal effort
|
||||
|
||||

|
||||
|
||||
@@ -48,12 +52,14 @@ Combine various filters, such as grayscale, blur, and dissolve, to decorate your
|
||||
- [Gradation Mode](#gradation-mode)
|
||||
- [Edge Mode](#edge-mode)
|
||||
- [Detail Filter](#detail-filter)
|
||||
- [Flip](#flip)
|
||||
- [Others](#others)
|
||||
- [Component: UIEffectTweener](#component-uieffecttweener)
|
||||
- [Component: UIEffectReplica](#component-uieffectreplica)
|
||||
- [Usage with TextMeshPro](#usage-with-textmeshpro)
|
||||
- [Usage with SoftMaskForUGUI](#usage-with-softmaskforugui)
|
||||
- [Usage with ShaderGraph](#usage-with-shadergraph)
|
||||
- [Usage with Timeline](#usage-with-timeline)
|
||||
- [Runtime/Editor Preset for UIEffect](#runtimeeditor-preset-for-uieffect)
|
||||
- [Usage with Code](#usage-with-code)
|
||||
- [Project Settings](#project-settings)
|
||||
@@ -87,18 +93,18 @@ Combine various filters, such as grayscale, blur, and dissolve, to decorate your
|
||||
- **v4 compatible components (optional)**: For easy upgrading with minimal changes, compatible v4 components are available optionally.
|
||||
- **SoftMaskForUGUI support (optional)**: Compatible with SoftMaskForUGUI for creating soft masks for UI elements. See for more details [here](#usage-with-softmaskforugui).
|
||||
- **ShaderGraph support (optional)**: Add `Canvas (UIEffect)` sub target (material) for UIEffect shaders. See for more details [here](#usage-with-shadergraph).
|
||||
- **Timeline support**: Control UIEffect using Timeline with `ControlTrack` and `UIEffect Tracks`. See for more details [here](#usage-with-timeline).
|
||||
|
||||
<br><br>
|
||||
|
||||
## 🎮 Demo
|
||||
|
||||
|
||||

|
||||

|
||||
<img src="https://github.com/mob-sakai/mob-sakai/releases/download/docs/uieffect5.7.0-demo-pattern.gif" width="582"/>
|
||||

|
||||

|
||||
|
||||
[WebGL Demo](https://mob-sakai.github.io/UIEffect/)
|
||||
[Try the WebGL Demo](https://mob-sakai.github.io/UIEffect/)
|
||||
|
||||
<br><br>
|
||||
|
||||
@@ -116,7 +122,7 @@ _This package requires **Unity 2020.3 or later**._
|
||||
```
|
||||
- To update the package, use Package Manager UI (`Window > Package Manager`) or run the following command with `@{version}`:
|
||||
```
|
||||
openupm add com.coffee.ui-effect@5.7.0
|
||||
openupm add com.coffee.ui-effect@5.9.0
|
||||
```
|
||||
|
||||
### Install via UPM (with Package Manager UI)
|
||||
@@ -125,7 +131,7 @@ _This package requires **Unity 2020.3 or later**._
|
||||
- Click `+ > Add package from git URL...` and input the repository URL: `https://github.com/mob-sakai/UIEffect.git?path=Packages/src`
|
||||

|
||||
- To update the package, change suffix `#{version}` to the target version.
|
||||
- e.g. `https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.7.0`
|
||||
- e.g. `https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.9.0`
|
||||
|
||||
### Install via UPM (Manually)
|
||||
|
||||
@@ -140,7 +146,7 @@ _This package requires **Unity 2020.3 or later**._
|
||||
```
|
||||
|
||||
- To update the package, change suffix `#{version}` to the target version.
|
||||
- e.g. `"com.coffee.ui-effect": "https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.7.0",`
|
||||
- e.g. `"com.coffee.ui-effect": "https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.9.0",`
|
||||
|
||||
### Install as Embedded Package
|
||||
|
||||
@@ -197,10 +203,20 @@ If upgrading from UIEffect v4 to v5, note the following breaking changes:
|
||||
2. Add a `UIEffect` component to a UI element (Image, RawImage, Text, TextMeshProUGUI, etc...) from the `Add Component` in the inspector or `Component > UI > UIEffect` menu.
|
||||

|
||||
|
||||
3. Adjust the effect filters and parameters in the inspector.
|
||||
3. Set `Tone Filter` to `Grayscale` and `Tone Intensity` to `1.0`.
|
||||
<img src="https://github.com/mob-sakai/mob-sakai/releases/download/docs/1749029605043.png" width="480"/>
|
||||
|
||||
4. Try other effect filters and parameters in the inspector.
|
||||

|
||||
|
||||
4. Enjoy!
|
||||
5. From the top menu, you can load/append preset.
|
||||
> [!TIP]
|
||||
> `Load` overwrites all properties with the preset, while `Append` only overwrites enabled filters and modes with the preset.
|
||||
> You can easily build effects by combining them with `Append`.
|
||||
|
||||

|
||||
|
||||
5. Enjoy!
|
||||
|
||||
<br><br>
|
||||
|
||||
@@ -252,8 +268,8 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||
|
||||

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

|
||||
- **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.
|
||||
@@ -267,6 +283,7 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||
- **Transition Color**: The color of the transition.
|
||||
- **Transition Color Glow**: Set the transition color to glow.
|
||||
- **Transition Auto Play Speed**: The speed of the transition animation (using shader side `_Time`). You can use this property to loop the `TransitionRate` without tweener or animation.
|
||||
- ⚠️ NOTE: This uses scaled time (affected by `Time.timeScale`). If you need unscaled time (useful for pause-resistant effects), use the [UIEffectTweener](#component-uieffecttweener) component instead.
|
||||
|
||||
> [!TIP]
|
||||
> **Transition Tex** applies transitions using its alpha channel.
|
||||
@@ -321,10 +338,10 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||
|
||||

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

|
||||
- **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.
|
||||
- **Gradation Gradient**: The gradient of the gradation. HDR colors are supported.
|
||||
- `Blend` and `Fixed` modes are available.
|
||||
- **Gradation Color 1**: The first color of the gradation.
|
||||
- **Gradation Color 2**: The second color of the gradation.
|
||||
@@ -332,6 +349,8 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||
- **Gradation Offset**: The offset of the gradation range.
|
||||
- **Gradation Scale**: The scale of the gradation range.
|
||||
- **Gradation Rotation** (`Angle` or `AngleGradient` only): The rotation of the gradation range.
|
||||
- **Gradation Wrap Mode**: `Repaet`, `Clamp`, `Mirror`, `Mirror Once`
|
||||
- **Gradation Reverse**: Reverse the gradient.
|
||||
- **Keep Aspect Ratio**:
|
||||
- ⚠️ NOTE: `Keep Aspect Ratio` is shared with `Transition Filter` and `Gradation Mode` and `Detail Filter`.
|
||||
|
||||
@@ -349,16 +368,18 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||
- **Edge Color Glow**: Set the shadow color to glow.
|
||||
- **Edge Shiny Width**: The width of the edge shiny.
|
||||
- **Edge Shiny Auto Play Speed**: The speed of the edge shiny (using shader side `_Time`).
|
||||
- ⚠️ NOTE: This uses scaled time (affected by `Time.timeScale`). If you need unscaled time (useful for pause-resistant effects), use the [UIEffectTweener](#component-uieffecttweener) component instead.
|
||||
|
||||
<br>
|
||||
|
||||
#### Detail Filter
|
||||
|
||||

|
||||

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

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

|
||||
- **Detail Intensity**: 0.0 (no effect) - 1.0 (full effect).
|
||||
- **Detail Color**: The color of the detail.
|
||||
- **Detail Threshold** (`Masking` only): The minimum and maximum alpha values used for masking. The larger the gap
|
||||
between these values, the stronger the softness effect.
|
||||
- **Detail Tex**: The texture used for the transition filter.
|
||||
@@ -368,15 +389,11 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||
|
||||
<br>
|
||||
|
||||
#### Others
|
||||
#### Flip
|
||||
|
||||

|
||||

|
||||
|
||||
- **Sampling Scale**: The referencing scale during sampling.
|
||||
- Larger values are suitable for high-resolution textures.
|
||||
- **Allow To Modify Mesh Shape**: If enabled, the mesh shape can be modified.
|
||||
- **Custom Root**: Use the custom transform for some effects.
|
||||
- **Flip**:
|
||||
- **Flip**: Combine the following flags.
|
||||
- `Nothing`
|
||||
- `Horizontal`
|
||||
- `Vertical`
|
||||
@@ -384,6 +401,17 @@ The `UIEffect` component applies visual effects to UI elements, allowing various
|
||||
- `Shadow`: Flip with the shadow.
|
||||

|
||||
|
||||
<br>
|
||||
|
||||
#### Others
|
||||
|
||||

|
||||
|
||||
- **Sampling Scale**: The referencing scale during sampling.
|
||||
- Larger values are suitable for high-resolution textures.
|
||||
- **Allow To Modify Mesh Shape**: If enabled, the mesh shape can be modified.
|
||||
- **Custom Root**: Use the custom transform for some effects.
|
||||
|
||||
> [!TIP]
|
||||
> `Transition Filter`, `Gradation Filter`, and `Detail Filter` usually refer to their own `RectTransform` when applying effects.
|
||||
> For example, if the mesh shape exceeds the `RectTransform` boundaries, the effect may not be applied correctly.
|
||||
@@ -503,6 +531,18 @@ To use UIEffect with ShaderGraph, you need to import additional resources.
|
||||
|
||||
<br><br>
|
||||
|
||||
### Usage with Timeline
|
||||
|
||||

|
||||
|
||||
Timeline is a powerful animation tool that can control UIEffect using `ControlTrack` and UIEffect tracks.
|
||||
|
||||
- `Control Track`: One of the built-in tracks. When you assign a GameObject with `UIEffect`, `UIEffect` will be enabled during the clip duration.
|
||||
- `UIEffect Tracks`: Tracks for UIEffect. They control `float` or `Color` type properties.
|
||||
- Supports blending, extrapolation, and tween.
|
||||
|
||||
<br><br>
|
||||
|
||||
### Runtime/Editor Preset for UIEffect
|
||||
|
||||

|
||||
@@ -510,7 +550,7 @@ To use UIEffect with ShaderGraph, you need to import additional resources.
|
||||
You can create and use presets for `UIEffect` components.
|
||||
|
||||
- Click the `Load` button to apply an editor preset.
|
||||
> Click the `Append` button to load only non-default settings from the editor preset.
|
||||
- Click the `Append` button to load only non-default settings from the editor preset.
|
||||
- Click the `Save As New` button to save the current settings as an editor preset.
|
||||
- In the [Project Settings](#project-settings), you can register saved editor presets as runtime presets.
|
||||
- Runtime presets can be loaded using the `UIEffect.LoadPreset(presetName)` method.
|
||||
@@ -548,16 +588,23 @@ UIEffectProjectSettings.shaderVariantCollection.WarmUp();
|
||||
|
||||
### Project Settings
|
||||
|
||||

|
||||

|
||||
|
||||
You can adjust the project-wide settings for UIEffect. (`Edit > Project Settings > UI > UIEffect`)
|
||||
|
||||
#### Settings
|
||||
|
||||
- **Transform Sensitivity**: `Low`, `Medium`, `High`
|
||||
- Set the sensitivity of the transformation when `Use Target Transform` is enabled in `UIEffectReplica` component.
|
||||
- **Runtime Presets**: A list of presets that can be loaded at runtime. Load them using `UIEffect.LoadPreset(presetName)` method.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> - The legacy prefab-based preset system is deprecated as of v5.8.0.
|
||||
> - If your project contains legacy presets, you can convert them to the new system.
|
||||
> - **Convert All Legacy Presets**: Creates new presets based on the legacy ones.
|
||||
> If the legacy presets are used as runtime presets, they will be replaced with the new ones.
|
||||
> You can load the new preset via the `UIEffect.LoadPreset` method.
|
||||
> - **Delete All Legacy Presets**: Deletes all legacy presets. If any legacy presets are assigned to `UIEffectReplica.target`, those targets will also be removed.
|
||||
> 
|
||||
|
||||
#### Editor
|
||||
|
||||
- **Use HDR Color Picker**: If enabled, the HDR color picker will be used in the inspector.
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"name": "Coffee.UIEffect",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f"
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:f06555f75b070af458a003d92f9efb00"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
@@ -21,6 +22,16 @@
|
||||
"name": "com.unity.ugui",
|
||||
"expression": "2.0.0",
|
||||
"define": "TMP_ENABLE"
|
||||
},
|
||||
{
|
||||
"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
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace Coffee.UIEffects
|
||||
Mask = 5,
|
||||
Melt = 6,
|
||||
Burn = 7,
|
||||
Blaze = 9,
|
||||
Pattern = 8
|
||||
}
|
||||
|
||||
@@ -110,8 +111,14 @@ namespace Coffee.UIEffects
|
||||
HorizontalGradient = 2,
|
||||
Vertical = 3,
|
||||
VerticalGradient = 4,
|
||||
Radial = 5,
|
||||
|
||||
[Obsolete]
|
||||
RadialFast = 5,
|
||||
|
||||
[Obsolete]
|
||||
RadialDetail = 6,
|
||||
RadialGradient = 12,
|
||||
Diagonal = 11,
|
||||
DiagonalToRightBottom = 7,
|
||||
DiagonalToLeftBottom = 8,
|
||||
@@ -125,6 +132,7 @@ namespace Coffee.UIEffects
|
||||
Masking = 1,
|
||||
Multiply = 2,
|
||||
Additive = 3,
|
||||
Subtractive = 6,
|
||||
Replace = 4,
|
||||
MultiplyAdditive = 5
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -271,7 +303,8 @@ namespace Coffee.UIEffectInternal
|
||||
private readonly ReorderableList _rlOptionalShaders;
|
||||
private readonly ReorderableList _rlUnregisteredVariants;
|
||||
private Editor _editor;
|
||||
private bool _expand;
|
||||
private bool _expandOptionalShaders;
|
||||
private bool _expandUnregisteredVariants;
|
||||
|
||||
public ShaderVariantRegistryEditor(SerializedProperty property, string optionName, Action onFindOptions)
|
||||
{
|
||||
@@ -281,11 +314,11 @@ namespace Coffee.UIEffectInternal
|
||||
_errorOnUnregisteredVariant = property.FindPropertyRelative("m_ErrorOnUnregisteredVariant");
|
||||
_asset = property.FindPropertyRelative("m_Asset");
|
||||
|
||||
_rlOptionalShaders = new ReorderableList(so, optionalShaders, false, true, true, true);
|
||||
_rlOptionalShaders = new ReorderableList(so, optionalShaders, true, true, true, true);
|
||||
_rlOptionalShaders.drawHeaderCallback = rect =>
|
||||
{
|
||||
var rLabel = new Rect(rect.x, rect.y, rect.width - 80, rect.height);
|
||||
EditorGUI.LabelField(rLabel,
|
||||
_expandOptionalShaders = EditorGUI.Foldout(rLabel, _expandOptionalShaders,
|
||||
EditorGUIUtility.TrTextContent($"Optional Shaders {optionName}",
|
||||
"Specify optional shaders explicitly."));
|
||||
|
||||
@@ -319,7 +352,7 @@ namespace Coffee.UIEffectInternal
|
||||
}
|
||||
|
||||
var rArrow = new Rect(r.x, r.y + h + 4, 20, h);
|
||||
EditorGUI.LabelField(rArrow, "->");
|
||||
EditorGUI.LabelField(rArrow, GUIContent.none, "ArrowNavigationRight");
|
||||
|
||||
var rValue = new Rect(r.x + 20, r.y + h + 4, r.width - 20, h);
|
||||
if (GUI.Button(rValue, value.stringValue, EditorStyles.popup))
|
||||
@@ -376,8 +409,8 @@ namespace Coffee.UIEffectInternal
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
_rlOptionalShaders.DoLayoutList();
|
||||
_expand = DrawRegisteredShaderVariants(_expand, _asset, ref _editor);
|
||||
DrawOptionalShaders(ref _expandOptionalShaders, _rlOptionalShaders);
|
||||
DrawRegisteredShaderVariants(ref _expandUnregisteredVariants, _asset, ref _editor);
|
||||
if (0 < _rlUnregisteredVariants.serializedProperty.arraySize)
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
@@ -406,20 +439,40 @@ namespace Coffee.UIEffectInternal
|
||||
EditorUtility.SetDirty(collection);
|
||||
}
|
||||
|
||||
private static bool DrawRegisteredShaderVariants(bool expand, SerializedProperty property, ref Editor editor)
|
||||
private static void DrawOptionalShaders(ref bool expand, ReorderableList list)
|
||||
{
|
||||
if (expand)
|
||||
{
|
||||
list.DoLayoutList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var r = EditorGUILayout.GetControlRect(false, 20);
|
||||
var rBg = new Rect(r.x - 3, r.y, r.width + 6, r.height);
|
||||
EditorGUI.LabelField(rBg, GUIContent.none, "RL Header");
|
||||
|
||||
r.x += 3;
|
||||
r.width -= 3;
|
||||
r.y += 0;
|
||||
list.drawHeaderCallback.Invoke(r);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawRegisteredShaderVariants(ref bool expand, SerializedProperty property,
|
||||
ref Editor editor)
|
||||
{
|
||||
var collection = property.objectReferenceValue as ShaderVariantCollection;
|
||||
if (collection == null) return expand;
|
||||
if (collection == null) return;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
var r = EditorGUILayout.GetControlRect(false, 20);
|
||||
var rBg = new Rect(r.x - 3, r.y, r.width + 6, r.height);
|
||||
EditorGUI.LabelField(rBg, GUIContent.none, "RL Header");
|
||||
|
||||
var rLabel = new Rect(r.x + 5, r.y, 200, r.height);
|
||||
var rLabel = new Rect(r.x + 3, r.y, 200, r.height);
|
||||
expand = EditorGUI.Foldout(rLabel, expand, "Registered Shader Variants");
|
||||
|
||||
var rButton = new Rect(r.x + r.width - 82, r.y + 1, 80, r.height - 4);
|
||||
var rButton = new Rect(r.x + r.width - 62, r.y + 1, 60, r.height - 4);
|
||||
if (GUI.Button(rButton, "Clear All", EditorStyles.miniButton))
|
||||
{
|
||||
collection.Clear();
|
||||
@@ -440,8 +493,6 @@ namespace Coffee.UIEffectInternal
|
||||
EditorGUILayout.EndVertical();
|
||||
editor.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
return expand;
|
||||
}
|
||||
|
||||
private static void ShowShaderDropdown(SerializedProperty property)
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3278a8b3cb92d4cc69862f0d45f150ad
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 014b76346c11643a89303ed3b5681733
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIEffects.Timeline
|
||||
{
|
||||
[DisplayName("Clip")]
|
||||
public class UIEffectColorClip : UIEffectClip<UIEffectColorBehaviour>
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class UIEffectColorBehaviour : UIEffectBehaviour, IGetValue<Color>
|
||||
{
|
||||
[ColorUsage(true, true)]
|
||||
public Color m_Value = Color.white;
|
||||
|
||||
[ColorUsage(true, true)]
|
||||
public Color m_From = Color.white;
|
||||
|
||||
public Color Get(float time)
|
||||
{
|
||||
return m_Tween
|
||||
? Color.Lerp(m_From, m_Value, m_Curve.Evaluate(time))
|
||||
: m_Value;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class UIEffectColorMixerBehaviour : UIEffectMixerBehaviour<Color, UIEffectColorBehaviour>
|
||||
{
|
||||
protected override Color Add(Color baseValue, Color value, float weight)
|
||||
{
|
||||
return baseValue + value * weight;
|
||||
}
|
||||
|
||||
protected override Color Lerp(Color defaultValue, Color value, float weight)
|
||||
{
|
||||
return Color.Lerp(defaultValue, value, weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c402544dc0be48afa6e9d3eb88120be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIEffects.Timeline
|
||||
{
|
||||
[DisplayName("Clip")]
|
||||
public class UIEffectFloatClip : UIEffectClip<UIEffectFloatBehaviour>
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class UIEffectFloatBehaviour : UIEffectBehaviour, IGetValue<float>
|
||||
{
|
||||
public float m_Value = 1;
|
||||
|
||||
public float m_From = 1;
|
||||
|
||||
public float Get(float time)
|
||||
{
|
||||
return m_Tween
|
||||
? Mathf.Lerp(m_From, m_Value, m_Curve.Evaluate(time))
|
||||
: m_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
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffaa25511fc8148839e36bda4414e944
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,177 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects.Timeline
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class FloatClipUsageAttribute : PropertyAttribute
|
||||
{
|
||||
public readonly float min;
|
||||
public readonly float max;
|
||||
public readonly float defaultValue;
|
||||
|
||||
public FloatClipUsageAttribute(float min, float max, float defaultValue = 0f)
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class ColorClipUsageAttribute : PropertyAttribute
|
||||
{
|
||||
public readonly bool alpha;
|
||||
|
||||
public ColorClipUsageAttribute(bool alpha)
|
||||
{
|
||||
this.alpha = alpha;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IGetValue<out T>
|
||||
{
|
||||
T Get(float time);
|
||||
}
|
||||
|
||||
[TrackColor(0.92f, 0.54f, 0.17f)]
|
||||
[TrackBindingType(typeof(UIEffect), TrackBindingFlags.AllowCreateComponent)]
|
||||
public abstract class UIEffectTrack<T> : TrackAsset
|
||||
where T : PlayableBehaviour, new()
|
||||
{
|
||||
protected abstract string fieldName { get; }
|
||||
|
||||
public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
|
||||
{
|
||||
var playable = ScriptPlayable<T>.Create(graph, inputCount);
|
||||
|
||||
foreach (var timelineClip in GetClips())
|
||||
{
|
||||
if (timelineClip.asset is UIEffectClip clip)
|
||||
{
|
||||
clip.timelineClip = timelineClip;
|
||||
}
|
||||
}
|
||||
|
||||
return playable;
|
||||
}
|
||||
|
||||
public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
|
||||
{
|
||||
var trackBinding = director.GetGenericBinding(this) as UIEffect;
|
||||
if (!trackBinding) return;
|
||||
|
||||
driver.AddFromName<UIEffect>(trackBinding.gameObject, fieldName);
|
||||
base.GatherProperties(director, driver);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class UIEffectClip : PlayableAsset, ITimelineClipAsset
|
||||
{
|
||||
public TimelineClip timelineClip { get; set; }
|
||||
public ClipCaps clipCaps => ClipCaps.Blending | ClipCaps.Extrapolation;
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class UIEffectClip<T> : UIEffectClip
|
||||
where T : UIEffectBehaviour, new()
|
||||
{
|
||||
[NotKeyable]
|
||||
[SerializeField]
|
||||
public T m_Data = new T();
|
||||
|
||||
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
|
||||
{
|
||||
var playable = ScriptPlayable<T>.Create(graph, m_Data);
|
||||
var behaviour = playable.GetBehaviour();
|
||||
behaviour.clip = this;
|
||||
return playable;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public abstract class UIEffectBehaviour : PlayableBehaviour
|
||||
{
|
||||
public bool m_Tween;
|
||||
public AnimationCurve m_Curve = AnimationCurve.Linear(0, 0, 1, 1);
|
||||
public UIEffectClip clip { get; set; }
|
||||
}
|
||||
|
||||
public abstract class UIEffectMixerBehaviour<T, TBehavior> : PlayableBehaviour
|
||||
where TBehavior : UIEffectBehaviour, IGetValue<T>, new()
|
||||
{
|
||||
private T _defaultValue;
|
||||
protected abstract T currentValue { get; set; }
|
||||
protected UIEffect effect { get; private set; }
|
||||
|
||||
public override void ProcessFrame(Playable playable, FrameData info, object playerData)
|
||||
{
|
||||
InitializeIfNeeded(playerData as UIEffect);
|
||||
if (!effect) return;
|
||||
|
||||
var inputCount = playable.GetInputCount();
|
||||
var value = default(T);
|
||||
var totalWeight = GetTotalWeight(playable);
|
||||
|
||||
for (var i = 0; i < inputCount; i++)
|
||||
{
|
||||
var weight = playable.GetInputWeight(i);
|
||||
if (weight <= 0) continue;
|
||||
|
||||
var playableInput = (ScriptPlayable<TBehavior>)playable.GetInput(i);
|
||||
var input = playableInput.GetBehaviour();
|
||||
var normalizedTime = (float)(playableInput.GetTime() / input.clip.timelineClip.duration);
|
||||
|
||||
value = Add(value, input.Get(normalizedTime), weight / totalWeight);
|
||||
totalWeight += weight;
|
||||
}
|
||||
|
||||
currentValue = Lerp(_defaultValue, value, totalWeight);
|
||||
}
|
||||
|
||||
public override void OnPlayableDestroy(Playable playable)
|
||||
{
|
||||
if (effect)
|
||||
{
|
||||
currentValue = _defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetTotalWeight(Playable playable)
|
||||
{
|
||||
var totalWeight = 0f;
|
||||
var inputCount = playable.GetInputCount();
|
||||
for (var i = 0; i < inputCount; i++)
|
||||
{
|
||||
totalWeight += playable.GetInputWeight(i);
|
||||
}
|
||||
|
||||
return totalWeight;
|
||||
}
|
||||
|
||||
private void InitializeIfNeeded(UIEffect newEffect)
|
||||
{
|
||||
if (effect == newEffect) return;
|
||||
|
||||
if (effect)
|
||||
{
|
||||
currentValue = _defaultValue;
|
||||
}
|
||||
|
||||
effect = newEffect;
|
||||
_defaultValue = newEffect ? currentValue : default;
|
||||
}
|
||||
|
||||
protected abstract T Add(T current, T value, float weight);
|
||||
|
||||
protected abstract T Lerp(T defaultValue, T value, float weight);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a54d6ecf5bae485db4b0df376bebc35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[FloatClipUsage(0f, 1f)]
|
||||
[TrackClipType(typeof(UIEffectFloatClip))]
|
||||
[DisplayName("UIEffect Tracks/Color Intensity Track")]
|
||||
public class ColorIntensityTrack : UIEffectTrack<ColorIntensityMixer>
|
||||
{
|
||||
protected override string fieldName => "m_ColorIntensity";
|
||||
}
|
||||
|
||||
public class ColorIntensityMixer : UIEffectFloatMixerBehaviour
|
||||
{
|
||||
protected override float currentValue
|
||||
{
|
||||
get => effect.colorIntensity;
|
||||
set => effect.colorIntensity = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66d61d709d31c4220bc59365f78584ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[ColorClipUsage(false)]
|
||||
[TrackClipType(typeof(UIEffectColorClip))]
|
||||
[DisplayName("UIEffect Tracks/Color Track")]
|
||||
public class ColorTrack : UIEffectTrack<ColorMixer>
|
||||
{
|
||||
protected override string fieldName => "m_Color";
|
||||
}
|
||||
|
||||
public class ColorMixer : UIEffectColorMixerBehaviour
|
||||
{
|
||||
protected override Color currentValue
|
||||
{
|
||||
get => effect.color;
|
||||
set => effect.color = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edfa6dc975b3446d8bc2cf6ca1fdd40f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[ColorClipUsage(true)]
|
||||
[TrackClipType(typeof(UIEffectColorClip))]
|
||||
[DisplayName("UIEffect Tracks/Detail Color Track")]
|
||||
public class DetailColorTrack : UIEffectTrack<DetailColorMixer>
|
||||
{
|
||||
protected override string fieldName => "m_DetailColor";
|
||||
}
|
||||
|
||||
public class DetailColorMixer : UIEffectColorMixerBehaviour
|
||||
{
|
||||
protected override Color currentValue
|
||||
{
|
||||
get => effect.detailColor;
|
||||
set => effect.detailColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88051c9178d704e47a12db836b6343c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[FloatClipUsage(0f, 1f)]
|
||||
[TrackClipType(typeof(UIEffectFloatClip))]
|
||||
[DisplayName("UIEffect Tracks/Detail Intensity Track")]
|
||||
public class DetailIntensityTrack : UIEffectTrack<DetailIntensityMixer>
|
||||
{
|
||||
protected override string fieldName => "m_DetailIntensity";
|
||||
}
|
||||
|
||||
public class DetailIntensityMixer : UIEffectFloatMixerBehaviour
|
||||
{
|
||||
protected override float currentValue
|
||||
{
|
||||
get => effect.detailIntensity;
|
||||
set => effect.detailIntensity = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e901a5dfc37104d2182dcc49fe370305
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[ColorClipUsage(true)]
|
||||
[TrackClipType(typeof(UIEffectColorClip))]
|
||||
[DisplayName("UIEffect Tracks/Detail Color Track")]
|
||||
public class EdgeColorTrack : UIEffectTrack<EdgeColorMixer>
|
||||
{
|
||||
protected override string fieldName => "m_EdgeColor";
|
||||
}
|
||||
|
||||
public class EdgeColorMixer : UIEffectColorMixerBehaviour
|
||||
{
|
||||
protected override Color currentValue
|
||||
{
|
||||
get => effect.edgeColor;
|
||||
set => effect.edgeColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f78a05c2255e94329a1b7bd465ac8f8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[FloatClipUsage(0f, 1f)]
|
||||
[TrackClipType(typeof(UIEffectFloatClip))]
|
||||
[DisplayName("UIEffect Tracks/Edge Shiny Rate Track")]
|
||||
public class EdgeShinyRateTrack : UIEffectTrack<EdgeShinyRateMixer>
|
||||
{
|
||||
protected override string fieldName => "m_EdgeShinyRate";
|
||||
}
|
||||
|
||||
public class EdgeShinyRateMixer : UIEffectFloatMixerBehaviour
|
||||
{
|
||||
protected override float currentValue
|
||||
{
|
||||
get => effect.edgeShinyRate;
|
||||
set => effect.edgeShinyRate = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 118c294bc3dfa4e7a96de50b410ad846
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[FloatClipUsage(0f, 1f)]
|
||||
[TrackClipType(typeof(UIEffectFloatClip))]
|
||||
[DisplayName("UIEffect Tracks/Gradation Intensity Track")]
|
||||
public class GradationIntensityTrack : UIEffectTrack<GradationIntensityMixer>
|
||||
{
|
||||
protected override string fieldName => "m_GradationIntensity";
|
||||
}
|
||||
|
||||
public class GradationIntensityMixer : UIEffectFloatMixerBehaviour
|
||||
{
|
||||
protected override float currentValue
|
||||
{
|
||||
get => effect.gradationIntensity;
|
||||
set => effect.gradationIntensity = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b4c7c51d8c8c4d9ebfacb4ec8e7f73e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[TrackClipType(typeof(UIEffectFloatClip))]
|
||||
[DisplayName("UIEffect Tracks/Gradation Offset Track")]
|
||||
public class GradationOffsetTrack : UIEffectTrack<GradationOffsetMixer>
|
||||
{
|
||||
protected override string fieldName => "m_GradationOffset";
|
||||
}
|
||||
|
||||
public class GradationOffsetMixer : UIEffectFloatMixerBehaviour
|
||||
{
|
||||
protected override float currentValue
|
||||
{
|
||||
get => effect.gradationOffset;
|
||||
set => effect.gradationOffset = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: deb67c01293914e41a70a7570c3a539e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[TrackClipType(typeof(UIEffectFloatClip))]
|
||||
[DisplayName("UIEffect Tracks/Gradation Rotation Track")]
|
||||
public class GradationRotationTrack : UIEffectTrack<GradationRotationMixer>
|
||||
{
|
||||
protected override string fieldName => "m_GradationRotation";
|
||||
}
|
||||
|
||||
public class GradationRotationMixer : UIEffectFloatMixerBehaviour
|
||||
{
|
||||
protected override float currentValue
|
||||
{
|
||||
get => effect.gradationRotation;
|
||||
set => effect.gradationRotation = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb2c49df5c5af40d189179c70f3f4e8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[FloatClipUsage(0.01f, 10f)]
|
||||
[TrackClipType(typeof(UIEffectFloatClip))]
|
||||
[DisplayName("UIEffect Tracks/Gradation Scale Track")]
|
||||
public class GradationScaleTrack : UIEffectTrack<GradationScaleMixer>
|
||||
{
|
||||
protected override string fieldName => "m_GradationScale";
|
||||
}
|
||||
|
||||
public class GradationScaleMixer : UIEffectFloatMixerBehaviour
|
||||
{
|
||||
protected override float currentValue
|
||||
{
|
||||
get => effect.gradationScale;
|
||||
set => effect.gradationScale = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e9a4fc9655b64a399feaf134500daad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[FloatClipUsage(0f, 1f)]
|
||||
[TrackClipType(typeof(UIEffectFloatClip))]
|
||||
[DisplayName("UIEffect Tracks/Sampling Intensity Track")]
|
||||
public class SamplingIntensityTrack : UIEffectTrack<SamplingIntensityMixer>
|
||||
{
|
||||
protected override string fieldName => "m_SamplingIntensity";
|
||||
}
|
||||
|
||||
public class SamplingIntensityMixer : UIEffectFloatMixerBehaviour
|
||||
{
|
||||
protected override float currentValue
|
||||
{
|
||||
get => effect.samplingIntensity;
|
||||
set => effect.samplingIntensity = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae43eda84464f470db063babd75d86ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[FloatClipUsage(0f, 1f)]
|
||||
[TrackClipType(typeof(UIEffectFloatClip))]
|
||||
[DisplayName("UIEffect Tracks/Tone Intensity Track")]
|
||||
public class ToneIntensityTrack : UIEffectTrack<ToneIntensityMixer>
|
||||
{
|
||||
protected override string fieldName => "m_ToneIntensity";
|
||||
}
|
||||
|
||||
public class ToneIntensityMixer : UIEffectFloatMixerBehaviour
|
||||
{
|
||||
protected override float currentValue
|
||||
{
|
||||
get => effect.toneIntensity;
|
||||
set => effect.toneIntensity = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c08d90226dd3d48c7b26e4148a627c30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[ColorClipUsage(true)]
|
||||
[TrackClipType(typeof(UIEffectColorClip))]
|
||||
[DisplayName("UIEffect Tracks/Transition Color Track")]
|
||||
public class TransitionColorTrack : UIEffectTrack<TransitionColorMixer>
|
||||
{
|
||||
protected override string fieldName => "m_TransitionColor";
|
||||
}
|
||||
|
||||
public class TransitionColorMixer : UIEffectColorMixerBehaviour
|
||||
{
|
||||
protected override Color currentValue
|
||||
{
|
||||
get => effect.transitionColor;
|
||||
set => effect.transitionColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cbbddc14d5744997a755e56c474a436
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
#if TIMELINE_ENABLE
|
||||
using System.ComponentModel;
|
||||
using UnityEngine.Timeline;
|
||||
using Coffee.UIEffects.Timeline;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[FloatClipUsage(0f, 1f)]
|
||||
[TrackClipType(typeof(UIEffectFloatClip))]
|
||||
[DisplayName("UIEffect Tracks/Transition Rate Track")]
|
||||
public class TransitionRateTrack : UIEffectTrack<TransitionRateMixer>
|
||||
{
|
||||
protected override string fieldName => "m_TransitionRate";
|
||||
}
|
||||
|
||||
public class TransitionRateMixer : UIEffectFloatMixerBehaviour
|
||||
{
|
||||
protected override float currentValue
|
||||
{
|
||||
get => effect.transitionRate;
|
||||
set => effect.transitionRate = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97f54e7d118464cd099026c08294dc29
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+643
-370
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,9 @@ using UnityEngine.EventSystems;
|
||||
using UnityEngine.Profiling;
|
||||
using UnityEngine.UI;
|
||||
using UnityEditor;
|
||||
#if TIMELINE_ENABLE
|
||||
using UnityEngine.Timeline;
|
||||
#endif
|
||||
|
||||
[assembly: InternalsVisibleTo("UIEffect")]
|
||||
[assembly: InternalsVisibleTo("Coffee.UIEffect.Editor")]
|
||||
@@ -15,6 +18,9 @@ namespace Coffee.UIEffects
|
||||
[ExecuteAlways]
|
||||
[DisallowMultipleComponent]
|
||||
public abstract class UIEffectBase : UIBehaviour, IMeshModifier, IMaterialModifier, ICanvasRaycastFilter
|
||||
#if TIMELINE_ENABLE
|
||||
, ITimeControl
|
||||
#endif
|
||||
{
|
||||
private static readonly InternalObjectPool<UIEffectContext> s_ContextPool =
|
||||
new InternalObjectPool<UIEffectContext>(() => new UIEffectContext(), x => true, x => x.Reset());
|
||||
@@ -26,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>();
|
||||
@@ -33,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
|
||||
@@ -62,14 +87,9 @@ namespace Coffee.UIEffects
|
||||
|
||||
public virtual RectTransform transitionRoot => transform as RectTransform;
|
||||
|
||||
public virtual Flip flip
|
||||
{
|
||||
get => 0;
|
||||
set { }
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
_canModifyMesh = true;
|
||||
_onBeforeCanvasRebuild ??= OnBeforeCanvasRebuild;
|
||||
_onAfterCanvasRebuild ??= OnAfterCanvasRebuild;
|
||||
UIExtraCallbacks.onBeforeCanvasRebuild += _onBeforeCanvasRebuild;
|
||||
@@ -103,19 +123,28 @@ 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())
|
||||
{
|
||||
_canModifyMesh = true;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnAfterCanvasRebuild()
|
||||
private void OnAfterCanvasRebuild()
|
||||
{
|
||||
if (!_material || !graphic || context == null) return;
|
||||
if (!_material || !graphic || !canvas || context == null) return;
|
||||
if (!context.useViewMatrix) return;
|
||||
|
||||
context.UpdateViewMatrix(GetCurrentMaterial(), transitionRoot, graphic.canvas.rootCanvas, flip);
|
||||
context.UpdateViewMatrix(GetCurrentMaterial(), transitionRoot, canvas.rootCanvas);
|
||||
}
|
||||
|
||||
protected override void OnCanvasHierarchyChanged()
|
||||
{
|
||||
_canvasCached = false;
|
||||
_canvas = null;
|
||||
}
|
||||
|
||||
public void ModifyMesh(Mesh mesh)
|
||||
@@ -129,12 +158,15 @@ namespace Coffee.UIEffects
|
||||
_canModifyMesh = CanModifyMesh();
|
||||
if (_canModifyMesh)
|
||||
{
|
||||
context.ModifyMesh(graphic, transitionRoot, vh, canModifyShape, flip);
|
||||
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;
|
||||
if (transform == root) return true;
|
||||
@@ -255,5 +287,25 @@ namespace Coffee.UIEffects
|
||||
|
||||
public abstract void SetRate(float rate, UIEffectTweener.CullingMask cullingMask);
|
||||
public abstract bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera);
|
||||
|
||||
public void SetTime(double _)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnControlTimeStart()
|
||||
{
|
||||
if (this)
|
||||
{
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnControlTimeStop()
|
||||
{
|
||||
if (this)
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,13 @@ 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);
|
||||
private static readonly int s_SrcBlend = Shader.PropertyToID("_SrcBlend");
|
||||
private static readonly int s_DstBlend = Shader.PropertyToID("_DstBlend");
|
||||
private static readonly int s_ToneIntensity = Shader.PropertyToID("_ToneIntensity");
|
||||
private static readonly int s_ToneParams = Shader.PropertyToID("_ToneParams");
|
||||
private static readonly int s_ColorFilter = Shader.PropertyToID("_ColorFilter");
|
||||
private static readonly int s_ColorValue = Shader.PropertyToID("_ColorValue");
|
||||
private static readonly int s_ColorIntensity = Shader.PropertyToID("_ColorIntensity");
|
||||
@@ -36,6 +35,7 @@ namespace Coffee.UIEffects
|
||||
private static readonly int s_TransitionColorGlow = Shader.PropertyToID("_TransitionColorGlow");
|
||||
private static readonly int s_TransitionPatternReverse = Shader.PropertyToID("_TransitionPatternReverse");
|
||||
private static readonly int s_TransitionAutoPlaySpeed = Shader.PropertyToID("_TransitionAutoPlaySpeed");
|
||||
private static readonly int s_TransitionGradientTex = Shader.PropertyToID("_TransitionGradientTex");
|
||||
private static readonly int s_TargetColor = Shader.PropertyToID("_TargetColor");
|
||||
private static readonly int s_TargetRange = Shader.PropertyToID("_TargetRange");
|
||||
private static readonly int s_TargetSoftness = Shader.PropertyToID("_TargetSoftness");
|
||||
@@ -53,6 +53,7 @@ namespace Coffee.UIEffects
|
||||
private static readonly int s_PatternArea = Shader.PropertyToID("_PatternArea");
|
||||
private static readonly int s_DetailIntensity = Shader.PropertyToID("_DetailIntensity");
|
||||
private static readonly int s_DetailThreshold = Shader.PropertyToID("_DetailThreshold");
|
||||
private static readonly int s_DetailColor = Shader.PropertyToID("_DetailColor");
|
||||
private static readonly int s_DetailTex = Shader.PropertyToID("_DetailTex");
|
||||
private static readonly int s_DetailTex_ST = Shader.PropertyToID("_DetailTex_ST");
|
||||
private static readonly int s_DetailTex_Speed = Shader.PropertyToID("_DetailTex_Speed");
|
||||
@@ -64,8 +65,11 @@ namespace Coffee.UIEffects
|
||||
private static readonly int s_GradationColor4 = Shader.PropertyToID("_GradationColor4");
|
||||
private static readonly int s_GradationTex = Shader.PropertyToID("_GradationTex");
|
||||
private static readonly int s_GradationTex_ST = Shader.PropertyToID("_GradationTex_ST");
|
||||
private static readonly int s_GradationRadial = Shader.PropertyToID("_GradationRadial");
|
||||
private static readonly int s_RootViewMatrix = Shader.PropertyToID("_RootViewMatrix");
|
||||
private static readonly int s_GradViewMatrix = Shader.PropertyToID("_GradViewMatrix");
|
||||
private static readonly int s_MirrorRootViewMatrix = Shader.PropertyToID("_MirrorRootViewMatrix");
|
||||
private static readonly int s_MirrorGradViewMatrix = Shader.PropertyToID("_MirrorGradViewMatrix");
|
||||
private static readonly int s_CanvasToWorldMatrix = Shader.PropertyToID("_CanvasToWorldMatrix");
|
||||
|
||||
private static readonly string[] s_ToneKeywords =
|
||||
@@ -106,7 +110,8 @@ namespace Coffee.UIEffects
|
||||
"TRANSITION_MASK",
|
||||
"TRANSITION_MELT",
|
||||
"TRANSITION_BURN",
|
||||
"TRANSITION_PATTERN"
|
||||
"TRANSITION_PATTERN",
|
||||
"TRANSITION_BLAZE"
|
||||
};
|
||||
|
||||
private static readonly string[] s_TargetKeywords =
|
||||
@@ -130,14 +135,14 @@ namespace Coffee.UIEffects
|
||||
"DETAIL_MULTIPLY",
|
||||
"DETAIL_ADDITIVE",
|
||||
"DETAIL_REPLACE",
|
||||
"DETAIL_MULTIPLY_ADDITIVE"
|
||||
"DETAIL_MULTIPLY_ADDITIVE",
|
||||
"DETAIL_SUBTRACTIVE"
|
||||
};
|
||||
|
||||
private static readonly string[] s_GradationKeywords =
|
||||
{
|
||||
"",
|
||||
"GRADATION_GRADIENT",
|
||||
"GRADATION_RADIAL",
|
||||
"GRADATION_COLOR2",
|
||||
"GRADATION_COLOR4"
|
||||
};
|
||||
@@ -156,285 +161,392 @@ namespace Coffee.UIEffects
|
||||
};
|
||||
|
||||
public static Func<UIVertex, Rect, UIVertex> onModifyVertex;
|
||||
public ToneFilter toneFilter = ToneFilter.None;
|
||||
public float toneIntensity = 1;
|
||||
public Vector4 toneParams = new Vector4(0, 0, 0, 0);
|
||||
public ToneFilter m_ToneFilter;
|
||||
public float m_ToneIntensity;
|
||||
|
||||
public ColorFilter colorFilter = ColorFilter.None;
|
||||
public float colorIntensity = 1;
|
||||
public Color color = Color.white;
|
||||
public bool colorGlow;
|
||||
public ColorFilter m_ColorFilter;
|
||||
public float m_ColorIntensity;
|
||||
public Color m_Color;
|
||||
public bool m_ColorGlow;
|
||||
|
||||
public SamplingFilter samplingFilter = SamplingFilter.None;
|
||||
public float samplingIntensity = 0.5f;
|
||||
public float samplingWidth;
|
||||
public SamplingFilter m_SamplingFilter;
|
||||
public float m_SamplingIntensity;
|
||||
public float m_SamplingWidth;
|
||||
|
||||
public TransitionFilter transitionFilter = TransitionFilter.None;
|
||||
public float transitionRate = 0.5f;
|
||||
public bool transitionReverse;
|
||||
public Texture transitionTex;
|
||||
public Vector2 transitionTexScale = new Vector2(1, 1);
|
||||
public Vector2 transitionTexOffset = new Vector2(0, 0);
|
||||
public Vector2 transitionTexSpeed = new Vector2(0, 0);
|
||||
public float transitionRotation = 0;
|
||||
public bool transitionKeepAspectRatio = true;
|
||||
public float transitionWidth = 0.2f;
|
||||
public float transitionSoftness = 0.2f;
|
||||
public MinMax01 transitionRange = new MinMax01(0, 1);
|
||||
public ColorFilter transitionColorFilter = ColorFilter.MultiplyAdditive;
|
||||
public Color transitionColor = new Color(0f, 0.5f, 1.0f, 1.0f);
|
||||
public bool transitionColorGlow;
|
||||
public bool transitionPatternReverse;
|
||||
public float transitionAutoPlaySpeed;
|
||||
public TransitionFilter m_TransitionFilter;
|
||||
public float m_TransitionRate;
|
||||
public bool m_TransitionReverse;
|
||||
public Texture m_TransitionTex;
|
||||
public Vector2 m_TransitionTexScale;
|
||||
public Vector2 m_TransitionTexOffset;
|
||||
public Vector2 m_TransitionTexSpeed;
|
||||
public float m_TransitionRotation;
|
||||
public bool m_TransitionKeepAspectRatio;
|
||||
public float m_TransitionWidth;
|
||||
public float m_TransitionSoftness;
|
||||
public MinMax01 m_TransitionRange;
|
||||
public ColorFilter m_TransitionColorFilter;
|
||||
public Color m_TransitionColor;
|
||||
public bool m_TransitionColorGlow;
|
||||
public bool m_TransitionPatternReverse;
|
||||
public float m_TransitionAutoPlaySpeed;
|
||||
public Gradient m_TransitionGradient;
|
||||
|
||||
public TargetMode targetMode = TargetMode.None;
|
||||
public Color targetColor = Color.white;
|
||||
public float targetRange = 1;
|
||||
public float targetSoftness = 0.5f;
|
||||
public TargetMode m_TargetMode;
|
||||
public Color m_TargetColor;
|
||||
public float m_TargetRange;
|
||||
public float m_TargetSoftness;
|
||||
|
||||
public BlendMode srcBlendMode = BlendMode.One;
|
||||
public BlendMode dstBlendMode = BlendMode.OneMinusSrcAlpha;
|
||||
public BlendMode m_SrcBlendMode;
|
||||
public BlendMode m_DstBlendMode;
|
||||
|
||||
public ShadowMode shadowMode = ShadowMode.None;
|
||||
public Vector2 shadowDistance = new Vector2(1f, -1f);
|
||||
public int shadowIteration = 1;
|
||||
public float shadowFade = 0.9f;
|
||||
public float shadowMirrorScale = 0.5f;
|
||||
public float shadowBlurIntensity;
|
||||
public ColorFilter shadowColorFilter;
|
||||
public Color shadowColor;
|
||||
public bool shadowColorGlow;
|
||||
public ShadowMode m_ShadowMode;
|
||||
public Vector2 m_ShadowDistance;
|
||||
public int m_ShadowIteration;
|
||||
public float m_ShadowFade;
|
||||
public float m_ShadowMirrorScale;
|
||||
public float m_ShadowBlurIntensity;
|
||||
public ColorFilter m_ShadowColorFilter;
|
||||
public Color m_ShadowColor;
|
||||
public bool m_ShadowColorGlow;
|
||||
|
||||
public EdgeMode edgeMode;
|
||||
public float edgeShinyRate;
|
||||
public float edgeWidth;
|
||||
public ColorFilter edgeColorFilter;
|
||||
public Color edgeColor;
|
||||
public bool edgeColorGlow;
|
||||
public float edgeShinyWidth;
|
||||
public float edgeShinyAutoPlaySpeed;
|
||||
public PatternArea patternArea;
|
||||
public EdgeMode m_EdgeMode;
|
||||
public float m_EdgeShinyRate;
|
||||
public float m_EdgeWidth;
|
||||
public ColorFilter m_EdgeColorFilter;
|
||||
public Color m_EdgeColor;
|
||||
public bool m_EdgeColorGlow;
|
||||
public float m_EdgeShinyWidth;
|
||||
public float m_EdgeShinyAutoPlaySpeed;
|
||||
public PatternArea m_PatternArea;
|
||||
|
||||
public GradationMode gradationMode;
|
||||
public float gradationIntensity;
|
||||
public GradationColorFilter gradationColorFilter;
|
||||
public Color gradationColor1;
|
||||
public Color gradationColor2;
|
||||
public Color gradationColor3;
|
||||
public Color gradationColor4;
|
||||
public Texture2D gradationTex;
|
||||
public float gradationOffset;
|
||||
public float gradationScale;
|
||||
public float gradationRotation;
|
||||
private List<float> _keyTimes;
|
||||
public GradationMode m_GradationMode;
|
||||
public float m_GradationIntensity;
|
||||
public GradationColorFilter m_GradationColorFilter;
|
||||
public Color m_GradationColor1;
|
||||
public Color m_GradationColor2;
|
||||
public Color m_GradationColor3;
|
||||
public Color m_GradationColor4;
|
||||
public Gradient m_GradationGradient;
|
||||
public float m_GradationOffset;
|
||||
public float m_GradationScale;
|
||||
public float m_GradationRotation;
|
||||
public TextureWrapMode m_GradationWrapMode;
|
||||
public bool m_GradationReverse;
|
||||
|
||||
public DetailFilter detailFilter;
|
||||
public float detailIntensity;
|
||||
public MinMax01 detailThreshold;
|
||||
public Texture detailTex;
|
||||
public Vector2 detailTexScale = new Vector2(1, 1);
|
||||
public Vector2 detailTexOffset = new Vector2(0, 0);
|
||||
public Vector2 detailTexSpeed = new Vector2(0, 0);
|
||||
public DetailFilter m_DetailFilter;
|
||||
public float m_DetailIntensity;
|
||||
public MinMax01 m_DetailThreshold;
|
||||
public Color m_DetailColor;
|
||||
public Texture m_DetailTex;
|
||||
public Vector2 m_DetailTexScale;
|
||||
public Vector2 m_DetailTexOffset;
|
||||
public Vector2 m_DetailTexSpeed;
|
||||
|
||||
public bool willModifyMaterial => toneFilter != ToneFilter.None
|
||||
|| colorFilter != ColorFilter.None
|
||||
|| samplingFilter != SamplingFilter.None
|
||||
|| transitionFilter != TransitionFilter.None
|
||||
|| srcBlendMode != BlendMode.One
|
||||
|| dstBlendMode != BlendMode.OneMinusSrcAlpha
|
||||
|| shadowMode != ShadowMode.None
|
||||
|| edgeMode != EdgeMode.None
|
||||
|| detailFilter != DetailFilter.None
|
||||
|| gradationMode != GradationMode.None;
|
||||
public Flip m_Flip;
|
||||
|
||||
public bool willModifyMaterial => m_ToneFilter != ToneFilter.None
|
||||
|| m_ColorFilter != ColorFilter.None
|
||||
|| m_SamplingFilter != SamplingFilter.None
|
||||
|| m_TransitionFilter != TransitionFilter.None
|
||||
|| m_SrcBlendMode != BlendMode.One
|
||||
|| m_DstBlendMode != BlendMode.OneMinusSrcAlpha
|
||||
|| m_ShadowMode != ShadowMode.None
|
||||
|| m_EdgeMode != EdgeMode.None
|
||||
|| m_DetailFilter != DetailFilter.None
|
||||
|| m_GradationMode != GradationMode.None;
|
||||
|
||||
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;
|
||||
private bool _isTransitionGradientDirty = true;
|
||||
private static readonly Color[] s_Colors = new Color[256];
|
||||
|
||||
private static readonly InternalObjectPool<Texture2D> s_TexturePool = new InternalObjectPool<Texture2D>(
|
||||
() =>
|
||||
{
|
||||
var texture = new Texture2D(s_Colors.Length, 1, TextureFormat.RGBAFloat, false, false)
|
||||
{
|
||||
name = "GradationRamp",
|
||||
hideFlags = HideFlags.DontSave,
|
||||
wrapMode = TextureWrapMode.Repeat,
|
||||
anisoLevel = 0
|
||||
};
|
||||
|
||||
return texture;
|
||||
},
|
||||
texture => texture,
|
||||
_ => { });
|
||||
|
||||
private Texture2D gradationRampTex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_GradationGradient == null) return null;
|
||||
if (!_gradationRampTex) _gradationRampTex = s_TexturePool.Rent();
|
||||
if (!_isGradientDirty) return _gradationRampTex;
|
||||
_isGradientDirty = false;
|
||||
|
||||
var w = s_Colors.Length;
|
||||
for (var i = 0; i < w; i++)
|
||||
{
|
||||
var x = m_GradationReverse ? w - 1 - i : i;
|
||||
var t = (float)i / (w - 1);
|
||||
s_Colors[x] = ApplyColorSpace(m_GradationGradient.Evaluate(t));
|
||||
}
|
||||
|
||||
_gradationRampTex.wrapMode = m_GradationWrapMode;
|
||||
_gradationRampTex.filterMode = m_GradationGradient.mode == GradientMode.Blend
|
||||
? FilterMode.Bilinear
|
||||
: FilterMode.Point;
|
||||
_gradationRampTex.SetPixels(s_Colors);
|
||||
_gradationRampTex.Apply();
|
||||
return _gradationRampTex;
|
||||
}
|
||||
}
|
||||
|
||||
private Texture2D transitionRampTex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_TransitionGradient == null) return null;
|
||||
if (!_transitionRampTex) _transitionRampTex = s_TexturePool.Rent();
|
||||
if (!_isTransitionGradientDirty) return _transitionRampTex;
|
||||
_isTransitionGradientDirty = false;
|
||||
|
||||
var w = s_Colors.Length;
|
||||
for (var i = 0; i < w; i++)
|
||||
{
|
||||
var t = (float)i / (w - 1);
|
||||
s_Colors[i] = ApplyColorSpace(m_TransitionGradient.Evaluate(t));
|
||||
}
|
||||
|
||||
s_Colors[w - 1].a = 0;
|
||||
|
||||
_transitionRampTex.wrapMode = TextureWrapMode.Clamp;
|
||||
_transitionRampTex.filterMode = m_TransitionGradient.mode == GradientMode.Blend
|
||||
? FilterMode.Bilinear
|
||||
: FilterMode.Point;
|
||||
_transitionRampTex.SetPixels(s_Colors);
|
||||
_transitionRampTex.Apply();
|
||||
return _transitionRampTex;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
InternalListPool<float>.Return(ref _keyTimes);
|
||||
_isGradientDirty = true;
|
||||
_isTransitionGradientDirty = true;
|
||||
s_TexturePool.Return(ref _gradationRampTex);
|
||||
s_TexturePool.Return(ref _transitionRampTex);
|
||||
CopyFrom(s_DefaultContext);
|
||||
}
|
||||
|
||||
private void CopyFrom(UIEffectContext preset)
|
||||
private void CopyFrom(UIEffectContext src)
|
||||
{
|
||||
toneFilter = preset.toneFilter;
|
||||
toneIntensity = preset.toneIntensity;
|
||||
toneParams = preset.toneParams;
|
||||
var dst = this;
|
||||
dst.m_ToneFilter = src.m_ToneFilter;
|
||||
dst.m_ToneIntensity = src.m_ToneIntensity;
|
||||
|
||||
colorFilter = preset.colorFilter;
|
||||
color = preset.color;
|
||||
colorIntensity = preset.colorIntensity;
|
||||
colorGlow = preset.colorGlow;
|
||||
dst.m_ColorFilter = src.m_ColorFilter;
|
||||
dst.m_Color = src.m_Color;
|
||||
dst.m_ColorIntensity = src.m_ColorIntensity;
|
||||
dst.m_ColorGlow = src.m_ColorGlow;
|
||||
|
||||
samplingFilter = preset.samplingFilter;
|
||||
samplingIntensity = preset.samplingIntensity;
|
||||
samplingWidth = preset.samplingWidth;
|
||||
dst.m_SamplingFilter = src.m_SamplingFilter;
|
||||
dst.m_SamplingIntensity = src.m_SamplingIntensity;
|
||||
dst.m_SamplingWidth = src.m_SamplingWidth;
|
||||
|
||||
transitionFilter = preset.transitionFilter;
|
||||
transitionRate = preset.transitionRate;
|
||||
transitionReverse = preset.transitionReverse;
|
||||
transitionTex = preset.transitionTex;
|
||||
transitionTexScale = preset.transitionTexScale;
|
||||
transitionTexOffset = preset.transitionTexOffset;
|
||||
transitionTexSpeed = preset.transitionTexSpeed;
|
||||
transitionKeepAspectRatio = preset.transitionKeepAspectRatio;
|
||||
transitionRotation = preset.transitionRotation;
|
||||
transitionWidth = preset.transitionWidth;
|
||||
transitionSoftness = preset.transitionSoftness;
|
||||
transitionRange = preset.transitionRange;
|
||||
transitionColor = preset.transitionColor;
|
||||
transitionColorFilter = preset.transitionColorFilter;
|
||||
transitionColorGlow = preset.transitionColorGlow;
|
||||
transitionPatternReverse = preset.transitionPatternReverse;
|
||||
transitionAutoPlaySpeed = preset.transitionAutoPlaySpeed;
|
||||
dst.m_TransitionFilter = src.m_TransitionFilter;
|
||||
dst.m_TransitionRate = src.m_TransitionRate;
|
||||
dst.m_TransitionReverse = src.m_TransitionReverse;
|
||||
dst.m_TransitionTex = src.m_TransitionTex;
|
||||
dst.m_TransitionTexScale = src.m_TransitionTexScale;
|
||||
dst.m_TransitionTexOffset = src.m_TransitionTexOffset;
|
||||
dst.m_TransitionTexSpeed = src.m_TransitionTexSpeed;
|
||||
dst.m_TransitionKeepAspectRatio = src.m_TransitionKeepAspectRatio;
|
||||
dst.m_TransitionRotation = src.m_TransitionRotation;
|
||||
dst.m_TransitionWidth = src.m_TransitionWidth;
|
||||
dst.m_TransitionSoftness = src.m_TransitionSoftness;
|
||||
dst.m_TransitionRange = src.m_TransitionRange;
|
||||
dst.m_TransitionColor = src.m_TransitionColor;
|
||||
dst.m_TransitionColorFilter = src.m_TransitionColorFilter;
|
||||
dst.m_TransitionColorGlow = src.m_TransitionColorGlow;
|
||||
dst.m_TransitionPatternReverse = src.m_TransitionPatternReverse;
|
||||
dst.m_TransitionAutoPlaySpeed = src.m_TransitionAutoPlaySpeed;
|
||||
dst.m_TransitionGradient = src.m_TransitionGradient;
|
||||
|
||||
targetMode = preset.targetMode;
|
||||
targetColor = preset.targetColor;
|
||||
targetRange = preset.targetRange;
|
||||
targetSoftness = preset.targetSoftness;
|
||||
dst.m_TargetMode = src.m_TargetMode;
|
||||
dst.m_TargetColor = src.m_TargetColor;
|
||||
dst.m_TargetRange = src.m_TargetRange;
|
||||
dst.m_TargetSoftness = src.m_TargetSoftness;
|
||||
|
||||
srcBlendMode = preset.srcBlendMode;
|
||||
dstBlendMode = preset.dstBlendMode;
|
||||
dst.m_SrcBlendMode = src.m_SrcBlendMode;
|
||||
dst.m_DstBlendMode = src.m_DstBlendMode;
|
||||
|
||||
shadowMode = preset.shadowMode;
|
||||
shadowDistance = preset.shadowDistance;
|
||||
shadowIteration = preset.shadowIteration;
|
||||
shadowFade = preset.shadowFade;
|
||||
shadowMirrorScale = preset.shadowMirrorScale;
|
||||
shadowBlurIntensity = preset.shadowBlurIntensity;
|
||||
shadowColorFilter = preset.shadowColorFilter;
|
||||
shadowColor = preset.shadowColor;
|
||||
shadowColorGlow = preset.shadowColorGlow;
|
||||
dst.m_ShadowMode = src.m_ShadowMode;
|
||||
dst.m_ShadowDistance = src.m_ShadowDistance;
|
||||
dst.m_ShadowIteration = src.m_ShadowIteration;
|
||||
dst.m_ShadowFade = src.m_ShadowFade;
|
||||
dst.m_ShadowMirrorScale = src.m_ShadowMirrorScale;
|
||||
dst.m_ShadowBlurIntensity = src.m_ShadowBlurIntensity;
|
||||
dst.m_ShadowColorFilter = src.m_ShadowColorFilter;
|
||||
dst.m_ShadowColor = src.m_ShadowColor;
|
||||
dst.m_ShadowColorGlow = src.m_ShadowColorGlow;
|
||||
|
||||
edgeMode = preset.edgeMode;
|
||||
edgeShinyRate = preset.edgeShinyRate;
|
||||
edgeWidth = preset.edgeWidth;
|
||||
edgeColorFilter = preset.edgeColorFilter;
|
||||
edgeColor = preset.edgeColor;
|
||||
edgeColorGlow = preset.edgeColorGlow;
|
||||
edgeShinyAutoPlaySpeed = preset.edgeShinyAutoPlaySpeed;
|
||||
edgeShinyWidth = preset.edgeShinyWidth;
|
||||
patternArea = preset.patternArea;
|
||||
dst.m_EdgeMode = src.m_EdgeMode;
|
||||
dst.m_EdgeShinyRate = src.m_EdgeShinyRate;
|
||||
dst.m_EdgeWidth = src.m_EdgeWidth;
|
||||
dst.m_EdgeColorFilter = src.m_EdgeColorFilter;
|
||||
dst.m_EdgeColor = src.m_EdgeColor;
|
||||
dst.m_EdgeColorGlow = src.m_EdgeColorGlow;
|
||||
dst.m_EdgeShinyAutoPlaySpeed = src.m_EdgeShinyAutoPlaySpeed;
|
||||
dst.m_EdgeShinyWidth = src.m_EdgeShinyWidth;
|
||||
dst.m_PatternArea = src.m_PatternArea;
|
||||
|
||||
gradationMode = preset.gradationMode;
|
||||
gradationIntensity = preset.gradationIntensity;
|
||||
gradationColorFilter = preset.gradationColorFilter;
|
||||
gradationColor1 = preset.gradationColor1;
|
||||
gradationColor2 = preset.gradationColor2;
|
||||
gradationColor3 = preset.gradationColor3;
|
||||
gradationColor4 = preset.gradationColor4;
|
||||
gradationTex = preset.gradationTex;
|
||||
gradationScale = preset.gradationScale;
|
||||
gradationOffset = preset.gradationOffset;
|
||||
gradationRotation = preset.gradationRotation;
|
||||
dst.m_GradationMode = src.m_GradationMode;
|
||||
dst.m_GradationIntensity = src.m_GradationIntensity;
|
||||
dst.m_GradationColorFilter = src.m_GradationColorFilter;
|
||||
dst.m_GradationColor1 = src.m_GradationColor1;
|
||||
dst.m_GradationColor2 = src.m_GradationColor2;
|
||||
dst.m_GradationColor3 = src.m_GradationColor3;
|
||||
dst.m_GradationColor4 = src.m_GradationColor4;
|
||||
dst.m_GradationGradient = src.m_GradationGradient;
|
||||
dst.m_GradationScale = src.m_GradationScale;
|
||||
dst.m_GradationOffset = src.m_GradationOffset;
|
||||
dst.m_GradationRotation = src.m_GradationRotation;
|
||||
dst.m_GradationWrapMode = src.m_GradationWrapMode;
|
||||
dst.m_GradationReverse = src.m_GradationReverse;
|
||||
|
||||
detailFilter = preset.detailFilter;
|
||||
detailIntensity = preset.detailIntensity;
|
||||
detailThreshold = preset.detailThreshold;
|
||||
detailTex = preset.detailTex;
|
||||
detailTexScale = preset.detailTexScale;
|
||||
detailTexOffset = preset.detailTexOffset;
|
||||
detailTexSpeed = preset.detailTexSpeed;
|
||||
dst.m_DetailFilter = src.m_DetailFilter;
|
||||
dst.m_DetailIntensity = src.m_DetailIntensity;
|
||||
dst.m_DetailColor = src.m_DetailColor;
|
||||
dst.m_DetailThreshold = src.m_DetailThreshold;
|
||||
dst.m_DetailTex = src.m_DetailTex;
|
||||
dst.m_DetailTexScale = src.m_DetailTexScale;
|
||||
dst.m_DetailTexOffset = src.m_DetailTexOffset;
|
||||
dst.m_DetailTexSpeed = src.m_DetailTexSpeed;
|
||||
|
||||
dst.m_Flip = src.m_Flip;
|
||||
}
|
||||
|
||||
public void SetGradationDirty()
|
||||
{
|
||||
InternalListPool<float>.Return(ref _keyTimes);
|
||||
_isGradientDirty = true;
|
||||
}
|
||||
|
||||
public void SetTransitionGradationDirty()
|
||||
{
|
||||
_isTransitionGradientDirty = true;
|
||||
}
|
||||
|
||||
public void ApplyToMaterial(Material material, float actualSamplingScale = 1f)
|
||||
{
|
||||
if (!material) return;
|
||||
|
||||
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
|
||||
Profiler.BeginSample("(UIE)[UIEffect] ApplyToMaterial");
|
||||
|
||||
material.SetInt(s_SrcBlend, (int)srcBlendMode);
|
||||
material.SetInt(s_DstBlend, (int)dstBlendMode);
|
||||
material.SetInt(s_SrcBlend, (int)m_SrcBlendMode);
|
||||
material.SetInt(s_DstBlend, (int)m_DstBlendMode);
|
||||
|
||||
material.SetFloat(s_ToneIntensity, Mathf.Clamp01(toneIntensity));
|
||||
material.SetVector(s_ToneParams, toneParams);
|
||||
material.SetFloat(s_ToneIntensity, Mathf.Clamp01(m_ToneIntensity));
|
||||
|
||||
material.SetInt(s_ColorFilter, (int)colorFilter);
|
||||
material.SetColor(s_ColorValue, color);
|
||||
material.SetFloat(s_ColorIntensity, Mathf.Clamp01(colorIntensity));
|
||||
material.SetInt(s_ColorGlow, colorGlow ? 1 : 0);
|
||||
material.SetInt(s_ColorFilter, (int)m_ColorFilter);
|
||||
material.SetColor(s_ColorValue, ApplyColorSpace(m_Color));
|
||||
material.SetFloat(s_ColorIntensity, Mathf.Clamp01(m_ColorIntensity));
|
||||
material.SetInt(s_ColorGlow, m_ColorGlow ? 1 : 0);
|
||||
|
||||
material.SetFloat(s_SamplingIntensity, Mathf.Clamp01(samplingIntensity));
|
||||
material.SetFloat(s_SamplingWidth, samplingWidth);
|
||||
material.SetFloat(s_SamplingIntensity, Mathf.Clamp01(m_SamplingIntensity));
|
||||
material.SetFloat(s_SamplingWidth, m_SamplingWidth);
|
||||
material.SetFloat(s_SamplingScale, actualSamplingScale);
|
||||
|
||||
material.SetFloat(s_TransitionRate, Mathf.Clamp01(transitionRate));
|
||||
material.SetInt(s_TransitionReverse, transitionReverse ? 1 : 0);
|
||||
material.SetTexture(s_TransitionTex, transitionFilter != 0 ? transitionTex : null);
|
||||
material.SetFloat(s_TransitionRate, Mathf.Clamp01(m_TransitionRate));
|
||||
material.SetInt(s_TransitionReverse, m_TransitionReverse ? 1 : 0);
|
||||
material.SetTexture(s_TransitionTex, m_TransitionFilter != 0 ? m_TransitionTex : null);
|
||||
material.SetVector(s_TransitionTex_ST,
|
||||
new Vector4(transitionTexScale.x, transitionTexScale.y,
|
||||
transitionTexOffset.x, transitionTexOffset.y));
|
||||
material.SetVector(s_TransitionTex_Speed, transitionTexSpeed);
|
||||
material.SetFloat(s_TransitionWidth, Mathf.Clamp01(transitionWidth));
|
||||
material.SetFloat(s_TransitionSoftness, Mathf.Clamp01(transitionSoftness));
|
||||
material.SetVector(s_TransitionRange, new Vector2(transitionRange.min, transitionRange.max));
|
||||
material.SetInt(s_TransitionColorFilter, (int)transitionColorFilter);
|
||||
material.SetColor(s_TransitionColor, transitionColor);
|
||||
material.SetInt(s_TransitionColorGlow, transitionColorGlow ? 1 : 0);
|
||||
material.SetInt(s_TransitionPatternReverse, transitionPatternReverse ? 1 : 0);
|
||||
material.SetFloat(s_TransitionAutoPlaySpeed, transitionAutoPlaySpeed);
|
||||
new Vector4(m_TransitionTexScale.x, m_TransitionTexScale.y,
|
||||
m_TransitionTexOffset.x, m_TransitionTexOffset.y));
|
||||
material.SetVector(s_TransitionTex_Speed, m_TransitionTexSpeed);
|
||||
material.SetFloat(s_TransitionWidth, Mathf.Clamp01(m_TransitionWidth));
|
||||
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, 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, targetColor);
|
||||
material.SetFloat(s_TargetRange, Mathf.Clamp01(targetRange));
|
||||
material.SetFloat(s_TargetSoftness, Mathf.Clamp01(targetSoftness));
|
||||
material.SetColor(s_TargetColor, ApplyColorSpace(m_TargetColor));
|
||||
material.SetFloat(s_TargetRange, Mathf.Clamp01(m_TargetRange));
|
||||
material.SetFloat(s_TargetSoftness, Mathf.Clamp01(m_TargetSoftness));
|
||||
|
||||
switch (samplingFilter)
|
||||
switch (m_SamplingFilter)
|
||||
{
|
||||
case SamplingFilter.BlurFast:
|
||||
case SamplingFilter.BlurMedium:
|
||||
case SamplingFilter.BlurDetail:
|
||||
material.SetFloat(s_ShadowBlurIntensity, Mathf.Clamp01(shadowBlurIntensity));
|
||||
material.SetFloat(s_ShadowBlurIntensity, Mathf.Clamp01(m_ShadowBlurIntensity));
|
||||
break;
|
||||
default:
|
||||
material.SetFloat(s_ShadowBlurIntensity, Mathf.Clamp01(samplingIntensity));
|
||||
material.SetFloat(s_ShadowBlurIntensity, Mathf.Clamp01(m_SamplingIntensity));
|
||||
break;
|
||||
}
|
||||
|
||||
material.SetInt(s_ShadowColorFilter, (int)shadowColorFilter);
|
||||
material.SetColor(s_ShadowColor, shadowColor);
|
||||
material.SetInt(s_ShadowColorGlow, shadowColorGlow ? 1 : 0);
|
||||
material.SetInt(s_ShadowColorFilter, (int)m_ShadowColorFilter);
|
||||
material.SetColor(s_ShadowColor, ApplyColorSpace(m_ShadowColor));
|
||||
material.SetInt(s_ShadowColorGlow, m_ShadowColorGlow ? 1 : 0);
|
||||
|
||||
material.SetFloat(s_EdgeWidth, Mathf.Clamp01(edgeWidth));
|
||||
material.SetInt(s_EdgeColorFilter, (int)edgeColorFilter);
|
||||
material.SetColor(s_EdgeColor, edgeColor);
|
||||
material.SetInt(s_EdgeColorGlow, edgeColorGlow ? 1 : 0);
|
||||
material.SetFloat(s_EdgeShinyRate, Mathf.Clamp01(edgeShinyRate));
|
||||
material.SetFloat(s_EdgeShinyWidth, Mathf.Clamp01(edgeShinyWidth));
|
||||
material.SetFloat(s_EdgeShinyAutoPlaySpeed, edgeShinyAutoPlaySpeed);
|
||||
material.SetInt(s_PatternArea, edgeMode != EdgeMode.None ? (int)patternArea : 0);
|
||||
material.SetFloat(s_EdgeWidth, Mathf.Clamp01(m_EdgeWidth));
|
||||
material.SetInt(s_EdgeColorFilter, (int)m_EdgeColorFilter);
|
||||
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));
|
||||
material.SetFloat(s_EdgeShinyAutoPlaySpeed, m_EdgeShinyAutoPlaySpeed);
|
||||
material.SetInt(s_PatternArea, m_EdgeMode != EdgeMode.None ? (int)m_PatternArea : 0);
|
||||
|
||||
material.SetTexture(s_GradationTex, gradationMode != 0 ? gradationTex : null);
|
||||
material.SetTexture(s_GradationTex, m_GradationMode != 0 ? gradationRampTex : null);
|
||||
material.SetVector(s_GradationTex_ST, GetGradationScaleAndOffset());
|
||||
|
||||
material.SetFloat(s_GradationIntensity, gradationIntensity);
|
||||
material.SetInt(s_GradationColorFilter, (int)gradationColorFilter);
|
||||
material.SetColor(s_GradationColor1, gradationColor1);
|
||||
material.SetColor(s_GradationColor2, gradationColor2);
|
||||
material.SetColor(s_GradationColor3, gradationColor3);
|
||||
material.SetColor(s_GradationColor4, gradationColor4);
|
||||
material.SetFloat(s_GradationIntensity, m_GradationIntensity);
|
||||
material.SetInt(s_GradationColorFilter, (int)m_GradationColorFilter);
|
||||
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
|
||||
#pragma warning restore CS0612
|
||||
|| m_GradationMode == GradationMode.RadialGradient ? 1 : 0);
|
||||
|
||||
material.SetFloat(s_DetailIntensity, Mathf.Clamp01(detailIntensity));
|
||||
material.SetVector(s_DetailThreshold, new Vector2(detailThreshold.min, detailThreshold.max));
|
||||
material.SetTexture(s_DetailTex, detailFilter != 0 ? detailTex : null);
|
||||
material.SetFloat(s_DetailIntensity, Mathf.Clamp01(m_DetailIntensity));
|
||||
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,
|
||||
new Vector4(detailTexScale.x, detailTexScale.y,
|
||||
detailTexOffset.x, detailTexOffset.y));
|
||||
material.SetVector(s_DetailTex_Speed, detailTexSpeed);
|
||||
new Vector4(m_DetailTexScale.x, m_DetailTexScale.y,
|
||||
m_DetailTexOffset.x, m_DetailTexOffset.y));
|
||||
material.SetVector(s_DetailTex_Speed, m_DetailTexSpeed);
|
||||
|
||||
SetKeyword(material, s_ToneKeywords, (int)toneFilter);
|
||||
SetKeyword(material, s_ColorKeywords, colorFilter != 0 || shadowMode != 0 ? 1 : 0);
|
||||
SetKeyword(material, s_SamplingKeywords, (int)samplingFilter);
|
||||
SetKeyword(material, s_TransitionKeywords, (int)transitionFilter);
|
||||
SetKeyword(material, s_EdgeKeywords, (int)edgeMode);
|
||||
SetKeyword(material, s_DetailKeywords, (int)detailFilter);
|
||||
SetKeyword(material, s_TargetKeywords, (int)targetMode);
|
||||
SetKeyword(material, s_ToneKeywords, (int)m_ToneFilter);
|
||||
SetKeyword(material, s_ColorKeywords, m_ColorFilter != 0 || m_ShadowMode != 0 ? 1 : 0);
|
||||
SetKeyword(material, s_SamplingKeywords, (int)m_SamplingFilter);
|
||||
SetKeyword(material, s_TransitionKeywords, (int)m_TransitionFilter);
|
||||
SetKeyword(material, s_EdgeKeywords, (int)m_EdgeMode);
|
||||
SetKeyword(material, s_DetailKeywords, (int)m_DetailFilter);
|
||||
SetKeyword(material, s_TargetKeywords, (int)m_TargetMode);
|
||||
|
||||
switch (gradationMode)
|
||||
switch (m_GradationMode)
|
||||
{
|
||||
case GradationMode.None:
|
||||
SetKeyword(material, s_GradationKeywords, 0);
|
||||
@@ -442,21 +554,22 @@ namespace Coffee.UIEffects
|
||||
case GradationMode.HorizontalGradient:
|
||||
case GradationMode.VerticalGradient:
|
||||
case GradationMode.AngleGradient:
|
||||
case GradationMode.RadialGradient:
|
||||
SetKeyword(material, s_GradationKeywords, 1);
|
||||
break;
|
||||
case GradationMode.RadialFast:
|
||||
case GradationMode.RadialDetail:
|
||||
SetKeyword(material, s_GradationKeywords, 2);
|
||||
break;
|
||||
case GradationMode.Horizontal:
|
||||
case GradationMode.Vertical:
|
||||
case GradationMode.DiagonalToRightBottom:
|
||||
case GradationMode.DiagonalToLeftBottom:
|
||||
case GradationMode.Angle:
|
||||
SetKeyword(material, s_GradationKeywords, 3);
|
||||
case GradationMode.Radial:
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
case GradationMode.RadialDetail:
|
||||
#pragma warning restore CS0612
|
||||
SetKeyword(material, s_GradationKeywords, 2);
|
||||
break;
|
||||
case GradationMode.Diagonal:
|
||||
SetKeyword(material, s_GradationKeywords, 4);
|
||||
SetKeyword(material, s_GradationKeywords, 3);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -466,73 +579,93 @@ namespace Coffee.UIEffects
|
||||
public void SetEnablePreview(bool enable, Material material)
|
||||
{
|
||||
if (!material) return;
|
||||
material.SetVector(s_TransitionTex_Speed, enable ? (Vector4)transitionTexSpeed : Vector4.zero);
|
||||
material.SetVector(s_DetailTex_Speed, enable ? (Vector4)detailTexSpeed : Vector4.zero);
|
||||
material.SetFloat(s_TransitionAutoPlaySpeed, enable ? transitionAutoPlaySpeed : 0);
|
||||
material.SetFloat(s_EdgeShinyAutoPlaySpeed, enable ? edgeShinyAutoPlaySpeed : 0);
|
||||
material.SetVector(s_TransitionTex_Speed, enable ? (Vector4)m_TransitionTexSpeed : Vector4.zero);
|
||||
material.SetVector(s_DetailTex_Speed, enable ? (Vector4)m_DetailTexSpeed : Vector4.zero);
|
||||
material.SetFloat(s_TransitionAutoPlaySpeed, enable ? m_TransitionAutoPlaySpeed : 0);
|
||||
material.SetFloat(s_EdgeShinyAutoPlaySpeed, enable ? m_EdgeShinyAutoPlaySpeed : 0);
|
||||
}
|
||||
|
||||
public void UpdateViewMatrix(Material material, RectTransform transitionRoot, Canvas canvas, Flip flip)
|
||||
public void UpdateViewMatrix(Material material, RectTransform transitionRoot, Canvas canvas)
|
||||
{
|
||||
if (!material) return;
|
||||
|
||||
var size = transitionRoot.rect.size;
|
||||
var scale = new Vector3(1f / size.x, 1f / size.y, 1f);
|
||||
if (transitionKeepAspectRatio && !Mathf.Approximately(scale.x, scale.y))
|
||||
if (m_TransitionKeepAspectRatio && !Mathf.Approximately(scale.x, scale.y))
|
||||
{
|
||||
scale.x = scale.y = Mathf.Min(scale.x, scale.y);
|
||||
}
|
||||
|
||||
if (0 != (flip & Flip.Effect))
|
||||
if (0 != (m_Flip & Flip.Effect))
|
||||
{
|
||||
scale.x = 0 != (flip & Flip.Horizontal) ? -scale.x : scale.x;
|
||||
scale.y = 0 != (flip & Flip.Vertical) ? -scale.y : scale.y;
|
||||
scale.x = 0 != (m_Flip & Flip.Horizontal) ? -scale.x : scale.x;
|
||||
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, transitionRotation);
|
||||
var rootScale = 1f / GetMultiplier(transitionRotation);
|
||||
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 (canvas.renderMode == RenderMode.ScreenSpaceOverlay || !canvas.worldCamera)
|
||||
if (m_ShadowMode == ShadowMode.Mirror)
|
||||
{
|
||||
material.SetMatrix(s_CanvasToWorldMatrix, canvas.transform.localToWorldMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.SetMatrix(s_CanvasToWorldMatrix, Matrix4x4.identity);
|
||||
var mirrorInv = 1f / m_ShadowMirrorScale;
|
||||
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);
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
var gScale = 1 / gradationScale;
|
||||
switch (gradationMode)
|
||||
var gScale = 1 / m_GradationScale;
|
||||
switch (m_GradationMode)
|
||||
{
|
||||
case GradationMode.HorizontalGradient:
|
||||
case GradationMode.VerticalGradient:
|
||||
case GradationMode.AngleGradient:
|
||||
return new Vector4(gScale, 1, -0.5f * (gScale + 1) - gradationOffset, 0);
|
||||
case GradationMode.RadialFast:
|
||||
return new Vector4(gScale, 1, -0.5f * (gScale + 1) - m_GradationOffset, 0);
|
||||
case GradationMode.Radial:
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
case GradationMode.RadialDetail:
|
||||
#pragma warning restore CS0612
|
||||
{
|
||||
return new Vector4(gScale, 1, gradationOffset, 0);
|
||||
return new Vector4(gScale, 1, m_GradationOffset, 0);
|
||||
}
|
||||
default:
|
||||
return new Vector4(gScale, 1, gradationOffset * (gScale + 1) / 2 - gScale * 0.5f + 0.5f, 0);
|
||||
return new Vector4(gScale, 1, m_GradationOffset * (gScale + 1) / 2 - gScale * 0.5f + 0.5f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private float GetGradationRotation()
|
||||
{
|
||||
switch (gradationMode)
|
||||
switch (m_GradationMode)
|
||||
{
|
||||
case GradationMode.DiagonalToLeftBottom:
|
||||
return 135;
|
||||
@@ -544,7 +677,7 @@ namespace Coffee.UIEffects
|
||||
return -90;
|
||||
case GradationMode.Angle:
|
||||
case GradationMode.AngleGradient:
|
||||
return gradationRotation;
|
||||
return m_GradationRotation;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -558,33 +691,37 @@ 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, Flip flip)
|
||||
public void ModifyMesh(Graphic graphic, Canvas canvas, RectTransform transitionRoot, VertexHelper vh,
|
||||
bool canModifyShape)
|
||||
{
|
||||
// Apply flip (without effect).
|
||||
ApplyFlipWithoutEffect(vh, flip);
|
||||
ApplyFlipWithoutEffect(vh, m_Flip);
|
||||
|
||||
var count = vh.currentIndexCount;
|
||||
if (!willModifyVertex || count == 0) return;
|
||||
|
||||
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));
|
||||
@@ -616,10 +753,10 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
|
||||
// Apply flip (with effect).
|
||||
ApplyFlipWithEffect(verts, flip);
|
||||
ApplyFlipWithEffect(verts, m_Flip);
|
||||
|
||||
// Apply shadow.
|
||||
ApplyShadow(verts, transitionRoot, flip);
|
||||
ApplyShadow(verts, transitionRoot, m_Flip);
|
||||
|
||||
vh.Clear();
|
||||
vh.AddUIVertexTriangleStream(verts);
|
||||
@@ -627,7 +764,7 @@ namespace Coffee.UIEffects
|
||||
|
||||
private void ApplyShadow(List<UIVertex> verts, RectTransform transitionRoot, Flip flip)
|
||||
{
|
||||
var distance = shadowDistance;
|
||||
var distance = m_ShadowDistance;
|
||||
if (distance == Vector2.zero) return;
|
||||
|
||||
if ((flip & Flip.Shadow) != 0)
|
||||
@@ -636,17 +773,17 @@ namespace Coffee.UIEffects
|
||||
distance.y = (flip & Flip.Vertical) != 0 ? -distance.y : distance.y;
|
||||
}
|
||||
|
||||
switch (shadowMode)
|
||||
switch (m_ShadowMode)
|
||||
{
|
||||
case ShadowMode.Shadow:
|
||||
case ShadowMode.Shadow3:
|
||||
case ShadowMode.Outline:
|
||||
case ShadowMode.Outline8:
|
||||
ShadowUtil.DoShadow(verts, s_ShadowVectors[(int)shadowMode], distance, shadowIteration,
|
||||
shadowFade);
|
||||
ShadowUtil.DoShadow(verts, s_ShadowVectors[(int)m_ShadowMode], distance, m_ShadowIteration,
|
||||
m_ShadowFade);
|
||||
break;
|
||||
case ShadowMode.Mirror:
|
||||
ShadowUtil.DoMirror(verts, distance, shadowMirrorScale, shadowFade, transitionRoot);
|
||||
ShadowUtil.DoMirror(verts, distance, m_ShadowMirrorScale, m_ShadowFade, transitionRoot);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -678,7 +815,7 @@ namespace Coffee.UIEffects
|
||||
if (!canModifyShape) return Vector4.zero;
|
||||
|
||||
var expandSize = Vector4.zero;
|
||||
switch (samplingFilter)
|
||||
switch (m_SamplingFilter)
|
||||
{
|
||||
case SamplingFilter.BlurFast:
|
||||
expandSize += Vector4.one * 10;
|
||||
@@ -695,7 +832,7 @@ namespace Coffee.UIEffects
|
||||
break;
|
||||
}
|
||||
|
||||
switch (transitionFilter)
|
||||
switch (m_TransitionFilter)
|
||||
{
|
||||
case TransitionFilter.Melt:
|
||||
expandSize.y += 40;
|
||||
@@ -707,5 +844,10 @@ namespace Coffee.UIEffects
|
||||
|
||||
return expandSize;
|
||||
}
|
||||
|
||||
private static Color ApplyColorSpace(Color color)
|
||||
{
|
||||
return QualitySettings.activeColorSpace == ColorSpace.Linear ? color.linear : color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
using Coffee.UIEffectInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[CreateAssetMenu]
|
||||
[ExecuteAlways]
|
||||
public class UIEffectPreset : ScriptableObject
|
||||
{
|
||||
internal static UIEffectPreset s_DefaultPreset;
|
||||
|
||||
internal static UIEffectPreset GetDefaultPreset()
|
||||
{
|
||||
if (!s_DefaultPreset)
|
||||
{
|
||||
s_DefaultPreset = CreateInstance<UIEffectPreset>();
|
||||
s_DefaultPreset.hideFlags = HideFlags.HideAndDontSave;
|
||||
}
|
||||
|
||||
return s_DefaultPreset;
|
||||
}
|
||||
|
||||
public ToneFilter m_ToneFilter = ToneFilter.None;
|
||||
[Range(0, 1)] public float m_ToneIntensity = 1;
|
||||
|
||||
public ColorFilter m_ColorFilter = ColorFilter.None;
|
||||
[Range(0, 1)] public float m_ColorIntensity = 1;
|
||||
public Color m_Color = Color.white;
|
||||
public bool m_ColorGlow = false;
|
||||
|
||||
public SamplingFilter m_SamplingFilter = SamplingFilter.None;
|
||||
[Range(0, 1)] public float m_SamplingIntensity = 0.5f;
|
||||
[Range(0.5f, 10f)] public float m_SamplingWidth = 1;
|
||||
|
||||
public TransitionFilter m_TransitionFilter = TransitionFilter.None;
|
||||
[Range(0, 1)] public float m_TransitionRate = 0.5f;
|
||||
public bool m_TransitionReverse;
|
||||
public Texture m_TransitionTex;
|
||||
public Vector2 m_TransitionTexScale = new Vector2(1, 1);
|
||||
public Vector2 m_TransitionTexOffset = new Vector2(0, 0);
|
||||
public Vector2 m_TransitionTexSpeed = new Vector2(0, 0);
|
||||
[Range(0, 360)] public float m_TransitionRotation = 0;
|
||||
public bool m_TransitionKeepAspectRatio = true;
|
||||
[Range(0, 1)] public float m_TransitionWidth = 0.2f;
|
||||
[Range(0, 1)] public float m_TransitionSoftness = 0.2f;
|
||||
public MinMax01 m_TransitionRange = new MinMax01(0, 1);
|
||||
public ColorFilter m_TransitionColorFilter = ColorFilter.MultiplyAdditive;
|
||||
public Color m_TransitionColor = new Color(0f, 0.5f, 1.0f, 1.0f);
|
||||
public bool m_TransitionColorGlow = false;
|
||||
public bool m_TransitionPatternReverse = false;
|
||||
[Range(-5, 5)] public float m_TransitionAutoPlaySpeed = 0f;
|
||||
public Gradient m_TransitionGradient = new Gradient();
|
||||
|
||||
public TargetMode m_TargetMode = TargetMode.None;
|
||||
public Color m_TargetColor = Color.white;
|
||||
[Range(0, 1)] public float m_TargetRange = 0.1f;
|
||||
[Range(0, 1)] public float m_TargetSoftness = 0.5f;
|
||||
|
||||
public BlendType m_BlendType = BlendType.AlphaBlend;
|
||||
public BlendMode m_SrcBlendMode = BlendMode.One;
|
||||
public BlendMode m_DstBlendMode = BlendMode.OneMinusSrcAlpha;
|
||||
|
||||
public ShadowMode m_ShadowMode = ShadowMode.None;
|
||||
public Vector2 m_ShadowDistance = new Vector2(1f, -1f);
|
||||
[Range(1, 5)] public int m_ShadowIteration = 1;
|
||||
[Range(0, 1)] public float m_ShadowFade = 0.9f;
|
||||
[Range(0, 2)] public float m_ShadowMirrorScale = 0.5f;
|
||||
[Range(0, 1)] public float m_ShadowBlurIntensity = 1;
|
||||
public ColorFilter m_ShadowColorFilter = ColorFilter.Replace;
|
||||
public Color m_ShadowColor = Color.white;
|
||||
public bool m_ShadowColorGlow = false;
|
||||
|
||||
public GradationMode m_GradationMode = GradationMode.None;
|
||||
[Range(0, 1)] public float m_GradationIntensity = 1;
|
||||
public GradationColorFilter m_GradationColorFilter = GradationColorFilter.Multiply;
|
||||
public Color m_GradationColor1 = Color.white;
|
||||
public Color m_GradationColor2 = Color.white;
|
||||
public Color m_GradationColor3 = Color.white;
|
||||
public Color m_GradationColor4 = Color.white;
|
||||
public Gradient m_GradationGradient = new Gradient();
|
||||
[Range(-1, 1)] public float m_GradationOffset = 0;
|
||||
[PowerRange(0.01f, 10, 10)] public float m_GradationScale = 1;
|
||||
[Range(0, 360)] public float m_GradationRotation = 0;
|
||||
public TextureWrapMode m_GradationWrapMode = TextureWrapMode.Repeat;
|
||||
public bool m_GradationReverse;
|
||||
|
||||
public EdgeMode m_EdgeMode = EdgeMode.None;
|
||||
[Range(0, 1)] public float m_EdgeWidth = 0.5f;
|
||||
public ColorFilter m_EdgeColorFilter = ColorFilter.Replace;
|
||||
public Color m_EdgeColor = Color.white;
|
||||
public bool m_EdgeColorGlow = false;
|
||||
[Range(0, 1)] public float m_EdgeShinyRate = 0.5f;
|
||||
[Range(0, 1)] public float m_EdgeShinyWidth = 0.5f;
|
||||
[Range(-5, 5)] public float m_EdgeShinyAutoPlaySpeed = 1f;
|
||||
public PatternArea m_PatternArea = PatternArea.Inner;
|
||||
|
||||
public DetailFilter m_DetailFilter = DetailFilter.None;
|
||||
[Range(0, 1)] public float m_DetailIntensity = 1;
|
||||
public Color m_DetailColor = Color.white;
|
||||
public MinMax01 m_DetailThreshold = new MinMax01(0, 1);
|
||||
public Texture m_DetailTex;
|
||||
public Vector2 m_DetailTexScale = new Vector2(1, 1);
|
||||
public Vector2 m_DetailTexOffset = new Vector2(0, 0);
|
||||
public Vector2 m_DetailTexSpeed = new Vector2(0, 0);
|
||||
|
||||
public Flip m_Flip = 0;
|
||||
|
||||
public void UpdateContext(UIEffectContext dst)
|
||||
{
|
||||
var src = this;
|
||||
dst.m_ToneFilter = src.m_ToneFilter;
|
||||
dst.m_ToneIntensity = src.m_ToneIntensity;
|
||||
|
||||
dst.m_ColorFilter = src.m_ColorFilter;
|
||||
dst.m_Color = src.m_Color;
|
||||
dst.m_ColorIntensity = src.m_ColorIntensity;
|
||||
dst.m_ColorGlow = src.m_ColorGlow;
|
||||
|
||||
dst.m_SamplingFilter = src.m_SamplingFilter;
|
||||
dst.m_SamplingIntensity = src.m_SamplingIntensity;
|
||||
dst.m_SamplingWidth = src.m_SamplingWidth;
|
||||
|
||||
dst.m_TransitionFilter = src.m_TransitionFilter;
|
||||
dst.m_TransitionRate = src.m_TransitionRate;
|
||||
dst.m_TransitionReverse = src.m_TransitionReverse;
|
||||
dst.m_TransitionTex = src.m_TransitionTex;
|
||||
dst.m_TransitionTexScale = src.m_TransitionTexScale;
|
||||
dst.m_TransitionTexOffset = src.m_TransitionTexOffset;
|
||||
dst.m_TransitionTexSpeed = src.m_TransitionTexSpeed;
|
||||
dst.m_TransitionRotation = src.m_TransitionRotation;
|
||||
dst.m_TransitionKeepAspectRatio = src.m_TransitionKeepAspectRatio;
|
||||
dst.m_TransitionWidth = src.m_TransitionWidth;
|
||||
dst.m_TransitionSoftness = src.m_TransitionSoftness;
|
||||
dst.m_TransitionRange = src.m_TransitionRange;
|
||||
dst.m_TransitionColorFilter = src.m_TransitionColorFilter;
|
||||
dst.m_TransitionColor = src.m_TransitionColor;
|
||||
dst.m_TransitionColorGlow = src.m_TransitionColorGlow;
|
||||
dst.m_TransitionPatternReverse = src.m_TransitionPatternReverse;
|
||||
dst.m_TransitionAutoPlaySpeed = src.m_TransitionAutoPlaySpeed;
|
||||
dst.m_TransitionGradient = src.m_TransitionGradient;
|
||||
|
||||
dst.m_TargetMode = src.m_TargetMode;
|
||||
dst.m_TargetColor = src.m_TargetColor;
|
||||
dst.m_TargetRange = src.m_TargetRange;
|
||||
dst.m_TargetSoftness = src.m_TargetSoftness;
|
||||
|
||||
dst.m_SrcBlendMode = src.m_SrcBlendMode;
|
||||
dst.m_DstBlendMode = src.m_DstBlendMode;
|
||||
|
||||
dst.m_ShadowMode = src.m_ShadowMode;
|
||||
dst.m_ShadowDistance = src.m_ShadowDistance;
|
||||
dst.m_ShadowIteration = src.m_ShadowIteration;
|
||||
dst.m_ShadowFade = src.m_ShadowFade;
|
||||
dst.m_ShadowMirrorScale = src.m_ShadowMirrorScale;
|
||||
dst.m_ShadowBlurIntensity = src.m_ShadowBlurIntensity;
|
||||
dst.m_ShadowColorFilter = src.m_ShadowColorFilter;
|
||||
dst.m_ShadowColor = src.m_ShadowColor;
|
||||
dst.m_ShadowColorGlow = src.m_ShadowColorGlow;
|
||||
|
||||
dst.m_EdgeMode = src.m_EdgeMode;
|
||||
dst.m_EdgeShinyRate = src.m_EdgeShinyRate;
|
||||
dst.m_EdgeWidth = src.m_EdgeWidth;
|
||||
dst.m_EdgeColorFilter = src.m_EdgeColorFilter;
|
||||
dst.m_EdgeColor = src.m_EdgeColor;
|
||||
dst.m_EdgeColorGlow = src.m_EdgeColorGlow;
|
||||
dst.m_EdgeShinyWidth = src.m_EdgeShinyWidth;
|
||||
dst.m_EdgeShinyAutoPlaySpeed = src.m_EdgeShinyAutoPlaySpeed;
|
||||
dst.m_PatternArea = src.m_PatternArea;
|
||||
|
||||
dst.m_GradationMode = src.m_GradationMode;
|
||||
dst.m_GradationIntensity = src.m_GradationIntensity;
|
||||
dst.m_GradationColorFilter = src.m_GradationColorFilter;
|
||||
dst.m_GradationColor1 = src.m_GradationColor1;
|
||||
dst.m_GradationColor2 = src.m_GradationColor2;
|
||||
dst.m_GradationColor3 = src.m_GradationColor3;
|
||||
dst.m_GradationColor4 = src.m_GradationColor4;
|
||||
dst.m_GradationGradient = src.m_GradationGradient;
|
||||
dst.m_GradationOffset = src.m_GradationOffset;
|
||||
dst.m_GradationScale = src.m_GradationScale;
|
||||
dst.m_GradationRotation = src.m_GradationRotation;
|
||||
dst.m_GradationWrapMode = src.m_GradationWrapMode;
|
||||
dst.m_GradationReverse = src.m_GradationReverse;
|
||||
|
||||
dst.m_DetailFilter = src.m_DetailFilter;
|
||||
dst.m_DetailIntensity = src.m_DetailIntensity;
|
||||
dst.m_DetailColor = src.m_DetailColor;
|
||||
dst.m_DetailThreshold = src.m_DetailThreshold;
|
||||
dst.m_DetailTex = src.m_DetailTex;
|
||||
dst.m_DetailTexScale = src.m_DetailTexScale;
|
||||
dst.m_DetailTexOffset = src.m_DetailTexOffset;
|
||||
dst.m_DetailTexSpeed = src.m_DetailTexSpeed;
|
||||
|
||||
dst.m_Flip = src.m_Flip;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1b6988bc8fdf48b4896110606a86b61
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 5b93acc4527c740459bbfbd3404191be, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -6,19 +7,18 @@ using Coffee.UIEffectInternal;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
public class UIEffectProjectSettings : PreloadedProjectSettings<UIEffectProjectSettings>
|
||||
{
|
||||
[Tooltip(
|
||||
"The sensitivity of the transformation when `Use Target Transform` is enabled in the `UIEffectReplica` component.")]
|
||||
[Header("Setting")]
|
||||
[SerializeField]
|
||||
private TransformSensitivity m_TransformSensitivity = TransformSensitivity.Medium;
|
||||
internal List<UIEffect> m_RuntimePresets = new List<UIEffect>();
|
||||
|
||||
[SerializeField]
|
||||
internal List<UIEffect> m_RuntimePresets = new List<UIEffect>();
|
||||
internal List<UIEffectPreset> m_RuntimePresetsV2 = new List<UIEffectPreset>();
|
||||
|
||||
[Header("Editor")]
|
||||
[Tooltip("Use HDR color pickers on color fields.")]
|
||||
@@ -36,29 +36,24 @@ namespace Coffee.UIEffects
|
||||
|
||||
public static ShaderVariantCollection shaderVariantCollection => shaderRegistry.shaderVariantCollection;
|
||||
|
||||
public static TransformSensitivity transformSensitivity
|
||||
{
|
||||
get => instance.m_TransformSensitivity;
|
||||
set => instance.m_TransformSensitivity = value;
|
||||
}
|
||||
|
||||
public static bool useHdrColorPicker
|
||||
{
|
||||
get => instance.m_UseHDRColorPicker;
|
||||
set => instance.m_UseHDRColorPicker = value;
|
||||
}
|
||||
|
||||
public static void RegisterRuntimePreset(UIEffect effect)
|
||||
public static void RegisterRuntimePreset(UIEffectPreset preset)
|
||||
{
|
||||
// Already registered.
|
||||
if (!effect || LoadRuntimePreset(effect.name)) return;
|
||||
if (!preset || instance.m_RuntimePresetsV2.Contains(preset)) return;
|
||||
|
||||
instance.m_RuntimePresets.Add(effect);
|
||||
instance.m_RuntimePresetsV2.Add(preset);
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.SetDirty(instance);
|
||||
#endif
|
||||
}
|
||||
|
||||
[Obsolete("LoadRuntimePreset is obsolete. Use LoadPreset instead.", false)]
|
||||
public static UIEffect LoadRuntimePreset(string presetName)
|
||||
{
|
||||
for (var i = 0; i < instance.m_RuntimePresets.Count; i++)
|
||||
@@ -73,6 +68,21 @@ namespace Coffee.UIEffects
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Object LoadPreset(string presetName)
|
||||
{
|
||||
for (var i = 0; i < instance.m_RuntimePresetsV2.Count; i++)
|
||||
{
|
||||
var preset = instance.m_RuntimePresetsV2[i];
|
||||
if (preset && preset.name == presetName)
|
||||
{
|
||||
return preset;
|
||||
}
|
||||
}
|
||||
#pragma warning disable CS0618
|
||||
return LoadRuntimePreset(presetName);
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private const string k_PresetDir = "UIEffectPresets";
|
||||
private const string k_PresetSaveDir = "Assets/ProjectSettings/" + k_PresetDir;
|
||||
@@ -81,12 +91,12 @@ 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.7.0 (Unity 6)";
|
||||
const string version = "v5.9.0 (Unity 6)";
|
||||
#else
|
||||
const string tmpSupport = "TextMeshPro Support";
|
||||
const string version = "v5.7.0";
|
||||
const string version = "v5.9.0";
|
||||
#endif
|
||||
ShaderSampleImporter.RegisterShaderSamples(new[]
|
||||
{
|
||||
@@ -101,8 +111,8 @@ namespace Coffee.UIEffects
|
||||
("Hidden/TextMeshPro/Mobile/Distance Field (UIEffect)", tmpSupport, version),
|
||||
|
||||
// ShaderGraph Support
|
||||
("Shader Graphs/UISample (UIEffect)", "ShaderGraph Support (Unity 6 BuiltIn)", "v5.7.0"),
|
||||
("Shader Graphs/UISampleURP (UIEffect)", "ShaderGraph Support (Unity 6 URP)", "v5.7.0")
|
||||
("Shader Graphs/UISample (UIEffect)", "ShaderGraph Support (Unity 6 BuiltIn)", "v5.9.0"),
|
||||
("Shader Graphs/UISampleURP (UIEffect)", "ShaderGraph Support (Unity 6 URP)", "v5.9.0")
|
||||
});
|
||||
ShaderSampleImporter.RegisterShaderAliases(new[]
|
||||
{
|
||||
@@ -223,11 +233,26 @@ namespace Coffee.UIEffects
|
||||
.ToArray();
|
||||
return AssetDatabase.FindAssets("t:prefab", dirs)
|
||||
.Select(AssetDatabase.GUIDToAssetPath)
|
||||
.OrderBy(x => AssetImporter.GetAtPath(x).userData)
|
||||
.Select(AssetDatabase.LoadAssetAtPath<UIEffect>)
|
||||
.Where(x => x)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
internal static UIEffectPreset[] LoadEditorPresetsV2()
|
||||
{
|
||||
var dirs = AssetDatabase.FindAssets(k_PresetDir + " t:folder")
|
||||
.Select(AssetDatabase.GUIDToAssetPath)
|
||||
.Where(x => Path.GetFileName(x) == k_PresetDir)
|
||||
.OrderBy(x => x.StartsWith("Packages/com.coffee.ui-effect/"))
|
||||
.ToArray();
|
||||
return AssetDatabase.FindAssets("t:UIEffectPreset", dirs)
|
||||
.Select(AssetDatabase.GUIDToAssetPath)
|
||||
.OrderBy(x => AssetImporter.GetAtPath(x).userData)
|
||||
.Select(AssetDatabase.LoadAssetAtPath<UIEffectPreset>)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
internal static void SaveAsNewPreset(UIEffect effect)
|
||||
{
|
||||
if (!Directory.Exists(k_PresetSaveDir))
|
||||
@@ -235,18 +260,16 @@ namespace Coffee.UIEffects
|
||||
Directory.CreateDirectory(k_PresetSaveDir);
|
||||
}
|
||||
|
||||
var prefabPath = EditorUtility.SaveFilePanel("Save Preset", k_PresetSaveDir, effect.name, "prefab");
|
||||
if (string.IsNullOrEmpty(prefabPath)) return;
|
||||
var path = EditorUtility.SaveFilePanel("Save Preset", k_PresetSaveDir, effect.name, "asset");
|
||||
if (string.IsNullOrEmpty(path)) return;
|
||||
|
||||
var prefab = new GameObject();
|
||||
prefab.SetActive(false);
|
||||
path = FileUtil.GetProjectRelativePath(path);
|
||||
path = AssetDatabase.GenerateUniqueAssetPath(path);
|
||||
|
||||
var preset = prefab.AddComponent<UIEffect>();
|
||||
preset.LoadPreset(effect);
|
||||
var prefabAsset = PrefabUtility.SaveAsPrefabAsset(prefab, prefabPath);
|
||||
|
||||
EditorGUIUtility.PingObject(prefabAsset);
|
||||
DestroyImmediate(prefab);
|
||||
var preset = CreateInstance<UIEffectPreset>();
|
||||
effect.SavePreset(preset, false);
|
||||
AssetDatabase.CreateAsset(preset, path);
|
||||
EditorGUIUtility.PingObject(preset);
|
||||
}
|
||||
|
||||
[SettingsProvider]
|
||||
@@ -255,7 +278,7 @@ namespace Coffee.UIEffects
|
||||
return new PreloadedProjectSettingsProvider("Project/UI/UI Effect");
|
||||
}
|
||||
|
||||
internal static (string path, bool builtin) GetPresetPath(UIEffect preset)
|
||||
internal static (string path, bool builtin) GetPresetPath(Object preset)
|
||||
{
|
||||
var assetPath = AssetDatabase.GetAssetPath(preset);
|
||||
var builtin = assetPath.StartsWith("Packages/com.coffee.ui-effect/");
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
using Coffee.UIEffectInternal;
|
||||
using System.Linq;
|
||||
using Coffee.UIEffectInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[Icon("Packages/com.coffee.ui-effect/Editor/UIEffectIconIcon.png")]
|
||||
public class UIEffectReplica : UIEffectBase
|
||||
public sealed class UIEffectReplica : UIEffectBase, ISerializationCallbackReceiver
|
||||
{
|
||||
[SerializeField] private UIEffect m_Target;
|
||||
[SerializeField] private UIEffectPreset m_Preset;
|
||||
[SerializeField] private bool m_UseTargetTransform = true;
|
||||
|
||||
[PowerRange(0.01f, 100, 10f)]
|
||||
@@ -28,12 +30,26 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (m_Target == value) return;
|
||||
m_Target = value;
|
||||
m_Preset = null;
|
||||
RefreshTarget(m_Target);
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public UIEffectPreset preset
|
||||
{
|
||||
get => m_Preset;
|
||||
set
|
||||
{
|
||||
if (m_Preset == value) return;
|
||||
m_Preset = value;
|
||||
RefreshTarget(null);
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public bool useTargetTransform
|
||||
{
|
||||
get => m_UseTargetTransform;
|
||||
@@ -79,36 +95,61 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public override Flip flip => target ? target.flip : 0;
|
||||
|
||||
public override float actualSamplingScale => Mathf.Clamp(m_SamplingScale, 0.01f, 100);
|
||||
|
||||
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
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!target) return null;
|
||||
if (!isTargetInScene) return base.context;
|
||||
// Following the preset/preset-target.
|
||||
if (preset || (target && !isTargetInScene)) return base.context;
|
||||
|
||||
return target.isActiveAndEnabled ? target.context : null;
|
||||
// Following the instantiated target.
|
||||
return target && target.isActiveAndEnabled && isTargetInScene
|
||||
? target.context
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
RefreshTarget(target);
|
||||
if (!preset)
|
||||
{
|
||||
RefreshTarget(target);
|
||||
}
|
||||
|
||||
base.OnEnable();
|
||||
}
|
||||
|
||||
@@ -128,13 +169,28 @@ namespace Coffee.UIEffects
|
||||
protected override void OnValidate()
|
||||
{
|
||||
RefreshTarget(target);
|
||||
|
||||
if (preset || (target && !isTargetInScene))
|
||||
{
|
||||
context?.SetGradationDirty();
|
||||
context?.SetTransitionGradationDirty();
|
||||
}
|
||||
|
||||
base.OnValidate();
|
||||
}
|
||||
|
||||
internal override void SetEnablePreviewIfSelected(GameObject[] selection)
|
||||
{
|
||||
if (!isTargetInScene) return;
|
||||
target.SetEnablePreviewIfSelected(selection);
|
||||
// Following the instantiated target.
|
||||
if (isTargetInScene)
|
||||
{
|
||||
target.SetEnablePreviewIfSelected(selection);
|
||||
}
|
||||
// Following the preset/preset-target.
|
||||
else
|
||||
{
|
||||
context?.SetEnablePreview(selection.Contains(gameObject), effectMaterial);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -160,20 +216,34 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
internal override void UpdateContext(UIEffectContext c)
|
||||
internal override void UpdateContext(UIEffectContext dst)
|
||||
{
|
||||
if (target && !isTargetInScene)
|
||||
// Following the preset.
|
||||
if (preset)
|
||||
{
|
||||
target.UpdateContext(c);
|
||||
preset.UpdateContext(dst);
|
||||
}
|
||||
// Following the preset-target.
|
||||
else if (target && !isTargetInScene)
|
||||
{
|
||||
target.UpdateContext(dst);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyContextToMaterial(Material material)
|
||||
{
|
||||
if (!isActiveAndEnabled || !target) return;
|
||||
if (isTargetInScene && !target.isActiveAndEnabled) return;
|
||||
if (!isActiveAndEnabled && !preset && !target) return;
|
||||
|
||||
base.ApplyContextToMaterial(material);
|
||||
// Following the preset/preset-target.
|
||||
if (preset || (target && !isTargetInScene))
|
||||
{
|
||||
base.ApplyContextToMaterial(material);
|
||||
}
|
||||
// Following the instantiated target.
|
||||
else if (isTargetInScene && target.isActiveAndEnabled)
|
||||
{
|
||||
base.ApplyContextToMaterial(material);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetRate(float rate, UIEffectTweener.CullingMask mask)
|
||||
@@ -186,5 +256,22 @@ namespace Coffee.UIEffects
|
||||
|
||||
return target.IsRaycastLocationValid(sp, eventCamera);
|
||||
}
|
||||
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
if (m_Preset)
|
||||
{
|
||||
m_Target = null;
|
||||
}
|
||||
else if (m_Target)
|
||||
{
|
||||
m_Preset = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -80,10 +82,10 @@ namespace Coffee.UIEffects
|
||||
private static readonly Func<UIVertex, UIVertex, UIVertex, float, UIVertex> s_OnLerpVertex =
|
||||
null;
|
||||
|
||||
private static readonly Func<UIVertex, UIVertex> s_OnMarkAsShadow =
|
||||
vt =>
|
||||
private static readonly Func<UIVertex, float, UIVertex> s_OnMarkAsShadow =
|
||||
(vt, s) =>
|
||||
{
|
||||
vt.uv1.x -= 2;
|
||||
vt.uv1.x -= s;
|
||||
return vt;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
internal class ImageProxy : GraphicProxy
|
||||
internal sealed class ImageProxy : GraphicProxy
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[InitializeOnLoadMethod]
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
public static class ShadowUtil
|
||||
{
|
||||
public static Func<UIVertex, UIVertex> onMarkAsShadow;
|
||||
public static Func<UIVertex, float, UIVertex> onMarkAsShadow;
|
||||
|
||||
public static void DoShadow(List<UIVertex> verts, Vector2[] vectors, Vector2 distance, int iteration,
|
||||
float fade)
|
||||
@@ -30,14 +30,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (onMarkAsShadow != null)
|
||||
{
|
||||
verts[i] = onMarkAsShadow(verts[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
var vt = verts[i];
|
||||
vt.uv0.z -= 8;
|
||||
vt.uv0.w -= 8;
|
||||
verts[i] = vt;
|
||||
verts[i] = onMarkAsShadow(verts[i], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +47,15 @@ namespace Coffee.UIEffects
|
||||
var offset = distance.y - (scale + 1) * pivot * height;
|
||||
var range = new Vector2(rect2.yMin, rect2.yMax);
|
||||
ApplyMirror(verts, count, rate, range, scale, offset, fade);
|
||||
|
||||
// Mark as shadow vertices.
|
||||
for (var i = 0; i < verts.Count - count; i++)
|
||||
{
|
||||
if (onMarkAsShadow != null)
|
||||
{
|
||||
verts[i] = onMarkAsShadow(verts[i], 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyMirror(List<UIVertex> verts, int count, float rate, Vector2 range, float scale,
|
||||
|
||||
@@ -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;
|
||||
@@ -59,7 +58,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
OnChangeText(textMeshProUGUI);
|
||||
s_ChangedInstances.Add(textMeshProUGUI);
|
||||
}
|
||||
else if (0 < textMeshProUGUI.textInfo?.meshInfo?.Length
|
||||
&& 0 < textMeshProUGUI.textInfo.meshInfo[0].vertexCount)
|
||||
@@ -91,10 +90,10 @@ namespace Coffee.UIEffects
|
||||
};
|
||||
#endif
|
||||
|
||||
private static readonly Func<UIVertex, UIVertex> s_OnMarkAsShadow =
|
||||
vt =>
|
||||
private static readonly Func<UIVertex, float, UIVertex> s_OnMarkAsShadow =
|
||||
(vt, s) =>
|
||||
{
|
||||
vt.uv2.x -= 2;
|
||||
vt.uv2.x -= s;
|
||||
return vt;
|
||||
};
|
||||
|
||||
@@ -111,21 +110,30 @@ namespace Coffee.UIEffects
|
||||
private static readonly HashSet<TextMeshProUGUI> s_RegisteredInstances = new HashSet<TextMeshProUGUI>();
|
||||
private static readonly Dictionary<int, float> s_SdfScaleCache = new Dictionary<int, float>();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[InitializeOnLoadMethod]
|
||||
#endif
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
private static void InitializeOnLoad()
|
||||
private static void RuntimeInitializeOnLoadMethod()
|
||||
{
|
||||
s_ChangedInstances.Clear();
|
||||
s_RegisteredInstances.Clear();
|
||||
s_SdfScaleCache.Clear();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[InitializeOnLoadMethod]
|
||||
#else
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
#endif
|
||||
private static void InitializeOnLoad()
|
||||
{
|
||||
Register(new TmpProxy());
|
||||
|
||||
// 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);
|
||||
}
|
||||
@@ -137,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;
|
||||
@@ -145,11 +155,11 @@ namespace Coffee.UIEffects
|
||||
// If the scale has changed, add to the changed list
|
||||
if (s_SdfScaleCache.TryGetValue(id, out var prev) && !Mathf.Approximately(prev, lossyScaleY))
|
||||
{
|
||||
OnChangeText(textMeshProUGUI);
|
||||
s_ChangedInstances.Add(textMeshProUGUI);
|
||||
}
|
||||
|
||||
// Update the scale cache
|
||||
s_SdfScaleCache[id] = textMeshProUGUI.transform.lossyScale.y;
|
||||
s_SdfScaleCache[id] = lossyScaleY;
|
||||
}
|
||||
// Remove destroyed objects later
|
||||
else if (!ReferenceEquals(textMeshProUGUI, null))
|
||||
@@ -174,6 +184,9 @@ namespace Coffee.UIEffects
|
||||
foreach (var textMeshProUGUI in s_ChangedInstances)
|
||||
{
|
||||
if (!textMeshProUGUI || !textMeshProUGUI.isActiveAndEnabled) continue;
|
||||
if (!textMeshProUGUI.TryGetComponent<IMeshModifier>(out var _)) continue;
|
||||
|
||||
s_RegisteredInstances.Add(textMeshProUGUI);
|
||||
ModifyMesh(textMeshProUGUI);
|
||||
}
|
||||
|
||||
@@ -198,14 +211,6 @@ namespace Coffee.UIEffects
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void OnChangeText(Object obj)
|
||||
{
|
||||
if (obj is TextMeshProUGUI textMeshProUGUI && textMeshProUGUI.isActiveAndEnabled)
|
||||
{
|
||||
s_ChangedInstances.Add(textMeshProUGUI);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ModifyMesh(TextMeshProUGUI textMeshProUGUI)
|
||||
{
|
||||
if (!s_Mesh)
|
||||
@@ -214,19 +219,38 @@ namespace Coffee.UIEffects
|
||||
s_Mesh.MarkDynamic();
|
||||
}
|
||||
|
||||
s_RegisteredInstances.Add(textMeshProUGUI);
|
||||
var effect = textMeshProUGUI.GetComponent<UIEffectBase>();
|
||||
var subMeshes = InternalListPool<TMP_SubMeshUI>.Rent();
|
||||
var modifiers = InternalListPool<IMeshModifier>.Rent();
|
||||
var subModifiers = InternalListPool<IMeshModifier>.Rent();
|
||||
textMeshProUGUI.TryGetComponent<UIEffectBase>(out var effect);
|
||||
textMeshProUGUI.GetComponentsInChildren(subMeshes, 1);
|
||||
textMeshProUGUI.GetComponents(modifiers);
|
||||
|
||||
for (var i = 0; i < textMeshProUGUI.textInfo.meshInfo.Length; i++)
|
||||
{
|
||||
var meshInfo = textMeshProUGUI.textInfo.meshInfo[i];
|
||||
if (meshInfo.vertexCount == 0)
|
||||
{
|
||||
// Clear mesh if no vertices.
|
||||
s_Mesh.Clear(false);
|
||||
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;
|
||||
}
|
||||
|
||||
s_VertexHelper.Clear();
|
||||
meshInfo.mesh.CopyTo(s_VertexHelper, meshInfo.vertexCount, meshInfo.vertexCount * 6 / 4);
|
||||
meshInfo.mesh.CopyTo(s_VertexHelper);
|
||||
if (i == 0)
|
||||
{
|
||||
foreach (var modifier in modifiers)
|
||||
@@ -248,20 +272,28 @@ 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;
|
||||
replica.useTargetTransform = true;
|
||||
replica.customRoot = null;
|
||||
replica.flip = pEffect.flip;
|
||||
}
|
||||
else if (effect is UIEffectReplica pReplica && pReplica.isActiveAndEnabled)
|
||||
{
|
||||
replica.target = pReplica.target;
|
||||
replica.preset = pReplica.preset;
|
||||
replica.useTargetTransform = pReplica.useTargetTransform;
|
||||
replica.customRoot = pReplica.customRoot;
|
||||
replica.flip = pReplica.flip;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -288,6 +320,7 @@ namespace Coffee.UIEffects
|
||||
InternalListPool<IMeshModifier>.Return(ref modifiers);
|
||||
InternalListPool<IMeshModifier>.Return(ref subModifiers);
|
||||
s_Mesh.Clear(false);
|
||||
Misc.QueuePlayerLoopUpdate();
|
||||
}
|
||||
|
||||
private static TMP_SubMeshUI GetSubMeshUI(List<TMP_SubMeshUI> subMeshes, Material material, int start)
|
||||
|
||||
@@ -20,7 +20,7 @@ TextureImporter:
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 1
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
@@ -53,7 +53,7 @@ TextureImporter:
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
@@ -69,7 +69,7 @@ TextureImporter:
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 4
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
@@ -100,7 +100,7 @@ TextureImporter:
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 1
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
@@ -112,7 +112,7 @@ TextureImporter:
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 1
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 190 B |
@@ -0,0 +1,114 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b4bb77fa760f487cac2866aeb002588
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 0
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 32
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -31,6 +31,7 @@ SpriteAtlas:
|
||||
m_CrunchedCompression: 0
|
||||
m_AllowsAlphaSplitting: 0
|
||||
m_Overridden: 0
|
||||
m_IgnorePlatformSupport: 0
|
||||
m_AndroidETC2FallbackOverride: 0
|
||||
m_ForceMaximumCompressionQuality_BC6H_BC7: 1
|
||||
packingSettings:
|
||||
@@ -48,6 +49,14 @@ SpriteAtlas:
|
||||
bindAsDefault: 1
|
||||
isAtlasV2: 0
|
||||
cachedData: {fileID: 0}
|
||||
packedSpriteRenderDataKeys:
|
||||
- 2ee815c0807434e9091770d1c6cdc70b: 21300000
|
||||
- 098475820cf634867a339bb9af940722: 21300000
|
||||
- 03b5a015427324a419a5ddbd5d5a6551: 21300000
|
||||
- e822d767ed19641dcaf9831e1c8a742a: 21300000
|
||||
- 9617fea85692e4f5fb65fb2ddd4496ce: 21300000
|
||||
- 1851730bef7524e58b285a364983e21e: 21300000
|
||||
- be1fa55f69843fb4aaf4d0ff56004fba: 21300000
|
||||
m_MasterAtlas: {fileID: 0}
|
||||
m_PackedSprites:
|
||||
- {fileID: 21300000, guid: 2ee815c0807434e9091770d1c6cdc70b, type: 3}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -295,7 +295,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
m_ToneFilter: 0
|
||||
m_ToneIntensity: 1
|
||||
m_ToneParams: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_ColorFilter: 0
|
||||
m_ColorIntensity: 0.344
|
||||
m_Color: {r: 0, g: 1.7098039, b: 4, a: 1}
|
||||
@@ -340,6 +339,8 @@ MonoBehaviour:
|
||||
m_ShadowColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_ShadowColorGlow: 0
|
||||
m_GradationMode: 0
|
||||
m_GradationIntensity: 1
|
||||
m_GradationColorFilter: 1
|
||||
m_GradationColor1: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_GradationColor2: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_GradationColor3: {r: 1, g: 1, b: 1, a: 1}
|
||||
@@ -382,11 +383,23 @@ MonoBehaviour:
|
||||
m_EdgeWidth: 0.5
|
||||
m_EdgeColorFilter: 4
|
||||
m_EdgeColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_EdgeColorGlow: 0
|
||||
m_EdgeShinyRate: 0.5
|
||||
m_EdgeShinyWidth: 0.5
|
||||
m_EdgeShinyAutoPlaySpeed: 1
|
||||
m_PatternArea: 1
|
||||
m_DetailFilter: 0
|
||||
m_DetailIntensity: 1
|
||||
m_DetailThreshold:
|
||||
m_Min: 0
|
||||
m_Max: 1
|
||||
m_DetailColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_DetailTex: {fileID: 0}
|
||||
m_DetailTexScale: {x: 1, y: 1}
|
||||
m_DetailTexOffset: {x: 0, y: 0}
|
||||
m_DetailTexSpeed: {x: 0, y: 0}
|
||||
m_CustomRoot: {fileID: 0}
|
||||
m_Flip: 0
|
||||
--- !u!1 &973375176
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -592,7 +605,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 189, y: -165}
|
||||
m_AnchoredPosition: {x: 189, y: -117}
|
||||
m_SizeDelta: {x: 415.4, y: 111.41}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1421004028
|
||||
@@ -609,7 +622,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
m_ToneFilter: 0
|
||||
m_ToneIntensity: 1
|
||||
m_ToneParams: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_ColorFilter: 0
|
||||
m_ColorIntensity: 1
|
||||
m_Color: {r: 0.7454045, g: 0.18447503, b: 0.000303527, a: 1}
|
||||
@@ -654,6 +666,8 @@ MonoBehaviour:
|
||||
m_ShadowColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_ShadowColorGlow: 0
|
||||
m_GradationMode: 0
|
||||
m_GradationIntensity: 1
|
||||
m_GradationColorFilter: 1
|
||||
m_GradationColor1: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_GradationColor2: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_GradationColor3: {r: 1, g: 1, b: 1, a: 1}
|
||||
@@ -696,11 +710,23 @@ MonoBehaviour:
|
||||
m_EdgeWidth: 0.5
|
||||
m_EdgeColorFilter: 4
|
||||
m_EdgeColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_EdgeColorGlow: 0
|
||||
m_EdgeShinyRate: 0.5
|
||||
m_EdgeShinyWidth: 0.5
|
||||
m_EdgeShinyAutoPlaySpeed: 1
|
||||
m_PatternArea: 1
|
||||
m_DetailFilter: 0
|
||||
m_DetailIntensity: 1
|
||||
m_DetailThreshold:
|
||||
m_Min: 0
|
||||
m_Max: 1
|
||||
m_DetailColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_DetailTex: {fileID: 0}
|
||||
m_DetailTexScale: {x: 1, y: 1}
|
||||
m_DetailTexOffset: {x: 0, y: 0}
|
||||
m_DetailTexSpeed: {x: 0, y: 0}
|
||||
m_CustomRoot: {fileID: 0}
|
||||
m_Flip: 0
|
||||
--- !u!114 &1421004029
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -853,7 +879,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
m_ToneFilter: 1
|
||||
m_ToneIntensity: 0.75
|
||||
m_ToneParams: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_ColorFilter: 6
|
||||
m_ColorIntensity: 0.6
|
||||
m_Color: {r: 0.16862746, g: 0, b: 0.12038653, a: 1}
|
||||
@@ -898,6 +923,8 @@ MonoBehaviour:
|
||||
m_ShadowColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_ShadowColorGlow: 0
|
||||
m_GradationMode: 0
|
||||
m_GradationIntensity: 1
|
||||
m_GradationColorFilter: 1
|
||||
m_GradationColor1: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_GradationColor2: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_GradationColor3: {r: 1, g: 1, b: 1, a: 1}
|
||||
@@ -940,11 +967,23 @@ MonoBehaviour:
|
||||
m_EdgeWidth: 0.5
|
||||
m_EdgeColorFilter: 4
|
||||
m_EdgeColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_EdgeColorGlow: 0
|
||||
m_EdgeShinyRate: 0.5
|
||||
m_EdgeShinyWidth: 0.5
|
||||
m_EdgeShinyAutoPlaySpeed: 1
|
||||
m_PatternArea: 1
|
||||
m_DetailFilter: 0
|
||||
m_DetailIntensity: 1
|
||||
m_DetailThreshold:
|
||||
m_Min: 0
|
||||
m_Max: 1
|
||||
m_DetailColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_DetailTex: {fileID: 0}
|
||||
m_DetailTexScale: {x: 1, y: 1}
|
||||
m_DetailTexOffset: {x: 0, y: 0}
|
||||
m_DetailTexSpeed: {x: 0, y: 0}
|
||||
m_CustomRoot: {fileID: 0}
|
||||
m_Flip: 0
|
||||
--- !u!114 &1567169364
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
+10
-1
@@ -10,7 +10,9 @@ namespace UnityEditor.Rendering.BuiltIn.ShaderGraph
|
||||
internal class BuiltInUIEffectSubTarget : BuiltInCanvasSubTarget
|
||||
{
|
||||
// UIEffectForShaderGraph.hlsl
|
||||
internal static string s_UIEffectHlsl => AssetDatabase.GUIDToAssetPath("5109b2ad9b8be459592190a5678464e3");
|
||||
private static GUID s_UIEffectCgincGuid => new GUID("2dd0ed35b98b345218d9aa8ac5a3ad6b");
|
||||
private static GUID s_UIEffectHlslGuid => new GUID("5109b2ad9b8be459592190a5678464e3");
|
||||
private static string s_UIEffectHlsl => AssetDatabase.GUIDToAssetPath(s_UIEffectHlslGuid.ToString());
|
||||
|
||||
public BuiltInUIEffectSubTarget() { displayName = "Canvas (UIEffect)"; }
|
||||
|
||||
@@ -25,6 +27,13 @@ namespace UnityEditor.Rendering.BuiltIn.ShaderGraph
|
||||
protected override IncludeCollection postgraphIncludes => base.postgraphIncludes
|
||||
.Add(s_UIEffectHlsl, IncludeLocation.Postgraph); // Include UIEffectForShaderGraph.hlsl on postgraph
|
||||
|
||||
public override void Setup(ref TargetSetupContext context)
|
||||
{
|
||||
base.Setup(ref context);
|
||||
context.AddAssetDependency(s_UIEffectHlslGuid, AssetCollection.Flags.SourceDependency);
|
||||
context.AddAssetDependency(s_UIEffectCgincGuid, AssetCollection.Flags.SourceDependency);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modify pass descriptor for UIEffect.
|
||||
/// </summary>
|
||||
|
||||
+12
-11
@@ -1,5 +1,6 @@
|
||||
// ==== UIEFFECT START ====
|
||||
SurfaceDescriptionInputs _fragInput;
|
||||
|
||||
half4 uieffect_frag(float2 uv)
|
||||
{
|
||||
float2 prevUv = _fragInput.uv0.xy;
|
||||
@@ -34,25 +35,25 @@ half4 frag_override(PackedVaryings packedInput) : SV_TARGET
|
||||
_fragInput = surfaceDescriptionInputs;
|
||||
const half4 origin = uieffect_frag(_fragInput.uv0.xy);
|
||||
half4 color = uieffect(origin, _fragInput.uv0.xy, unpacked.texCoord2, float4(unpacked.positionWS, 1));
|
||||
|
||||
|
||||
//Round up the alpha color coming from the interpolator (to 1.0/256.0 steps)
|
||||
//The incoming alpha could have numerical instability, which makes it very sensible to
|
||||
//HDR color transparency blend, when it blends with the world's texture.
|
||||
const half alphaPrecision = half(0xff);
|
||||
const half invAlphaPrecision = half(1.0/alphaPrecision);
|
||||
unpacked.color.a = round(unpacked.color.a * alphaPrecision)*invAlphaPrecision;
|
||||
|
||||
const half invAlphaPrecision = half(1.0 / alphaPrecision);
|
||||
unpacked.color.a = round(unpacked.color.a * alphaPrecision) * invAlphaPrecision;
|
||||
|
||||
#if !defined(HAVE_VFX_MODIFICATION) && !defined(_DISABLE_COLOR_TINT)
|
||||
color.rgb *= unpacked.color.rgb;
|
||||
color *= unpacked.color.a;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
//mask = Uv2
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(unpacked.texCoord1.xy)) * unpacked.texCoord1.zw);
|
||||
color *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASKABLE
|
||||
color *= SoftMask(unpacked.positionCS, unpacked.positionWS, color.a);
|
||||
@@ -60,12 +61,12 @@ half4 frag_override(PackedVaryings packedInput) : SV_TARGET
|
||||
// ==== SOFTMASKABLE END ====
|
||||
|
||||
#if defined(_ALPHATEST_ON) || defined(_BUILTIN_ALPHATEST_ON)
|
||||
clip(color.a - surfaceDescription.Alpha);
|
||||
clip(color.a - surfaceDescription.AlphaClipThreshold);
|
||||
#endif
|
||||
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
+125
@@ -26,6 +26,12 @@
|
||||
},
|
||||
{
|
||||
"m_Id": "867db961355a4c1ea898b69d9e6549b0"
|
||||
},
|
||||
{
|
||||
"m_Id": "a76cdcf36ae243e5a5ea033c7d40d34f"
|
||||
},
|
||||
{
|
||||
"m_Id": "23e0b7c820e7452ab73c3bec44cf0e48"
|
||||
}
|
||||
],
|
||||
"m_GroupDatas": [],
|
||||
@@ -92,6 +98,12 @@
|
||||
},
|
||||
{
|
||||
"m_Id": "d326ef5f90af4c7996e7e0c915e57983"
|
||||
},
|
||||
{
|
||||
"m_Id": "a76cdcf36ae243e5a5ea033c7d40d34f"
|
||||
},
|
||||
{
|
||||
"m_Id": "23e0b7c820e7452ab73c3bec44cf0e48"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -168,6 +180,85 @@
|
||||
"m_CustomEditorGUI": ""
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
|
||||
"m_ObjectId": "23e0b7c820e7452ab73c3bec44cf0e48",
|
||||
"m_Group": {
|
||||
"m_Id": ""
|
||||
},
|
||||
"m_Name": "SurfaceDescription.AlphaClipThreshold",
|
||||
"m_DrawState": {
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"width": 0.0,
|
||||
"height": 0.0
|
||||
}
|
||||
},
|
||||
"m_Slots": [
|
||||
{
|
||||
"m_Id": "3c6f2af22741431faed8a2606630029a"
|
||||
}
|
||||
],
|
||||
"synonyms": [],
|
||||
"m_Precision": 0,
|
||||
"m_PreviewExpanded": true,
|
||||
"m_DismissedVersion": 0,
|
||||
"m_PreviewMode": 0,
|
||||
"m_CustomColors": {
|
||||
"m_SerializableColors": []
|
||||
},
|
||||
"m_SerializedDescriptor": "SurfaceDescription.AlphaClipThreshold"
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
"m_ObjectId": "3c6f2af22741431faed8a2606630029a",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "Alpha Clip Threshold",
|
||||
"m_SlotType": 0,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "AlphaClipThreshold",
|
||||
"m_StageCapability": 2,
|
||||
"m_Value": 0.009999999776482582,
|
||||
"m_DefaultValue": 0.5,
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot",
|
||||
"m_ObjectId": "5891f1777feb46cdbd85b489f87bfc69",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "Emission",
|
||||
"m_SlotType": 0,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Emission",
|
||||
"m_StageCapability": 2,
|
||||
"m_Value": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"m_DefaultValue": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"m_Labels": [],
|
||||
"m_ColorMode": 1,
|
||||
"m_DefaultColor": {
|
||||
"r": 0.0,
|
||||
"g": 0.0,
|
||||
"b": 0.0,
|
||||
"a": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.Texture2DMaterialSlot",
|
||||
@@ -402,6 +493,40 @@
|
||||
"m_Labels": []
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
|
||||
"m_ObjectId": "a76cdcf36ae243e5a5ea033c7d40d34f",
|
||||
"m_Group": {
|
||||
"m_Id": ""
|
||||
},
|
||||
"m_Name": "SurfaceDescription.Emission",
|
||||
"m_DrawState": {
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"width": 0.0,
|
||||
"height": 0.0
|
||||
}
|
||||
},
|
||||
"m_Slots": [
|
||||
{
|
||||
"m_Id": "5891f1777feb46cdbd85b489f87bfc69"
|
||||
}
|
||||
],
|
||||
"synonyms": [],
|
||||
"m_Precision": 0,
|
||||
"m_PreviewExpanded": true,
|
||||
"m_DismissedVersion": 0,
|
||||
"m_PreviewMode": 0,
|
||||
"m_CustomColors": {
|
||||
"m_SerializableColors": []
|
||||
},
|
||||
"m_SerializedDescriptor": "SurfaceDescription.Emission"
|
||||
}
|
||||
|
||||
{
|
||||
"m_SGVersion": 0,
|
||||
"m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot",
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData: v5.7.0
|
||||
userData: v5.9.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData: v5.7.0
|
||||
userData: v5.9.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
|
||||
+13
-1
@@ -6,6 +6,11 @@ namespace UnityEditor.Rendering.Universal.ShaderGraph
|
||||
{
|
||||
internal class UniversalUIEffectSubTarget : UniversalCanvasSubTarget
|
||||
{
|
||||
// UIEffectForShaderGraph.hlsl
|
||||
private static GUID s_UIEffectCgincGuid => new GUID("2dd0ed35b98b345218d9aa8ac5a3ad6b");
|
||||
private static GUID s_UIEffectHlslGuid => new GUID("5109b2ad9b8be459592190a5678464e3");
|
||||
private static string s_UIEffectHlsl => AssetDatabase.GUIDToAssetPath(s_UIEffectHlslGuid.ToString());
|
||||
|
||||
[MenuItem("Assets/Create/Shader Graph/URP/Canvas Shader Graph (UIEffect)", priority = 1000)]
|
||||
private static void CreateUnlitGraph()
|
||||
{
|
||||
@@ -18,7 +23,14 @@ namespace UnityEditor.Rendering.Universal.ShaderGraph
|
||||
public UniversalUIEffectSubTarget() { displayName = "Canvas (UIEffect)"; }
|
||||
|
||||
protected override IncludeCollection postgraphIncludes => base.postgraphIncludes
|
||||
.Add(BuiltInUIEffectSubTarget.s_UIEffectHlsl, IncludeLocation.Postgraph);
|
||||
.Add(s_UIEffectHlsl, IncludeLocation.Postgraph);
|
||||
|
||||
public override void Setup(ref TargetSetupContext context)
|
||||
{
|
||||
base.Setup(ref context);
|
||||
context.AddAssetDependency(s_UIEffectHlslGuid, AssetCollection.Flags.SourceDependency);
|
||||
context.AddAssetDependency(s_UIEffectCgincGuid, AssetCollection.Flags.SourceDependency);
|
||||
}
|
||||
|
||||
public override PassDescriptor GenerateUIPassDescriptor(bool isSRP)
|
||||
{
|
||||
|
||||
+3
-3
@@ -61,11 +61,11 @@ SubShader {
|
||||
#pragma shader_feature_local_fragment _ TONE_GRAYSCALE TONE_SEPIA TONE_NEGATIVE TONE_RETRO TONE_POSTERIZE
|
||||
#pragma shader_feature_local_fragment _ COLOR_FILTER
|
||||
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN TRANSITION_PATTERN
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN TRANSITION_PATTERN TRANSITION_BLAZE
|
||||
#pragma shader_feature_local_fragment _ EDGE_PLAIN EDGE_SHINY
|
||||
#pragma shader_feature_local_fragment _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_SUBTRACTIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.7.0 (Unity 6)
|
||||
userData: v5.9.0 (Unity 6)
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+3
-3
@@ -60,11 +60,11 @@ SubShader{
|
||||
#pragma shader_feature_local_fragment _ TONE_GRAYSCALE TONE_SEPIA TONE_NEGATIVE TONE_RETRO TONE_POSTERIZE
|
||||
#pragma shader_feature_local_fragment _ COLOR_FILTER
|
||||
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN TRANSITION_PATTERN
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN TRANSITION_PATTERN TRANSITION_BLAZE
|
||||
#pragma shader_feature_local_fragment _ EDGE_PLAIN EDGE_SHINY
|
||||
#pragma shader_feature_local_fragment _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_SUBTRACTIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user