Redo 동작 안하는 오류 수정 #179

Merged
Ghost merged 1 commits from pgd/20250625_1 into main 2025-06-25 14:15:48 +09:00
2 changed files with 36 additions and 25 deletions

View File

@@ -99,28 +99,28 @@ namespace RTG
if (!_isEnabled)
return;
if (!Application.isEditor)
{
if (RTInput.GetKeyDown(KeyCode.Z) && RTInput.GetKey(KeyCode.LeftControl))
{
Undo();
}
else if (RTInput.GetKeyDown(KeyCode.Y) && RTInput.GetKey(KeyCode.LeftControl))
{
Redo();
}
return;
}
// Note: When running inside the editor, it seems that we need to add the LSHIFT key into
// the mix. Otherwise, Undo/Redo does not work.
if (GetEditorUndoHotkey())
{
Undo();
}
else if (GetEditorRedoHotkey())
{
Redo();
}
//if (!Application.isEditor)
//{
// if (RTInput.GetKeyDown(KeyCode.Z) && RTInput.GetKey(KeyCode.LeftControl))
// {
// Undo();
// }
// else if (RTInput.GetKeyDown(KeyCode.Y) && RTInput.GetKey(KeyCode.LeftControl))
// {
// Redo();
// }
// return;
//}
//// Note: When running inside the editor, it seems that we need to add the LSHIFT key into
//// the mix. Otherwise, Undo/Redo does not work.
//if (GetEditorUndoHotkey())
//{
// Undo();
//}
//else if (GetEditorRedoHotkey())
//{
// Redo();
//}
}
bool GetEditorUndoHotkey()

View File

@@ -7,12 +7,13 @@ using Studio.Manage;
namespace Studio.Command
{
public class CommandInvoker: IInputHandler
public class CommandInvoker : IInputHandler
{
public static CommandInvoker instance => SystemMain.instance.commandInvoker;
Stack<ICommand> commandStack = new();
Stack<IReversibleCommand> undoableStack = new ();
Stack<IReversibleCommand> undoableStack = new();
Stack<IReversibleCommand> redoableStack = new();
public void Invoke(ICommand command)
{
switch (command)
@@ -33,9 +34,10 @@ namespace Studio.Command
command.Execute();
commandStack.Push(command);
undoableStack.Push(command);
redoableStack.Clear();
}
public void Invoke(IIrreversibleCommand command)
public void Invoke(IIrreversibleCommand command)
{
Debug.Log($"Invoke Irreversible Command={command}");
command.Execute();
@@ -50,12 +52,21 @@ namespace Studio.Command
}
var command = undoableStack.Pop();
command.Undo();
redoableStack.Push(command);
}
public void Redo()
{
if (redoableStack.Count == 0)
{
return;
}
var command = redoableStack.Pop();
command.Execute();
undoableStack.Push(command);
}
public InputHandler GetInputHandler()
{
var shortcutTable = new Dictionary<KeyCode, Dictionary<KeyCode, Action>>();