선택된 객체 Undo 이후 대상이 없는 상태에서 복사 시 오류, Undo, Redo 연속 실행 #219

Merged
UVCXR merged 1 commits from pgd/20250718_2 into main 2025-07-21 09:20:39 +09:00
3 changed files with 67 additions and 17 deletions

View File

@@ -45,7 +45,7 @@ namespace Studio.Command
var renderObjectHandler = ManagerHub.instance.Get<RenderObjectHandler>(); var renderObjectHandler = ManagerHub.instance.Get<RenderObjectHandler>();
renderObjectHandler.rtgController.SetGizmoTargetObjects(new List<GameObject>()); renderObjectHandler.rtgController.SetGizmoTargetObjects(new List<GameObject>());
renderObjectHandler.DeselectAll();
} }
} }

View File

@@ -143,6 +143,8 @@ namespace Studio.Command
canvas.panel_dynamicobjectinfo.ResetObjectInfo(); canvas.panel_dynamicobjectinfo.ResetObjectInfo();
//connector.onRemoveObjects?.Invoke(); //connector.onRemoveObjects?.Invoke();
connector.componentScrollView.DeselectAll(); connector.componentScrollView.DeselectAll();
var renderObjectHandler = ManagerHub.instance.Get<RenderObjectHandler>();
renderObjectHandler.DeselectAll();
} }
} }

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using TMPro; using TMPro;
using UnityEditor.ShortcutManagement;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using XRLib; using XRLib;
@@ -14,9 +15,20 @@ namespace Studio.Manage
Dictionary<KeyCode, Action> upKeyActionTable = new Dictionary<KeyCode, Action>(); Dictionary<KeyCode, Action> upKeyActionTable = new Dictionary<KeyCode, Action>();
Dictionary<KeyCode, Action> downKeyActionTable = new Dictionary<KeyCode, Action>(); Dictionary<KeyCode, Action> downKeyActionTable = new Dictionary<KeyCode, Action>();
Dictionary<KeyCode, Dictionary<KeyCode, Action>> shortCutActionTable = new(); Dictionary<KeyCode, Dictionary<KeyCode, Action>> shortCutActionTable = new();
Dictionary<string, ShortcutState> shortcutStateTable = new Dictionary<string, ShortcutState>();
float shortCutInitialDelay = 0.5f;
float shortCutRepeatDelay = 0.1f;
Stack<InputHandler> handlerStack = new(); Stack<InputHandler> handlerStack = new();
Action updateLoop; Action updateLoop;
private class ShortcutState
{
public float pressStartTime = -1f;
public float lastActionTime = -1f;
}
public void SetHandler(InputHandler handler) public void SetHandler(InputHandler handler)
{ {
SetKeyboardPreset(handler); SetKeyboardPreset(handler);
@@ -143,18 +155,53 @@ namespace Studio.Manage
{ {
foreach (var k in kk) foreach (var k in kk)
{ {
if (Input.GetKeyDown(k.Key)) string inputKeystring = key + "+" + k.Key;
bool bothKeyPressed = Input.GetKey(k.Key);
if (!shortcutStateTable.TryGetValue(inputKeystring, out var state))
{
state = new ShortcutState();
shortcutStateTable[inputKeystring] = state;
}
if (bothKeyPressed)
{
float curTime = Time.time;
if (state.pressStartTime < 0f)
{
state.pressStartTime = curTime;
state.lastActionTime = -1f;
}
if (state.lastActionTime < 0f)
{ {
k.Value?.Invoke(); k.Value?.Invoke();
state.lastActionTime = curTime;
} }
} else
} {
} float holdTime = curTime - state.pressStartTime;
} float sinceLastAction = curTime - state.lastActionTime;
if (holdTime >= shortCutInitialDelay && sinceLastAction >= shortCutRepeatDelay)
{
k.Value?.Invoke();
state.lastActionTime = curTime;
}
}
}
else
{
state.pressStartTime = -1f;
state.lastActionTime = -1f;
}
}
}
}
}
updateLoop?.Invoke(); updateLoop?.Invoke();
} }
bool IsEditInputField() bool IsEditInputField()
{ {
GameObject selectedObj = EventSystem.current.currentSelectedGameObject; GameObject selectedObj = EventSystem.current.currentSelectedGameObject;
@@ -165,4 +212,5 @@ namespace Studio.Manage
return selectedObj.GetComponent<TMP_InputField>() != null; return selectedObj.GetComponent<TMP_InputField>() != null;
} }
} }
} }