119 lines
3.5 KiB
C#
119 lines
3.5 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UVC.Core;
|
|
using UVC.Object3d.Manager;
|
|
using UVC.Studio.Command;
|
|
using UVC.Studio.Config;
|
|
using UVC.Studio.Manager;
|
|
using UVC.Util;
|
|
using UVC.Extention;
|
|
|
|
public class ShortcutConfigurator : MonoBehaviour
|
|
{
|
|
[Inject]
|
|
private Setting? setting;
|
|
|
|
[Inject]
|
|
private StageObjectManager? stageObjectManager;
|
|
|
|
[Inject]
|
|
private SelectionManager? selectionManager;
|
|
|
|
// 단축키 관리자
|
|
public ShortcutManager? shortcutManager;
|
|
|
|
/// <summary>
|
|
/// 단축키 관리자를 설정합니다.
|
|
/// </summary>
|
|
public async void SetupShortcutManager()
|
|
{
|
|
await InjectorAppContext.Instance.WaitForInitializationAsync();
|
|
|
|
selectionManager = InjectorAppContext.Instance.Get<SelectionManager>();
|
|
stageObjectManager = InjectorAppContext.Instance.Get<StageObjectManager>();
|
|
|
|
// StudioShortcutManager 생성 또는 가져오기
|
|
shortcutManager = ShortcutManager.Instance;
|
|
if (shortcutManager == null)
|
|
{
|
|
var go = new GameObject("StudioShortcutManager");
|
|
shortcutManager = go.AddComponent<ShortcutManager>();
|
|
DontDestroyOnLoad(go);
|
|
}
|
|
|
|
// Setting 주입
|
|
Setting? currentSetting = setting;
|
|
if (currentSetting == null && InjectorAppContext.Instance != null)
|
|
{
|
|
currentSetting = InjectorAppContext.Instance.Get<Setting>();
|
|
}
|
|
if (currentSetting != null)
|
|
{
|
|
shortcutManager.SetSetting(currentSetting);
|
|
}
|
|
|
|
// 메뉴 단축키 등록
|
|
RegisterMenuShortcuts();
|
|
|
|
// 도구 단축키 등록
|
|
RegisterToolShortcuts();
|
|
|
|
Debug.Log("[SetupShortcutManager] 단축키 관리자가 설정되었습니다.");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 메뉴 단축키를 등록합니다.
|
|
/// </summary>
|
|
private void RegisterMenuShortcuts()
|
|
{
|
|
if (shortcutManager == null) return;
|
|
|
|
// Edit 메뉴
|
|
shortcutManager.RegisterMenuShortcut("delete", new EditDeleteCommand(selectionManager!, stageObjectManager!));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 도구 단축키를 등록합니다.
|
|
/// </summary>
|
|
private void RegisterToolShortcuts()
|
|
{
|
|
if (shortcutManager == null) return;
|
|
|
|
// 도구 단축키 - SelectionManager를 통해 기즈모 제어
|
|
shortcutManager.RegisterToolShortcut("select", () =>
|
|
{
|
|
if (selectionManager != null) selectionManager.Gizmo.SetActiveTool(TransformToolType.Select);
|
|
});
|
|
|
|
shortcutManager.RegisterToolShortcut("move", () =>
|
|
{
|
|
if (selectionManager != null) selectionManager.Gizmo.SetActiveTool(TransformToolType.Move);
|
|
});
|
|
|
|
shortcutManager.RegisterToolShortcut("rotate", () =>
|
|
{
|
|
if (selectionManager != null) selectionManager.Gizmo.SetActiveTool(TransformToolType.Rotate);
|
|
});
|
|
|
|
shortcutManager.RegisterToolShortcut("scale", () =>
|
|
{
|
|
if (selectionManager != null) selectionManager.Gizmo.SetActiveTool(TransformToolType.Scale);
|
|
});
|
|
|
|
shortcutManager.RegisterToolShortcut("node", () =>
|
|
{
|
|
CursorManager.Instance.SetCursor(CursorType.Node);
|
|
});
|
|
|
|
shortcutManager.RegisterToolShortcut("link", () =>
|
|
{
|
|
CursorManager.Instance.SetCursor(CursorType.Link);
|
|
});
|
|
|
|
shortcutManager.RegisterToolShortcut("arc", () =>
|
|
{
|
|
CursorManager.Instance.SetCursor(CursorType.Arc);
|
|
});
|
|
}
|
|
}
|