Files
Studio/Assets/Scripts/Studio/Managers/CommandHub.cs
2025-06-18 17:10:57 +09:00

58 lines
1.6 KiB
C#

using Studio.AssetTool;
using Studio.Core;
using Studio.Manage;
using Studio.Services;
using System.Collections.Generic;
using System.Windows.Input;
using UnityEngine;
using XRLib.Collections;
namespace Studio.Command
{
public class CommandHub : UnitySingleton<CommandHub>
{
public HashSet<ICommand> commands = new HashSet<ICommand>();
public void Init()
{
Join(new ActivateMoveGizmoCommand());
Join(new ActivateRotateGizmoCommand());
Join(new ActivateScaleGizmoCommand());
Join(new ResetGizmoCommand());
Join(new CopyObjectCommand());
Join(new RemoveAllObjectCommand());
Join(new RemoveSelectObjectCommand());
Join(new NewProjectCommand());
Join(new OpenProjectCommand());
Join(new SaveAndNewProjectCommand());
Join(new SaveAndOpenProjectCommand());
Join(new SaveProjectCommand());
Join(new TopMenuNewProjectCommand());
Join(new TopMenuOpenProjectCommand());
Join(new CreateConnectedAssetCommand());
Join(new ExitProgramCommand());
}
void Join(ICommand newCommand)
{
if (!commands.Add(newCommand))
{
Debug.LogError($"Command {newCommand} already exists in the hub.");
}
}
public T Get<T>() where T : ICommand
{
foreach (var c in commands)
{
if (c is T command)
{
return command;
}
}
return default(T);
}
}
}