The common solution to this is having some kind of lock that lets up after the player has held down a direction for a certain amount of time (like maybe half a second), at which point the lock lets up and it can start to quickly rake through buttons.
I’ve been trying to set inputActionsPerSecond to 0 but for some it doesn’t work again after I set it back to 20.
bool _rakeLock = false;
public bool RakeLock {
get {
return _rakeLock;
} set {
if (_rakeLock == value) return;
if (value) {
GameManager.standaloneInput.inputActionsPerSecond = 0f;
}
else {
GameManager.standaloneInput.inputActionsPerSecond = 20f;
}
_rakeLock = value;
}
}
In the StandaloneInputModule there is this function:
private bool SendMoveEventToSelectedObject()
{
float time = Time.unscaledTime;
if (!AllowMoveEventProcessing (time))
return false;
Vector2 movement = GetRawMoveVector ();
//Debug.Log(m_ProcessingEvent.rawType + " axis:" + m_AllowAxisEvents + " value:" + "(" + x + "," + y + ")");
var axisEventData = GetAxisEventData (movement.x, movement.y, 0.6f);
if (!Mathf.Approximately (axisEventData.moveVector.x, 0f)
|| !Mathf.Approximately (axisEventData.moveVector.y, 0f))
{
if (m_CurrentInputMode != InputMode.Buttons)
{
// so if we are chaning to keyboard
m_CurrentInputMode = InputMode.Buttons;
// if we are doing a 'fresh selection'
// return as we don't want to do a move.
if (ResetSelection ())
{
m_NextAction = time + 1f / m_InputActionsPerSecond;
return true;
}
}
ExecuteEvents.Execute (eventSystem.currentSelectedObject, axisEventData, ExecuteEvents.moveHandler);
}
m_NextAction = time + 1f / m_InputActionsPerSecond;
return axisEventData.used;
}
This is where we are using the input per second to handle the control lockout. If you want to make your own StandaloneModule that modifies this function then that’s probably the best thing. If you figure out a nice way to do the raking I would love to take the code back into out main branch.
Thanks @Tim-C for pointing me in the right direction. I’m trying to brew something up right now. I want to ask though, when I attempted to make a new module I copied the code from github StandaloneInputModule into my new class and got:
Assets/Scripts/GUI/dw_StandaloneInputModule.cs(333,46): error CS1061: Type `UnityEngine.EventSystems.PointerEventData' does not contain a definition for `pressPositon' and no extension method `pressPositon' of type `UnityEngine.EventSystems.PointerEventData' could be found (are you missing a using directive or an assembly reference?)
pressPositon is actually supposed to be pressPosition. I’m confused. Is the GitHub not the latest one? I have b18.
So I’ve been working on this, and I’m too dense to decipher how the StandaloneInputModule works well enough to implement the raking thing. I got it working but sometimes it would miss your input if you were clicking buttons really quickly which feels terrible. I burned an entire day on it so I decided to give up trying to understand it. I simply made my own module that handles button navigation. I now have two, MouseInputModule which is a stripped down version of Standalone to only handle mouse, and ButtonInputModule which operates at full frame and does its own logic that figures out what button is in the direction you pushed. I’ve attached mouse input one in case anyone is looking for a mouse only (doesn’t even process mouse clicks) module. My button input one is a bit specialized to my game so I don’t think anyone would find it useful.