1
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user