using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.EventSystems;
[RequireComponent(typeof(UIElementMouseCapturer))]
[RequireComponent(typeof(UIElementDragger))]
[RequireComponent(typeof(Image))]
public class UIWindow : MonoBehaviour
{
// Window title
[SerializeField]
private string windowTitle = "Window";
// Close button
private GameObject closeButton;
[SerializeField]
private CloseButtonCallback closeButtonCallback;
[Serializable]
private enum CloseButtonCallback
{
CLOSE_WINDOW,
TOGGLE_WINDOW
}
// IsOpen property
private bool isOpen;
private void OnEnable() { isOpen = true; }
private void OnDisable() { isOpen = false; }
public void ToggleWindow()
{
gameObject.SetActive(!gameObject.activeSelf);
}
public void CloseWindow()
{
Destroy(gameObject);
isOpen = false;
}
///
/// Called when the UIWindow component is created in the editor
/// We will use it to configure the image component
///
private void Reset()
{
// 18 16 28 125
GetComponent().color = new Color32(18, 16, 28, 125);
}
public virtual void Start()
{
isOpen = gameObject.activeSelf;
CreateCloseButton();
CreateWindowTitle();
if (closeButtonCallback == CloseButtonCallback.CLOSE_WINDOW)
closeButton.AddComponent