- Home /
How to Set Application.isFocused?
Hi,
Application.isFocus is read-only, but I want to set it to always be true. Any ideas?
Thanks!
I don't believe this is possible. Otherwise, the user would not be able to leave your game... Would you want an application impossible to quit?
We have a quit button that quits the application for that.
We need it to always be in focus because of another piece of software that is displaying Unity through Render Textures, that needs the main focus of Windows focus to be displayed, but whenever Unity isn't the main focus, I can no longer move around nor interact with anything.
$$anonymous$$aking this bool always true would allow me to move around and interact normally, unless you know of a better way?
Effectively, all I want to do is remove the isFocused check by Unity.
Thanks.
Answer by Sabre-Runner · Nov 29, 2018 at 10:12 AM
You don't set it. It's read only to tell you whether the application has focus or not. https://docs.unity3d.com/ScriptReference/Application-isFocused.html
Thanks for the input, I gathered as much.
Is there any method of actually telling code that it needs to run regardless of focus?
I have Run in Background on, but the controller stops moving once I take focus away from Unity.
If you're building for mobile you're going to have a hard problem there because every platform handles it differently. If it's a standalone build, Run in Background should be working for testing. $$anonymous$$aybe the problem is in your gamepad interface.
Interesting, fortunately I'm not building for mobile, it's for PC. I'm using the standard Unity FP character sript for movement. Is there something in here that I need to have a look at? Should Unity normally move around okay with Run in Background checked?
Your answer
Follow this Question
Related Questions
Change Bool When Audio Clip Ends C# 1 Answer
Could use some help on making my runaway/chase/follow/patrol script cooperate with each other 1 Answer
What does this mean? 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers