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().OnButtonPressed += OnClicked; private void OnClicked() => windowToClose.Close(); private void OnValidate() { if(windowToClose != null) return; windowToClose = GetComponentInParent(); } } }