Hey there,
After seeing various videos of people starting up my game, I came to discover that for pretty much everyone Unity’s default configuration window (in which you select a resolution and are able to bind the game’s controls) is spawned behind the Steam window. Users have to either Alt + Tab their way to the game, or click on the icon in the taskbar.
I’ve crawled the internet, the Steam forums, and the Unity forums, but nobody seems to have even mentioned this issue anywhere online. I just posted to a developer mailing and found that many of the devs saw the same issue and thought it only had something to do with their own computer.
All Unity games who have the configuration window enabled suffer from this issue. Has anyone been able to fix this? Is this a bug in Steam or in Unity?
We had this problem launching from Steam on both Windows and OSX until we stopped using the configuration window - we never found another solution, sorry.
After disabling the configuration window, launching via Windows Steam is fine but our app still doesn’t get focus correctly on OSX, so we run an external process to request focus from the OS during launch (an async process calls osascript -e ‘activate application “OurAppName”’) but we know other devs who wrote a native plugin to handle it.
Another note, we experienced the Steam overlay rendering inside the configuration window as well which obscured options and caused other problems. If you’re not seeing this then you’re doing slightly better than we did.
Some installations we run standalone on Windows also have focus issues but that’s more related to the default Windows registry settings not allowing the task switch automatically when launched from startup items or other automation. There is a registry setting you can edit to allow it (HKEY_CURRENT_USER/Control Panel/Desktop/ForegroundLockTimeout = 0). For these apps we also use some Windows calls to request focus at launch but like the OSX fix above, these won’t help you if you need the configuration window to get focus before your main app runs. It would be handy if there was an Application api call to request focus from the system.
I was having trouble with the game not receiving window focus on Mac when launched from Steam and this conversation came up in the first page of the results. Thanks to greg-harding for mentioning the osascript trick, it seems to work so far.
It other stumble on this conversation, here is the code I’m using:
#if UNITY_STANDALONE_OSX
// hack to give focus to our app because when launched from steam it doesn’t get it.
// Unity's configuration window launches -behind- Steam window - Unity Engine - Unity Discussions
// osascript -e ‘activate application “OurAppName”’
System.Diagnostics.Process.Start(“osascript”, “-e ‘activate application "OurAppName"’”);
#endif
In the meantime, I found the actual solution to this problem! Instead of directing Steams executable to the binary inside of the app, direct Steam to the .app!
Interesting - we’re linking to the ‘myapp.app/Contents/MacOS/myapp’. I’ll check if changing that to just the .app has any effect sometime.
Hey Greg - sorry for the blast from the past - but did you ever give this a go?
hey, I don’t think I updated our older game Element (it was working, ended up leaving it alone!) but our latest game Monster Racing League on Steam just links to the .app and doesn’t seem to have any focus issues.