BITFALL/Assets/BITKit/Unity/Scripts/UX/Utils/UXPanelEvent.cs

34 lines
857 B
C#
Raw Normal View History

2023-08-27 02:58:19 +08:00
using System;
2023-06-08 14:09:50 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BITKit;
using UnityEngine.Events;
namespace BITKit.UX
{
2023-08-27 02:58:19 +08:00
/// <summary>
/// 基于<see cref="IUXPanel"/>的面板事件
/// </summary>
public class UXPanelEvent : MonoBehaviour
2023-06-08 14:09:50 +08:00
{
2023-08-27 02:58:19 +08:00
public UnityEvent<bool> onEntryOrExit = new();
public UnityEvent onEntry = new();
public UnityEvent onExit = new();
private void Awake()
2023-06-08 14:09:50 +08:00
{
2023-08-27 02:58:19 +08:00
var panel = GetComponent<IUXPanel>();
panel.OnEntry += OnEntry;
panel.OnExit += OnExit;
2023-06-08 14:09:50 +08:00
}
2023-08-27 02:58:19 +08:00
private void OnExit()
2023-08-12 01:43:24 +08:00
{
2023-08-27 02:58:19 +08:00
onEntryOrExit.Invoke(false);
onExit.Invoke();
}
private void OnEntry()
{
onEntryOrExit.Invoke(true);
onEntry.Invoke();
2023-08-12 01:43:24 +08:00
}
2023-06-08 14:09:50 +08:00
}
}