UserInputManager 수정
This commit is contained in:
37
Assets/Scripts/Studio/Managers/UpdateRunner.cs
Normal file
37
Assets/Scripts/Studio/Managers/UpdateRunner.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Studio/Managers/UpdateRunner.cs.meta
Normal file
2
Assets/Scripts/Studio/Managers/UpdateRunner.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40294507f68cc2942b2bef179e37eb08
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user