using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace UI
{
///
/// Automatically sets up a full-screen Canvas and creates a Window on scene start.
/// Attach this component to any GameObject in the scene.
///
public class UIInitializer : MonoBehaviour
{
[Header("Window Settings")]
[SerializeField] private string windowTitle = "Window";
[SerializeField] private Vector2 windowSize = new Vector2(600, 400);
[SerializeField] private Vector2 windowPosition = Vector2.zero;
private void Start()
{
SetupCanvas();
SetupEventSystem();
CreateWindow();
}
///
/// Creates a full-screen Canvas if one doesn't exist
///
private void SetupCanvas()
{
Canvas existingCanvas = FindObjectOfType