LaboratoryProtection/Assets/UnityTest/ZXL/Scripts/UI/Help/GoSetActive.cs

35 lines
791 B
C#
Raw Normal View History

2023-10-07 14:49:38 +08:00
using System;
using Mono.Event;
using UnityEngine;
namespace UnityTest.ZXL
{
public class GoSetActive : MonoBehaviour
{
[SerializeField] private GoType _goType;
private void Awake()
{
EventManager.Instance.Subscribe(GoSetActiveEventArgs.EventId, GoSetActiveEvent);
}
private void OnDestroy()
{
EventManager.Instance.Unsubscribe(GoSetActiveEventArgs.EventId, GoSetActiveEvent);
}
private void GoSetActiveEvent(object sender, GameEventArgs e)
{
var args = e as GoSetActiveEventArgs;
if (_goType == args.goType)
{
gameObject.SetActive(args.isShow);
}
}
}
public enum GoType
{
UI_BG,
}
}