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

Fix console text input recording keypresses when minimised with hotkey #29

Closed MickWPM closed 3 years ago

MickWPM commented 3 years ago

When using the hotkey to hide the console the command input field continues capturing input (including ENTER which will submit the text for action). When opening it again it will have the junk captured and the show/hide hotkey character as appliable.

This fix disables the command input field when hidden and clears the text in the input field and reenables it when toggled open (clearing text could also be a toggleable option).

MickWPM commented 3 years ago

Fix for reported bug https://github.com/yasirkula/UnityIngameDebugConsole/issues/30

MickWPM commented 3 years ago

As per comment in report: Note this clears the console text input on open/closing to remove the hotkey character input. Downside of this is user is no longer able to type something in the input field, minimise the console, reopen the console and have the initial typed text preserved. This may or may not be desired functionality.

A toggle to clear text on open could be added however additional code would be needed to clear the hotkey character from the input text each time it is closed as the hotkey character would be recieved prior to the console closing.

yasirkula commented 3 years ago

Thank you for the PR and bringing this issue to my attention. I've tried a different approach that lets us preserve the commandInputField's value: https://www.diffchecker.com/i2HPU39n. I'd like to hear your thoughts in case I'm missing something.

MickWPM commented 3 years ago

Yea that looks like a neat approach; wasnt aware of the UI keyboard input being captured in after update. Thats a solid solution to a great tool!

yasirkula commented 3 years ago

Fixed the issue in commit https://github.com/yasirkula/UnityIngameDebugConsole/commit/d4284bfb91b1873affd8eb181d76facd5dfa9d32. Thank you for reviewing my code ^^