From c111cc55b9016f149a5a09c587c78226919af3be Mon Sep 17 00:00:00 2001 From: geondo55 <102933884+geondo55@users.noreply.github.com> Date: Fri, 18 Jul 2025 13:54:55 +0900 Subject: [PATCH] =?UTF-8?q?=EC=84=A0=ED=83=9D=EB=90=9C=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=20Undo=20=EC=9D=B4=ED=9B=84=20=EB=8C=80=EC=83=81?= =?UTF-8?q?=EC=9D=B4=20=EC=97=86=EB=8A=94=20=EC=83=81=ED=83=9C=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=B3=B5=EC=82=AC=20=EC=8B=9C=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?,=20Undo,=20Redo=20=EC=97=B0=EC=86=8D=20=EC=8B=A4=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Command/CreateConnectedAssetCommand.cs | 2 +- .../ObjectCommand/CopyObjectCommand.cs | 2 + .../Studio/Managers/UserInputManager.cs | 80 +++++++++++++++---- 3 files changed, 67 insertions(+), 17 deletions(-) diff --git a/Assets/Scripts/Studio/Command/CreateConnectedAssetCommand.cs b/Assets/Scripts/Studio/Command/CreateConnectedAssetCommand.cs index 017c7893..1fd89489 100644 --- a/Assets/Scripts/Studio/Command/CreateConnectedAssetCommand.cs +++ b/Assets/Scripts/Studio/Command/CreateConnectedAssetCommand.cs @@ -45,7 +45,7 @@ namespace Studio.Command var renderObjectHandler = ManagerHub.instance.Get(); renderObjectHandler.rtgController.SetGizmoTargetObjects(new List()); - + renderObjectHandler.DeselectAll(); } } diff --git a/Assets/Scripts/Studio/Command/ObjectCommand/CopyObjectCommand.cs b/Assets/Scripts/Studio/Command/ObjectCommand/CopyObjectCommand.cs index e65d9a3b..4fce1497 100644 --- a/Assets/Scripts/Studio/Command/ObjectCommand/CopyObjectCommand.cs +++ b/Assets/Scripts/Studio/Command/ObjectCommand/CopyObjectCommand.cs @@ -143,6 +143,8 @@ namespace Studio.Command canvas.panel_dynamicobjectinfo.ResetObjectInfo(); //connector.onRemoveObjects?.Invoke(); connector.componentScrollView.DeselectAll(); + var renderObjectHandler = ManagerHub.instance.Get(); + renderObjectHandler.DeselectAll(); } } diff --git a/Assets/Scripts/Studio/Managers/UserInputManager.cs b/Assets/Scripts/Studio/Managers/UserInputManager.cs index ac5f4d4f..7bc6a984 100644 --- a/Assets/Scripts/Studio/Managers/UserInputManager.cs +++ b/Assets/Scripts/Studio/Managers/UserInputManager.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using TMPro; +using UnityEditor.ShortcutManagement; using UnityEngine; using UnityEngine.EventSystems; using XRLib; @@ -13,10 +14,21 @@ namespace Studio.Manage Dictionary getKeyActionTable = new Dictionary(); Dictionary upKeyActionTable = new Dictionary(); Dictionary downKeyActionTable = new Dictionary(); - Dictionary> shortCutActionTable = new (); + Dictionary> shortCutActionTable = new(); + Dictionary shortcutStateTable = new Dictionary(); + + float shortCutInitialDelay = 0.5f; + float shortCutRepeatDelay = 0.1f; + Stack handlerStack = new(); Action updateLoop; + private class ShortcutState + { + public float pressStartTime = -1f; + public float lastActionTime = -1f; + } + public void SetHandler(InputHandler handler) { SetKeyboardPreset(handler); @@ -34,11 +46,11 @@ namespace Studio.Manage RemoveKeyActionPreset(currentHandler); break; } - + tempStack.Push(currentHandler); } - while(tempStack.Count > 0) + while (tempStack.Count > 0) { var tempHandler = tempStack.Pop(); SetKeyboardPreset(tempHandler); @@ -47,24 +59,24 @@ namespace Studio.Manage void RemoveKeyActionPreset(InputHandler handler) { - foreach(var k in handler.getKeyActions) + foreach (var k in handler.getKeyActions) { getKeyActionTable.Remove(k.Key); } - foreach(var k in handler.upKeyActions) + foreach (var k in handler.upKeyActions) { upKeyActionTable.Remove(k.Key); } - foreach(var k in handler.downKeyActions) + foreach (var k in handler.downKeyActions) { downKeyActionTable.Remove(k.Key); } - foreach(var k in handler.shortCutActions) + foreach (var k in handler.shortCutActions) { - foreach(var kk in k.Value) + foreach (var kk in k.Value) { shortCutActionTable[k.Key].Remove(kk.Key); } @@ -79,14 +91,14 @@ namespace Studio.Manage getKeyActionTable[k.Key] = k.Value; } - foreach(var k in handler.upKeyActions) + foreach (var k in handler.upKeyActions) { - upKeyActionTable[k.Key]= k.Value; + upKeyActionTable[k.Key] = k.Value; } - foreach(var k in handler.downKeyActions) + foreach (var k in handler.downKeyActions) { - downKeyActionTable[k.Key]= k.Value; + downKeyActionTable[k.Key] = k.Value; } foreach (var k in handler.shortCutActions) @@ -143,18 +155,53 @@ namespace Studio.Manage { 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)) { - k.Value?.Invoke(); + 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(); + 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(); } - bool IsEditInputField() { GameObject selectedObj = EventSystem.current.currentSelectedGameObject; @@ -165,4 +212,5 @@ namespace Studio.Manage return selectedObj.GetComponent() != null; } } + }