23 lines
644 B
C#
23 lines
644 B
C#
using NEG.UI.Window;
|
|
using System;
|
|
using UnityEngine;
|
|
|
|
namespace NEG.UI.UnityUi.Buttons
|
|
{
|
|
[RequireComponent(typeof(BaseButton))]
|
|
public class CloseWindow : MonoBehaviour
|
|
{
|
|
[Header("Set by hand or use editor button")]
|
|
[SerializeField] private MonoWindow windowToClose;
|
|
|
|
private void Awake() => GetComponent<BaseButton>().OnButtonPressed += OnClicked;
|
|
private void OnClicked() => windowToClose.Close();
|
|
|
|
private void OnValidate()
|
|
{
|
|
if(windowToClose != null)
|
|
return;
|
|
windowToClose = GetComponentInParent<MonoWindow>();
|
|
}
|
|
}
|
|
} |