From dfe91edac109a0911cf96ba5810069595e177d4f Mon Sep 17 00:00:00 2001 From: mob-sakai <12690315+mob-sakai@users.noreply.github.com> Date: Mon, 22 Jun 2026 12:03:03 +0900 Subject: [PATCH] style: fix style --- Assets/Demos/HotUpdate/HotUpdate.cs | 5 + .../Editor/UIEffectProjectSettingsEditor.cs | 20 ++- .../PreloadedProjectSettings.cs | 3 +- .../Utilities/ShaderVariantRegistry.cs | 124 +++++++++++------- Packages/src/Runtime/UIEffectContext.cs | 4 +- Packages/src/Runtime/Utilities/TmpProxy.cs | 3 +- Packages/src/Shaders/UIEffect.cginc | 6 +- Packages/src/Shaders/UIEffect.shader | 3 +- 8 files changed, 102 insertions(+), 66 deletions(-) diff --git a/Assets/Demos/HotUpdate/HotUpdate.cs b/Assets/Demos/HotUpdate/HotUpdate.cs index 0761d7f..2174d18 100644 --- a/Assets/Demos/HotUpdate/HotUpdate.cs +++ b/Assets/Demos/HotUpdate/HotUpdate.cs @@ -24,7 +24,9 @@ public class HotUpdate : MonoBehaviour private void Start() { if (m_ExecuteOnStart) + { Execute(); + } } private void AddLog(string message) @@ -32,7 +34,9 @@ public class HotUpdate : MonoBehaviour Debug.Log(message); _sb.AppendLine(message); if (m_Log) + { m_Log.text = _sb.ToString(); + } } public void Execute() @@ -48,6 +52,7 @@ public class HotUpdate : MonoBehaviour AddLog($"*** Execution is already in progress. Please wait until it completes."); return; } + _co = StartCoroutine(Co_Execute()); } diff --git a/Packages/src/Editor/UIEffectProjectSettingsEditor.cs b/Packages/src/Editor/UIEffectProjectSettingsEditor.cs index e67bcc5..b82beda 100644 --- a/Packages/src/Editor/UIEffectProjectSettingsEditor.cs +++ b/Packages/src/Editor/UIEffectProjectSettingsEditor.cs @@ -48,6 +48,13 @@ namespace Coffee.UIEffects.Editors x => !UIEffectProjectSettings.instance.m_RuntimePresetsV2.Contains(x.preset), UIEffectProjectSettings.RegisterRuntimePreset); }; + + _shaderVariantRegistryEditor = ShaderVariantRegistryEditor.Create(serializedObject, "(UIEffect)", + () => + { + UIEffectProjectSettings.shaderRegistry + .RegisterOptionalShaders(UIEffectProjectSettings.instance); + }); } public override void OnInspectorGUI() @@ -70,22 +77,11 @@ namespace Coffee.UIEffects.Editors // Shader registry EditorGUILayout.Space(); EditorGUILayout.LabelField("Shader", EditorStyles.boldLabel); - if (_shaderVariantRegistryEditor == null) - { - var property = serializedObject.FindProperty("m_ShaderVariantRegistry"); - _shaderVariantRegistryEditor = new ShaderVariantRegistryEditor(property, "(UIEffect)", - () => - { - UIEffectProjectSettings.shaderRegistry - .RegisterOptionalShaders(UIEffectProjectSettings.instance); - }); - } - _shaderVariantRegistryEditor.Draw(); DrawPreLoadSettingsInBuild("UIEffect"); - serializedObject.ApplyModifiedProperties(); + GUILayout.FlexibleSpace(); } private void DrawLegacyPresets() diff --git a/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs b/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs index 0955264..835cb57 100644 --- a/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs +++ b/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs @@ -15,8 +15,7 @@ namespace Coffee.UIEffectInternal #if UNITY_EDITOR { [Tooltip("When enabled, this settings asset will be added to PlayerSettings.preloadedAssets in build.\n\n" + - "When disable, you should load this settings via Resources, AssetBundles or " + - "Addressables to use UIEffect.")] + "When disable, you should load this settings via Resources, AssetBundles or Addressables to use.")] [SerializeField] [Header("Advanced")] [HideInInspector] diff --git a/Packages/src/Runtime/Internal/Utilities/ShaderVariantRegistry.cs b/Packages/src/Runtime/Internal/Utilities/ShaderVariantRegistry.cs index d8a8ad4..55f228a 100644 --- a/Packages/src/Runtime/Internal/Utilities/ShaderVariantRegistry.cs +++ b/Packages/src/Runtime/Internal/Utilities/ShaderVariantRegistry.cs @@ -398,7 +398,30 @@ namespace Coffee.UIEffectInternal private bool _expandOptionalShaders; private bool _expandUnregisteredVariants; - public ShaderVariantRegistryEditor(SerializedProperty property, string optionName, Action onFindOptions) + public static ShaderVariantRegistryEditor CreateWithoutOption(SerializedObject so) + { + var property = so.FindProperty("m_ShaderVariantRegistry"); + return new ShaderVariantRegistryEditor(property, null, null); + } + + public static ShaderVariantRegistryEditor CreateWithoutOption(SerializedProperty property) + { + return new ShaderVariantRegistryEditor(property, null, null); + } + + public static ShaderVariantRegistryEditor Create(SerializedObject so, string optionName, Action onFindOptions) + { + var property = so.FindProperty("m_ShaderVariantRegistry"); + return new ShaderVariantRegistryEditor(property, optionName, onFindOptions); + } + + public static ShaderVariantRegistryEditor Create(SerializedProperty property, string optionName, + Action onFindOptions) + { + return new ShaderVariantRegistryEditor(property, optionName, onFindOptions); + } + + private ShaderVariantRegistryEditor(SerializedProperty property, string optionName, Action onFindOptions) { var so = property.serializedObject; var optionalShaders = property.FindPropertyRelative("m_OptionalShaders"); @@ -406,6 +429,54 @@ namespace Coffee.UIEffectInternal _errorOnUnregisteredVariant = property.FindPropertyRelative("m_ErrorOnUnregisteredVariant"); _asset = property.FindPropertyRelative("m_Asset"); + _rlUnregisteredVariants = new ReorderableList(so, unregisteredVariants, false, true, false, true); + _rlUnregisteredVariants.drawHeaderCallback = rect => + { + var rWarning = new Rect(rect.x, rect.y, 20, rect.height); + var icon = EditorGUIUtility.TrIconContent("warning", + "These variants are not registered.\nRegister them to use in player."); + EditorGUI.LabelField(rWarning, icon); + + var rLabel = new Rect(rect.x + 20, rect.y, 200, rect.height); + EditorGUI.LabelField(rLabel, "Unregistered Shader Variants"); + + var rButton = new Rect(rect.x + rect.width - 60, rect.y, 60, rect.height - 4); + if (GUI.Button(rButton, "Clear All", EditorStyles.miniButton)) + { + unregisteredVariants.ClearArray(); + } + }; + _rlUnregisteredVariants.elementHeight = EditorGUIUtility.singleLineHeight * 2 + 4; + _rlUnregisteredVariants.drawElementCallback = (r, index, isActive, isFocused) => + { + if (unregisteredVariants.arraySize <= index) return; + + var element = unregisteredVariants.GetArrayElementAtIndex(index); + if (element == null) return; + + var key = element.FindPropertyRelative("key"); + var value = element.FindPropertyRelative("value"); + + var h = EditorGUIUtility.singleLineHeight; + var rKey = new Rect(r.x, r.y + 2, r.width, h); + EditorGUI.LabelField(rKey, key.stringValue, EditorStyles.popup); + + var rValue = new Rect(r.x + 20, r.y + h + 5, r.width - 40, 14); + var keywords = string.IsNullOrEmpty(value.stringValue) ? "" : value.stringValue; + EditorGUI.TextField(rValue, GUIContent.none, keywords, "LODRenderersText"); + + var rButton = new Rect(r.x + r.width - 20, r.y + h + 4, 20, h); + if (GUI.Button(rButton, EditorGUIUtility.IconContent("icons/toolbar plus.png"), "iconbutton")) + { + var collection = _asset.objectReferenceValue as ShaderVariantCollection; + AddVariant(collection, key.stringValue, value.stringValue); + unregisteredVariants.DeleteArrayElementAtIndex(index); + } + }; + + // Optional shaders. + if (string.IsNullOrEmpty(optionName)) return; + _rlOptionalShaders = new ReorderableList(so, optionalShaders, true, true, true, true); _rlOptionalShaders.drawHeaderCallback = rect => { @@ -452,56 +523,15 @@ namespace Coffee.UIEffectInternal ShowShaderDropdown(value); } }; - - _rlUnregisteredVariants = new ReorderableList(so, unregisteredVariants, false, true, false, true); - _rlUnregisteredVariants.drawHeaderCallback = rect => - { - var rWarning = new Rect(rect.x, rect.y, 20, rect.height); - var icon = EditorGUIUtility.TrIconContent("warning", - "These variants are not registered.\nRegister them to use in player."); - EditorGUI.LabelField(rWarning, icon); - - var rLabel = new Rect(rect.x + 20, rect.y, 200, rect.height); - EditorGUI.LabelField(rLabel, "Unregistered Shader Variants"); - - var rButton = new Rect(rect.x + rect.width - 60, rect.y, 60, rect.height - 4); - if (GUI.Button(rButton, "Clear All", EditorStyles.miniButton)) - { - unregisteredVariants.ClearArray(); - } - }; - _rlUnregisteredVariants.elementHeight = EditorGUIUtility.singleLineHeight * 2 + 4; - _rlUnregisteredVariants.drawElementCallback = (r, index, isActive, isFocused) => - { - if (unregisteredVariants.arraySize <= index) return; - - var element = unregisteredVariants.GetArrayElementAtIndex(index); - if (element == null) return; - - var key = element.FindPropertyRelative("key"); - var value = element.FindPropertyRelative("value"); - - var h = EditorGUIUtility.singleLineHeight; - var rKey = new Rect(r.x, r.y + 2, r.width, h); - EditorGUI.LabelField(rKey, key.stringValue, EditorStyles.popup); - - var rValue = new Rect(r.x + 20, r.y + h + 5, r.width - 40, 14); - var keywords = string.IsNullOrEmpty(value.stringValue) ? "" : value.stringValue; - EditorGUI.TextField(rValue, GUIContent.none, keywords, "LODRenderersText"); - - var rButton = new Rect(r.x + r.width - 20, r.y + h + 4, 20, h); - if (GUI.Button(rButton, EditorGUIUtility.IconContent("icons/toolbar plus.png"), "iconbutton")) - { - var collection = _asset.objectReferenceValue as ShaderVariantCollection; - AddVariant(collection, key.stringValue, value.stringValue); - unregisteredVariants.DeleteArrayElementAtIndex(index); - } - }; } public void Draw() { - DrawOptionalShaders(ref _expandOptionalShaders, _rlOptionalShaders); + if (_rlOptionalShaders != null) + { + DrawOptionalShaders(ref _expandOptionalShaders, _rlOptionalShaders); + } + DrawRegisteredShaderVariants(ref _expandUnregisteredVariants, _asset, ref _editor); if (0 < _rlUnregisteredVariants.serializedProperty.arraySize) { diff --git a/Packages/src/Runtime/UIEffectContext.cs b/Packages/src/Runtime/UIEffectContext.cs index f3b0ec3..ef2fb86 100644 --- a/Packages/src/Runtime/UIEffectContext.cs +++ b/Packages/src/Runtime/UIEffectContext.cs @@ -527,7 +527,9 @@ namespace Coffee.UIEffects #pragma warning disable CS0612 // Type or member is obsolete || m_GradationMode == GradationMode.RadialDetail #pragma warning restore CS0612 - || m_GradationMode == GradationMode.RadialGradient ? 1 : 0); + || m_GradationMode == GradationMode.RadialGradient + ? 1 + : 0); material.SetFloat(s_DetailIntensity, Mathf.Clamp01(m_DetailIntensity)); material.SetColor(s_DetailColor, ApplyColorSpace(m_DetailColor)); diff --git a/Packages/src/Runtime/Utilities/TmpProxy.cs b/Packages/src/Runtime/Utilities/TmpProxy.cs index b6702c3..cb29dc2 100644 --- a/Packages/src/Runtime/Utilities/TmpProxy.cs +++ b/Packages/src/Runtime/Utilities/TmpProxy.cs @@ -305,7 +305,8 @@ namespace Coffee.UIEffects Misc.QueuePlayerLoopUpdate(); } - private static TMP_SubMeshUI GetSubMeshUI(List subMeshes, Material material, Mesh mesh, int start) + private static TMP_SubMeshUI GetSubMeshUI(List subMeshes, Material material, Mesh mesh, + int start) { var count = subMeshes.Count; if (mesh) diff --git a/Packages/src/Shaders/UIEffect.cginc b/Packages/src/Shaders/UIEffect.cginc index dac01e0..ff49f44 100644 --- a/Packages/src/Shaders/UIEffect.cginc +++ b/Packages/src/Shaders/UIEffect.cginc @@ -82,7 +82,9 @@ uniform const matrix _CanvasToWorldMatrix; #endif #ifndef UIEFFECT_FRAG_STRUCT -struct uieffect_v2f{}; +struct uieffect_v2f +{ +}; #define UIEFFECT_FRAG_STRUCT uieffect_v2f #endif @@ -540,7 +542,7 @@ float edge(float2 uv, const float4 uvMask, float width) e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(0.0, -1.0)), uvMask)).a); e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(0.5, -0.866025)), uvMask)).a); e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(0.866025, -0.5)), uvMask)).a); - + return 1 - inv_lerp(0.15, 0.3, e); #else return 0; diff --git a/Packages/src/Shaders/UIEffect.shader b/Packages/src/Shaders/UIEffect.shader index 4c0baf6..fe84268 100644 --- a/Packages/src/Shaders/UIEffect.shader +++ b/Packages/src/Shaders/UIEffect.shader @@ -156,6 +156,7 @@ Shader "Hidden/UI/Default (UIEffect)" color.rgb *= color.a; return color; } + #define UIEFFECT_FRAG_STRUCT v2f #include "Packages/com.coffee.ui-effect/Shaders/UIEffect.cginc" // ==== UIEFFECT END ==== @@ -186,7 +187,7 @@ Shader "Hidden/UI/Default (UIEffect)" // ==== SOFTMASKABLE END ==== #ifdef UNITY_UI_ALPHACLIP - clip (c.a - 0.001); + clip(c.a - 0.001); #endif return c;