perf: Check If Inputs Have Been Listened On
This commit is contained in:
parent
d60537f940
commit
44bee2df08
|
@ -59,17 +59,27 @@ public class KeyboardInputsBehaviour : BehaviourOverride, IKeyboardInputs
|
|||
for (int i = 0; i < cachePressedCurrentlyCount; i++)
|
||||
{
|
||||
Keys currentlyPressedKey = cachePressedCurrently[i];
|
||||
if (!WasPressed(currentlyPressedKey))
|
||||
if (OnPressed.TryGetValue(currentlyPressedKey, out var action))
|
||||
action.Invoke(this, currentlyPressedKey);
|
||||
|
||||
if (!OnPressed.TryGetValue(currentlyPressedKey, out var action))
|
||||
continue;
|
||||
|
||||
if (WasPressed(currentlyPressedKey))
|
||||
continue;
|
||||
|
||||
action.Invoke(this, currentlyPressedKey);
|
||||
}
|
||||
|
||||
for (int i = 0; i < cachePressedPreviouslyCount; i++)
|
||||
{
|
||||
Keys previouslyPressedKey = cachePressedPreviously[i];
|
||||
if (!IsPressed(previouslyPressedKey))
|
||||
if (OnReleased.TryGetValue(previouslyPressedKey, out var action))
|
||||
action.Invoke(this, previouslyPressedKey);
|
||||
|
||||
if (!OnReleased.TryGetValue(previouslyPressedKey, out var action))
|
||||
continue;
|
||||
|
||||
if (IsPressed(previouslyPressedKey))
|
||||
continue;
|
||||
|
||||
action.Invoke(this, previouslyPressedKey);
|
||||
}
|
||||
|
||||
Array.Copy(cachePressedCurrently, cachePressedPreviously, cachePressedCurrentlyCount);
|
||||
|
|
Loading…
Reference in New Issue