using UnityEngine; using UnityEngine.UIElements; // Changed from UnityEngine.UI using System.Collections; using System; public class BattleUIManager : MonoBehaviour { public static BattleUIManager Instance { get; private set; } [Header("UI Toolkit References")] [Tooltip("Assign the UIDocument component from the scene.")] public UIDocument uiDocument; // UI Toolkit Element references private Button runPauseButtonElement; private Button advanceButtonElement; // Coroutine handle for the advance action private Coroutine advanceCoroutineHandle; void Awake() { if (Instance == null) { Instance = this; } else { Debug.LogWarning("Multiple instances of BattleUIManager found. Destroying this one."); Destroy(gameObject); return; } } void Start() { uiDocument = GetComponent(); if (uiDocument == null) { Debug.LogError("BattleUIManager: UIDocument is not assigned in the Inspector. Please assign it."); SetButtonsInteractable(false); // Attempt to disable if elements were somehow found enabled = false; return; } var rootVisualElement = uiDocument.rootVisualElement; if (rootVisualElement == null) { Debug.LogError("BattleUIManager: UIDocument has no rootVisualElement. Ensure UXML is correctly set up."); enabled = false; return; } // Query for the buttons by their names defined in UXML runPauseButtonElement = rootVisualElement.Q