yasirkula / UnityIngameDebugConsole

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

Clear EventSystem's current selection when the console window is hidden #85

Closed emredesu closed 1 year ago

emredesu commented 1 year ago

... because it causes a lot of unintended behaviour, especially on mobile devices.

As the console window's GameObject is not disabled when the console window is not closed, the EventSystem still keeps the last selected item in the console window as its selected item, as can be seen on the screenshot below.

Untitled

This causes some key presses to cause weird behaviour. Especially on mobile (Android), I had the system keyboard randomly pop up during gameplay, because even though the command InputField was hidden, the EventSystem still considered it selected, which caused my "jump" button (gamepad south button, which also happens to be the "Confirm" button in Unity's default EventSystem controls) to be opened.

yasirkula commented 1 year ago

It makes sense. But instead of creating a new function, please inline the new code and follow the same coding style there (also CRLF and tabs must be used). A little more context in the comment is also appreciated so that people can understand why the call is necessary. A link to this pull request in the comment would be very helpful in that regard.

yasirkula commented 1 year ago

I think something is wrong with line endings because the whole file is marked as dirty now. I wonder if the file's line endings weren't CRLF to begin with. Either that or the current line endings aren't CRLF, I'm not sure which.

emredesu commented 1 year ago

Upon further inspection, I am seeing that the original file has LF line endings (could be caused by having git config --global core.autocrlf true which automatically converts line endings to LF), which is causing the diff problem. I can convert the commit to LF to fix the diff or you could merge this to convert it back to CRLF, though it seems like the rest of the project also uses LF line endings so that could be a bad idea.

yasirkula commented 1 year ago

Converting it back to LF to minimize the diff seems like the best option, thank you for the detailed explanation.

emredesu commented 1 year ago

image

Seems to have fixed it 👍

yasirkula commented 1 year ago

Thanks!