From 62f39cd591941ed2ab5ff0e5cdfd3a168b6222a4 Mon Sep 17 00:00:00 2001 From: Ding Yuntian <1491671119@qq.com> Date: Tue, 3 Mar 2026 21:46:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=A9=E5=B1=95=20Framework=20?= =?UTF-8?q?=E6=A0=B8=E5=BF=83=E4=BA=8B=E4=BB=B6=E7=B3=BB=E7=BB=9F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- Assets/Scripts/Framework/Core/Core.cs | 11 ++++++++++ .../Framework/EventSystemKit/EventSystemEx.cs | 7 +++++++ .../EventSystemKit/EventTriggerEx.cs | 21 ++++++++++++++----- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Framework/Core/Core.cs b/Assets/Scripts/Framework/Core/Core.cs index d2e3cc10f..7e5f2f0d0 100644 --- a/Assets/Scripts/Framework/Core/Core.cs +++ b/Assets/Scripts/Framework/Core/Core.cs @@ -45,6 +45,12 @@ namespace AibisDream.Framework _instances[key] = instance; } + public void RegisterByInstance(object instance) + { + var key = instance.GetType(); + _instances[key] = instance; + } + public T Get() where T : class { var key = typeof(T); @@ -76,6 +82,11 @@ namespace AibisDream.Framework } public void Clear() => _instances.Clear(); + + public Type[] Keys() + { + return _instances.Keys.ToArray(); + } } public class DataContainer diff --git a/Assets/Scripts/Framework/EventSystemKit/EventSystemEx.cs b/Assets/Scripts/Framework/EventSystemKit/EventSystemEx.cs index 646e9fed3..c965ccb2b 100644 --- a/Assets/Scripts/Framework/EventSystemKit/EventSystemEx.cs +++ b/Assets/Scripts/Framework/EventSystemKit/EventSystemEx.cs @@ -81,6 +81,13 @@ namespace AibisDream.Framework } } + public void UnRegister(IInteraction interaction) + { + pointerOverObjList.Remove(interaction.GetGameObject()); + draggingObjList.Remove(interaction.GetGameObject()); + holdingObjList.Remove(interaction.GetGameObject()); + } + #endregion private void HandleDialogueComplete() diff --git a/Assets/Scripts/Framework/EventSystemKit/EventTriggerEx.cs b/Assets/Scripts/Framework/EventSystemKit/EventTriggerEx.cs index 3e97f3ec8..915231e70 100644 --- a/Assets/Scripts/Framework/EventSystemKit/EventTriggerEx.cs +++ b/Assets/Scripts/Framework/EventSystemKit/EventTriggerEx.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using UnityEngine; using UnityEngine.Events; using UnityEngine.EventSystems; @@ -109,8 +109,11 @@ namespace AibisDream.Framework public override void OnDrag(PointerEventData eventData) { - EventSystemEx.Instance.OnDrag(_interaction); - base.OnDrag(eventData); + if (_interaction.IsAvailable && !EventSystemEx.Instance.isLocked) + { + EventSystemEx.Instance.OnDrag(_interaction); + base.OnDrag(eventData); + } } public override void OnEndDrag(PointerEventData eventData) @@ -121,8 +124,11 @@ namespace AibisDream.Framework public override void OnBeginDrag(PointerEventData eventData) { - EventSystemEx.Instance.OnEndDrag(_interaction); - base.OnBeginDrag(eventData); + if (_interaction.IsAvailable && !EventSystemEx.Instance.isLocked) + { + EventSystemEx.Instance.OnEndDrag(_interaction); + base.OnBeginDrag(eventData); + } } public override void OnPointerClick(PointerEventData eventData) @@ -130,6 +136,11 @@ namespace AibisDream.Framework // EventSystemEx.Instance.OnPointerClick(_interaction); base.OnPointerClick(eventData); } + + void OnDestroy() + { + EventSystemEx.Instance.UnRegister(_interaction); + } } public interface IInteraction