- Home /
How to determine an initial state for if the game has focus?
According to the answer here you can use MonoBehaviour.OnApplicationFocus(bool) to keep track of whether the game window has focus or not.
However when the example code is used there seems to be a problem case (at least when built with 5.5.0f3). Start the executable and while the Unity logo is displayed click another window or the desktop to remove focus from the game. Since the scene (and the script containing OnApplicationFocus) don't exist yet there is no notification that focus was lost. When the scene does start the script is incorrectly initialized with the assumption that the game does have focus.
Is there a way to correctly initialize this state in code (without user intervention) or an alternative way to determine if the game has focus (even if platform specific)?
Your answer
Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Defocus input line? 0 Answers
Debuggging standalone player, possible to receive input when window loses focus? 0 Answers
Unity loses focus when Oculus display activated 1 Answer
InputField focus on PC vs android 0 Answers