99 lines
4.9 KiB
C#
99 lines
4.9 KiB
C#
#nullable enable
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
using UVC.Core;
|
|
using UVC.Studio.Manager;
|
|
using UVC.UIToolkit;
|
|
using UVC.UIToolkit.Util;
|
|
|
|
namespace UVC.Studio
|
|
{
|
|
/// <summary>UIDocument 타입 충돌 방지용 마커 래퍼 — Static UI Document</summary>
|
|
public sealed class StaticUIDocument { public readonly UIDocument Value; public StaticUIDocument(UIDocument v) { Value = v; } }
|
|
/// <summary>UIDocument 타입 충돌 방지용 마커 래퍼 — Dynamic UI Document</summary>
|
|
public sealed class DynamicUIDocument { public readonly UIDocument Value; public DynamicUIDocument(UIDocument v) { Value = v; } }
|
|
/// <summary>UIDocument 타입 충돌 방지용 마커 래퍼 — Modal UI Document</summary>
|
|
public sealed class ModalUIDocument { public readonly UIDocument Value; public ModalUIDocument(UIDocument v) { Value = v; } }
|
|
|
|
public class StudioSceneContext : InjectorSceneContext
|
|
{
|
|
/// <summary>
|
|
/// StudioSceneContext 인스턴스에 접근하기 위한 편의 프로퍼티
|
|
/// </summary>
|
|
public static new StudioSceneContext? Instance => InjectorSceneContext.Instance as StudioSceneContext;
|
|
|
|
[SerializeField] private GizmoUndoBridge? gizmoUndoBridge;
|
|
[SerializeField] private UndoRedoManager? undoRedoManager;
|
|
[SerializeField] private UIDocument? staticUI;
|
|
[SerializeField] private UIDocument? dynamicUI;
|
|
[SerializeField] private UIDocument? modalUI;
|
|
|
|
/// <summary>
|
|
/// Scene 라이프사이클 서비스들을 등록합니다.
|
|
/// 씬 로드 시 자동 호출되며, 씬 전환 시 자동으로 정리됩니다.
|
|
/// </summary>
|
|
protected override void RegisterSceneServices()
|
|
{
|
|
base.RegisterSceneServices();
|
|
// 여기에 StudioSceneContext에 등록할 서비스들을 추가하세요.
|
|
|
|
Injector.RegisterSingleton<StudioSceneMain>();
|
|
|
|
if(gizmoUndoBridge != null) Injector.RegisterInstance<GizmoUndoBridge>(gizmoUndoBridge, ServiceLifetime.Scene);
|
|
if(undoRedoManager != null) Injector.RegisterInstance<UndoRedoManager>(undoRedoManager, ServiceLifetime.Scene);
|
|
|
|
if(staticUI != null) {
|
|
staticUI.name = "StaticUI";
|
|
|
|
UTKPointerBlocker.Register(staticUI.rootVisualElement);
|
|
|
|
Injector.RegisterInstance(new StaticUIDocument(staticUI), ServiceLifetime.Scene);
|
|
UTKTopMenu? topMenu = staticUI.rootVisualElement.Q<UTKTopMenu>("topMenu");
|
|
if(topMenu != null) {
|
|
Injector.RegisterInstance<UTKTopMenu>(topMenu, ServiceLifetime.Scene);
|
|
}
|
|
UTKToolBar? toolBar = staticUI.rootVisualElement.Q<UTKToolBar>("toolBar");
|
|
if(toolBar != null) {
|
|
Injector.RegisterInstance<UTKToolBar>(toolBar, ServiceLifetime.Scene);
|
|
}
|
|
|
|
UTKPropertyTabListWindow? propertyWindow = staticUI.rootVisualElement.Q<UTKPropertyTabListWindow>("propertyWindow");
|
|
if(propertyWindow != null) {
|
|
Injector.RegisterInstance<UTKPropertyTabListWindow>(propertyWindow, ServiceLifetime.Scene);
|
|
|
|
// StageObjectManager 등록
|
|
var stageObjectManager = new StageObjectManager();
|
|
Injector.RegisterInstance<StageObjectManager>(stageObjectManager);
|
|
|
|
// SelectionManager 등록 (StageObjectManager, PropertyWindow 의존)
|
|
var selectionManager = new SelectionManager(stageObjectManager, propertyWindow);
|
|
Injector.RegisterInstance<SelectionManager>(selectionManager);
|
|
}
|
|
}
|
|
if(dynamicUI != null) {
|
|
dynamicUI.name = "DynamicUI";
|
|
Injector.RegisterInstance(new DynamicUIDocument(dynamicUI), ServiceLifetime.Scene);
|
|
}
|
|
if(modalUI != null) {
|
|
modalUI.name = "ModalUI";
|
|
Injector.RegisterInstance(new ModalUIDocument(modalUI), ServiceLifetime.Scene);
|
|
// 모달 UI를 사용하는 모든 UTK 컴포넌트에 루트 설정 필수
|
|
UTKAlert.SetRoot(modalUI.rootVisualElement);
|
|
UTKColorPicker.SetRoot(modalUI.rootVisualElement);
|
|
UTKDatePicker.SetRoot(modalUI.rootVisualElement);
|
|
UTKModal.SetRoot(modalUI.rootVisualElement);
|
|
UTKNotification.SetRoot(modalUI.rootVisualElement);
|
|
UTKToast.SetRoot(modalUI.rootVisualElement);
|
|
}
|
|
|
|
|
|
var explorerWindow = new UTKTreeListWindow();
|
|
explorerWindow.Title = "Explorer";
|
|
Injector.RegisterInstance<UTKTreeListWindow>(explorerWindow, ServiceLifetime.Scene);
|
|
|
|
var libraryWindow = new UTKAccordionListWindow();
|
|
libraryWindow.Title = "Library";
|
|
Injector.RegisterInstance<UTKAccordionListWindow>(libraryWindow, ServiceLifetime.Scene);
|
|
}
|
|
}
|
|
} |