Application.isFocused is incorrect if another program has focus during launch
Steps to reproduce:
Launch your game (or switch to play mode in the editor)
Switch focus on another program before it starts up
Application.isFocused incorrectly reads "true" from here on out until you focus back to the game at least once, then it is proper when defocusing & focusing after that
Can anyone else reproduce this? Is there a workaround?
Answer by shadiradio · Mar 18, 2019 at 08:16 PM
That feeling when you search for an answer to a year-and-a-half-old bug and only find your own post. :(
Answer by Saishy · Sep 11, 2018 at 06:30 AM
Reproduced on Windows 10, Unity 2018.2.5f1
Awake() correctly detects Application.isFocused, but Start() always show True.
UnloadTime: 1.174717 ms
Awake: Application is focused: False
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
TinyBirdUtils.TinyLogger:Log(Object, Object) (at D:\GameDev\Unity\Toranneko\Assets\Scripts\TinyLogger.cs:20)
GameManager:Awake() (at D:\GameDev\Unity\Toranneko\Assets\Scripts\GameManager.cs:19)
(Filename: D:/GameDev/Unity/Toranneko/Assets/Scripts/TinyLogger.cs Line: 20)
Start: Application is focused: True
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
TinyBirdUtils.TinyLogger:Log(Object, Object) (at D:\GameDev\Unity\Toranneko\Assets\Scripts\TinyLogger.cs:20)
GameManager:Start() (at D:\GameDev\Unity\Toranneko\Assets\Scripts\GameManager.cs:36)
(Filename: D:/GameDev/Unity/Toranneko/Assets/Scripts/TinyLogger.cs Line: 20)
Answer by Racines · Jan 20, 2021 at 05:47 PM
This is reproductible with Webgl build and unity 2019.3
Your answer
