using UnityEngine; using UnityEngine.UIElements; public class BuildingUIController : MonoBehaviour { [Header("UI References")] public UIDocument uiDocument; [Header("Building System")] public NewRoomBuilder roomBuilder; private VisualElement root; private Button wallModeButton; private Button doorModeButton; private Button entranceModeButton; private Button normalModeButton; private Label statusLabel; private Label instructionLabel; public enum BuildingMode { Normal, CreatingWalls, CreatingDoors, CreatingEntrance } private BuildingMode currentMode = BuildingMode.Normal; private void Start() { InitializeUI(); // Check for existing entrances periodically InvokeRepeating(nameof(UpdateEntranceButtonVisibility), 1f, 1f); } private void InitializeUI() { if (uiDocument == null) { uiDocument = GetComponent(); } // Load the UXML file VisualTreeAsset uiAsset = Resources.Load("UI/BuildingInterface"); if (uiAsset == null) { // Try loading from Assets/UI folder uiAsset = UnityEngine.Resources.Load("BuildingInterface"); } if (uiAsset != null) { uiDocument.visualTreeAsset = uiAsset; } else { Debug.LogWarning("BuildingInterface.uxml not found. Creating UI programmatically."); CreateUIManually(); return; } root = uiDocument.rootVisualElement; // Get button references wallModeButton = root.Q