Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Checking if an input field is focused

$
0
0
I know you can check if an input field is selected by the EventSystem with:
Code (csharp):
  1. public static bool IsInputFieldFocused()
  2. {
  3.     GameObject obj = EventSystem.current.currentSelectedGameObject;
  4.     return (obj != null && obj.GetComponent<InputField>() != null);
  5. }
This method isn't perfect though since the EventSystem will still consider the input field to be selected even after hitting enter/submitting it. This issue can become annoying for something like a chat box where you ignore game...

Checking if an input field is focused

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>