From 8a6e84cc714f6bce17fe69ed29d172b1ab599cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=80=9D=E6=B5=B7?= <1464576565@qq.com> Date: Mon, 15 Dec 2025 13:42:08 +0800 Subject: [PATCH] fix --- Editor/UX/Button/UXButtonEditor.cs | 1 - Editor/UX/Selectable/UXSelectableEditor.cs | 13 ++++++++++++- Runtime/UXComponent/Selectable/UXSelectable.cs | 3 +-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Editor/UX/Button/UXButtonEditor.cs b/Editor/UX/Button/UXButtonEditor.cs index bb9eafd..3cd4041 100644 --- a/Editor/UX/Button/UXButtonEditor.cs +++ b/Editor/UX/Button/UXButtonEditor.cs @@ -27,7 +27,6 @@ internal class UXButtonEditor : UXSelectableEditor private SerializedProperty m_UXGroup; private SerializedProperty m_ChildTransitions; - private ReorderableList m_ChildTransitionList; private static Color darkZebraEven = new Color(0.22f, 0.22f, 0.22f); diff --git a/Editor/UX/Selectable/UXSelectableEditor.cs b/Editor/UX/Selectable/UXSelectableEditor.cs index 140c559..f256c93 100644 --- a/Editor/UX/Selectable/UXSelectableEditor.cs +++ b/Editor/UX/Selectable/UXSelectableEditor.cs @@ -23,6 +23,7 @@ namespace UnityEngine.UI protected SerializedProperty m_Navigation; protected SerializedProperty m_MainTransition; protected SerializedProperty m_Interactable; + protected SerializedProperty m_animator; // 抽象皮肤(现在放在基类) protected GUISkin customSkin; @@ -53,6 +54,7 @@ namespace UnityEngine.UI m_Navigation = serializedObject.FindProperty("m_Navigation"); m_MainTransition = serializedObject.FindProperty("m_MainTransition"); m_Interactable = serializedObject.FindProperty("m_Interactable"); + m_animator = serializedObject.FindProperty("_animator"); // load customSkin once in base; 调整路径为你项目中 GUISkin 的实际路径(必要时修改) customSkin = AssetDatabase.LoadAssetAtPath("Packages/com.alicizax.unity.ui.extension/Editor/Res/GUISkin/UIExtensionGUISkin.guiskin"); @@ -322,7 +324,16 @@ namespace UnityEngine.UI EditorGUILayout.PropertyField(transition); - var animator = graphic != null ? graphic.GetComponent() : (target as UXSelectable).GetComponent(); + Animator animator = null; + if (target is UXSelectable anima) + { + animator = anima.GetComponent(); + } + else if (m_animator.objectReferenceValue != null) + { + animator = (Animator)m_animator.objectReferenceValue; + } + switch (currentTransition) { case Selectable.Transition.ColorTint: diff --git a/Runtime/UXComponent/Selectable/UXSelectable.cs b/Runtime/UXComponent/Selectable/UXSelectable.cs index 0762dc1..94fa910 100644 --- a/Runtime/UXComponent/Selectable/UXSelectable.cs +++ b/Runtime/UXComponent/Selectable/UXSelectable.cs @@ -57,8 +57,7 @@ namespace UnityEngine.UI protected static int s_SelectableCount = 0; protected int m_CurrentIndex = -1; protected bool m_EnableCalled = false; - - private Animator _animator; + [SerializeField] private Animator _animator; public Animator Animator => _animator ? _animator : _animator = GetComponent(); public static readonly Dictionary _animTriggerCache = new()