using UnityEngine;
using UnityEngine.UIElements;
using System;
using System.Collections.Generic;
///
/// Runtime Control Panel - Game View에서 ESC로 열고 닫는 컨트롤 패널.
/// SystemController의 서브매니저로 동작하며, UIDocument와 PanelSettings를 자동 생성.
///
[Serializable]
public class RuntimeControlPanelManager
{
[Tooltip("런타임 컨트롤 패널 활성화")]
public bool panelEnabled = true;
private UIDocument uiDocument;
private PanelSettings panelSettings;
private VisualElement root;
private VisualElement panelRoot;
private bool isVisible;
private bool isInitialized;
private Label catTitle;
private Label catDesc;
private ScrollView actionList;
private string currentCategory;
private VisualElement wsDot;
private Label wsValue;
private VisualElement recDot;
private VisualElement optitrackDot;
private Label facialValue;
private VisualElement retargetingDot;
private float lastStatusUpdate;
private const float STATUS_INTERVAL = 0.5f;
private Dictionary catButtons;
private StreamDeckServerManager manager;
private Action log;
private Action logError;
private bool initStarted;
public void Initialize(Transform parent, Action log, Action logError)
{
this.log = log;
this.logError = logError;
if (!panelEnabled) return;
var visualTree = Resources.Load("StreamingleUI/StreamingleControlPanel");
if (visualTree == null)
{
logError("RuntimeControlPanel UXML을 찾을 수 없습니다. (Resources/StreamingleUI/StreamingleControlPanel)");
return;
}
// PanelSettings 생성
panelSettings = ScriptableObject.CreateInstance();
panelSettings.scaleMode = PanelScaleMode.ScaleWithScreenSize;
panelSettings.referenceResolution = new Vector2Int(1920, 1080);
panelSettings.screenMatchMode = PanelScreenMatchMode.MatchWidthOrHeight;
panelSettings.match = 0.5f;
panelSettings.sortingOrder = 100;
// 기본 런타임 테마 설정
SetThemeStyleSheet(panelSettings);
// UI GameObject 생성
var go = new GameObject("RuntimeControlPanel");
go.transform.SetParent(parent);
// UIDocument 설정
uiDocument = go.AddComponent();
uiDocument.panelSettings = panelSettings;
uiDocument.visualTreeAsset = visualTree;
initStarted = true;
log("RuntimeControlPanel 오브젝트 생성 완료, UI 빌드 대기 중...");
}
private void SetupUI()
{
currentCategory = "camera";
catButtons = new Dictionary();
panelRoot = root.Q("panel-root");
catTitle = root.Q