feat: 扩展 Framework 核心事件系统功能
Made-with: Cursor
This commit is contained in:
@@ -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<T>() 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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user