UserInputManager 수정

This commit is contained in:
geondo55
2025-04-09 09:10:58 +09:00
parent 57fa1f08b6
commit bc48d7e7e1
3 changed files with 64 additions and 33 deletions

View File

@@ -0,0 +1,37 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using UnityEngine;
using XED.Core;
namespace XED
{
public class UpdateRunner : UnitySingleton<SystemMain>
{
private static List<Action> updateActions = new List<Action>();
public static void AddAction(Action action)
{
if (!updateActions.Contains(action))
{
updateActions.Add(action);
}
}
public static void RemoveAction(Action action)
{
if (updateActions.Contains(action))
{
updateActions.Remove(action);
}
}
void Update()
{
foreach (Action action in updateActions)
{
action?.Invoke();
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 40294507f68cc2942b2bef179e37eb08

View File

@@ -104,63 +104,55 @@ namespace XED.Manage
}
updateLoop += handler.updateLoop;
}
IEnumerator UpdateCoroutine()
void Update()
{
while (true)
foreach (var key in downKeyActionTable.Keys)
{
foreach (var key in downKeyActionTable.Keys)
if (Input.GetKeyDown(key))
{
if (Input.GetKeyDown(key))
{
Debug.Log("1");
downKeyActionTable[key]?.Invoke();
}
downKeyActionTable[key]?.Invoke();
}
}
foreach (var key in getKeyActionTable.Keys)
foreach (var key in getKeyActionTable.Keys)
{
if (Input.GetKey(key))
{
if (Input.GetKey(key))
{
Debug.Log("2");
getKeyActionTable[key]?.Invoke();
}
getKeyActionTable[key]?.Invoke();
}
}
foreach (var key in upKeyActionTable.Keys)
foreach (var key in upKeyActionTable.Keys)
{
if (Input.GetKeyUp(key))
{
if (Input.GetKeyUp(key))
{
Debug.Log("3");
upKeyActionTable[key]?.Invoke();
}
upKeyActionTable[key]?.Invoke();
}
}
foreach (var key in shortCutActionTable.Keys)
foreach (var key in shortCutActionTable.Keys)
{
if (Input.GetKey(key))
{
if (Input.GetKey(key))
if (shortCutActionTable.TryGetValue(key, out var kk))
{
Debug.Log("4");
if (shortCutActionTable.TryGetValue(key, out var kk))
foreach (var k in kk)
{
foreach (var k in kk)
if (Input.GetKeyDown(k.Key))
{
if (Input.GetKeyDown(k.Key))
{
k.Value?.Invoke();
}
k.Value?.Invoke();
}
}
}
}
updateLoop?.Invoke();
yield return null;
}
updateLoop?.Invoke();
}
public override void Init()
{
CoroutineRunner.instance.StartCoroutine(UpdateCoroutine());
UpdateRunner.AddAction(Update);
}
}
}