#if UNITY_EDITOR || DEVELOPMENT_BUILD using System; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; using TMPro; using Unity.Netcode; using Colosseum.Enemy; using Colosseum.Abnormalities; using Colosseum.AI; using Colosseum.Skills; #if UNITY_EDITOR using UnityEditor; #endif namespace Colosseum.UI { /// /// 런타임 디버그 패널 UI. /// 호스트(서버)에서 보스 HP, 페이즈, 보호막 등을 조작할 수 있는 접이식 HUD 패널입니다. /// public class DebugPanelUI : MonoBehaviour { [Header("Abnormality Data (Runtime)")] [Tooltip("기절 이상상태 데이터")] [SerializeField] private AbnormalityData stunAbnormalityData; [Tooltip("침묵 이상상태 데이터")] [SerializeField] private AbnormalityData silenceAbnormalityData; [Header("Settings")] [Tooltip("패널 너비")] [SerializeField] private float panelWidth = 280f; [Tooltip("패널 최대 높이")] [SerializeField] private float panelMaxHeight = 500f; // 보스 캐시 private BossEnemy cachedBoss; private bool suppressSliderCallback; // 스킬 강제 발동 private TMP_Dropdown skillDropdown; private List debugSkillList; private SkillController debugSkillController; private BossEnemy cachedBossForSkillDropdown; // UI 참조 private GameObject toggleButtonObject; private GameObject panelRoot; private bool isPanelOpen; // 보스 HP UI private TMP_Text hpInfoText; private Slider hpSlider; private Image hpSliderFillImage; private TMP_InputField hpInputField; // 보스 제어 UI private TMP_InputField phaseInputField; // 보호막 UI private TMP_InputField shieldAmountField; private void Awake() { BuildUI(); } private void Start() { if (panelRoot != null) panelRoot.SetActive(false); if (UIModeController.Instance != null) UIModeController.Instance.OnUIModeChanged += OnUIModeChanged; } private void OnDestroy() { if (UIModeController.Instance != null) UIModeController.Instance.OnUIModeChanged -= OnUIModeChanged; } private void Update() { RefreshBoss(); if (cachedBoss == null) return; UpdateHPDisplay(); RefreshSkillDropdownIfNeeded(); } /// /// 보스 참조 새로고침 /// private void RefreshBoss() { if (cachedBoss != null && cachedBoss.gameObject.activeInHierarchy) return; cachedBoss = BossEnemy.ActiveBoss; } /// /// 보스 없음 여부 반환 /// private bool NoBoss => cachedBoss == null; /// /// 서버 권한 확인 /// private bool IsHost => NetworkManager.Singleton != null && NetworkManager.Singleton.IsServer; // ────────────────────────────────────────────────── // UI 빌드 // ────────────────────────────────────────────────── /// /// 전체 UI 트리 생성 /// private void BuildUI() { BuildToggleButton(); BuildPanel(); } /// /// 토글 버튼 생성 (우측 하단 고정) /// private void BuildToggleButton() { toggleButtonObject = new GameObject("DebugToggle", typeof(RectTransform), typeof(Image), typeof(Button)); toggleButtonObject.transform.SetParent(transform, false); RectTransform r = toggleButtonObject.GetComponent(); r.anchorMin = new Vector2(1f, 0f); r.anchorMax = new Vector2(1f, 0f); r.pivot = new Vector2(1f, 0f); r.anchoredPosition = new Vector2(-10f, 10f); r.sizeDelta = new Vector2(80f, 36f); toggleButtonObject.GetComponent().color = new Color(0.15f, 0.15f, 0.15f, 0.92f); TMP_Text label = MakeTextChild("Label", toggleButtonObject.transform); label.text = "Debug"; label.fontSize = 16f; label.fontStyle = FontStyles.Bold; label.alignment = TextAlignmentOptions.Center; label.color = new Color(0.8f, 0.8f, 0.8f); toggleButtonObject.GetComponent