yasirkula / UnityIngameDebugConsole

A uGUI based console to see debug messages and execute commands during gameplay in Unity
MIT License
2.11k stars 221 forks source link

Can't enter commands when in an FPS #14

Closed brainwipe closed 4 years ago

brainwipe commented 4 years ago

In first person, the cursor mode is locked:

Cursor.lockState = CursorLockMode.Locked

So the input field cannot be clicked on to gain focus.

One solution is to force the focus when the log window is shown:

public void ShowLogWindow()
{
    // snip for brevity
   if (Cursor.lockState == CursorLockMode.Locked)
   {
      commandInputField.ActivateInputField();
   }
}

If you're happy with this fix, I'll raise a PR.

Thanks for a great asset!

yasirkula commented 4 years ago

Activating the input field will prompt the on-screen keyboard on mobile devices each time the log window is shown, which may not be preferable. We can easily fix this issue by wrapping this code in #if UNITY_EDITOR || UNITY_STANDALONE and #endif directives; still, I'm not sure how this will behave on laptops with touchscreens. I think it is better to keep things as is; developers may modify the code as you suggested if necessary.

brainwipe commented 4 years ago

Cool, that makes sense.