This commit is contained in:
CortexCore
2023-09-01 14:35:05 +08:00
parent a71288cf2d
commit 5561f5c3cc
136 changed files with 69284 additions and 66121 deletions

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -5,28 +6,29 @@ using BITKit;
using UnityEngine.Events;
namespace BITKit.UX
{
public class UXPanelEvent : MonoBehaviour, IPanelComponent
/// <summary>
/// 基于<see cref="IUXPanel"/>的面板事件
/// </summary>
public class UXPanelEvent : MonoBehaviour
{
public UnityEvent<bool> onSetActive = new();
public UnityEvent onActive = new();
public UnityEvent onInactive = new();
public void SetActive(bool active)
public UnityEvent<bool> onEntryOrExit = new();
public UnityEvent onEntry = new();
public UnityEvent onExit = new();
private void Awake()
{
onSetActive.Invoke(active);
if (active)
{
onActive.Invoke();
}
else
{
onInactive.Invoke();
}
var panel = GetComponent<IUXPanel>();
panel.OnEntry += OnEntry;
panel.OnExit += OnExit;
}
public bool Enabled
private void OnExit()
{
get => enabled;
set => enabled = value;
onEntryOrExit.Invoke(false);
onExit.Invoke();
}
private void OnEntry()
{
onEntryOrExit.Invoke(true);
onEntry.Invoke();
}
}
}