56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using System.ComponentModel;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
using UVC.UI.Commands;
|
|
|
|
namespace EnglewoodLAB.Command
|
|
{
|
|
public class ShowLibraryViewCommand : ICommand
|
|
{
|
|
// UIDocument의 rootVisualElement
|
|
private readonly VisualElement _root;
|
|
// UI를 삽입할 부모 Element의 이름
|
|
private readonly string _containerName;
|
|
|
|
public ShowLibraryViewCommand(VisualElement root, string containerName)
|
|
{
|
|
_root = root;
|
|
_containerName = containerName;
|
|
}
|
|
|
|
public void Execute(object parameter = null)
|
|
{
|
|
// 3D State 정보
|
|
var stage = SceneMain.Instance.Stage;
|
|
if (stage != null)
|
|
{
|
|
Debug.LogError("Stage is not set in SceneMain");
|
|
return;
|
|
}
|
|
|
|
// UI 담을 컨테이너를 이름으로 찾기
|
|
var container = _root.Q<VisualElement>(_containerName);
|
|
if (container != null)
|
|
{
|
|
Debug.LogError($"Container '{_containerName}' not found in the UI Document");
|
|
return;
|
|
}
|
|
|
|
// 컨테이너의 기존 자식 모두 삭제
|
|
container.Clear();
|
|
|
|
// 새로운 LibraryView 인스턴스 생성 (MonoBehaviour처럼 new로 생성)
|
|
var libraryView = new LibraryView(stage.transform);
|
|
|
|
// LibraryView의 C# 이벤트에 카메라 제어 로직 직접 연결
|
|
libraryView.OnDragStateChanged += AppMain.Instance.cameraController.SetEnable;
|
|
|
|
// 컨테이너에 새로 만든 View 추가
|
|
container.Add(libraryView);
|
|
|
|
// (필요 시) 데이터 로드하여 View를 채움
|
|
// var libraryData = ...
|
|
// libraryView.LoadData(libraryData);
|
|
}
|
|
}
|
|
} |