Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by Ezzerland · Jun 12, 2010 at 08:20 PM · javascriptpauseminimize

Detect when user minimizes application

Hey all, I was just trying to figure out how we can detect when a user has minimized the application (say, via alt+tab).

Here's what I'm trying to do. When the user minimizes the game, I'd like it to automatically pull up the escape menu I've created. I don't want the game to pause, I just want the escape menu to open. Is there a certain command that determines when the user has taken focus off of the game?

btw - This can be answered for Javascript or C#, either or both would be awesome!

Thanks,

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image qJake · Jun 12, 2010 at 08:52 PM 0
Share

There is no function to deter$$anonymous$$e this, since that's strictly a Windows problem (Something similar exists on $$anonymous$$ac, but it's a little different, and you can never "$$anonymous$$imize" a webplayer game). You would need to write a C++ plugin (Which requires Unity Pro) in order to detect when the application window has lost focus (either through alt+tab or some other means).

avatar image Ezzerland · Jun 12, 2010 at 10:03 PM 0
Share

It's not a web-player game, it's a stand-alone application. Unity has a built in function that when focus is taken off the game it automatically pauses it or leaves it running if I wish, I was hoping I could simply alter this function to do as i wish above.

See: http://unity3d.com/support/documentation/ScriptReference/Application-runInBackground.html

avatar image qJake · Jun 13, 2010 at 02:30 AM 0
Share

Yes, I know about that function, but you can't access how it deter$$anonymous$$es if the game is in the background or not, nor can you just... change what it does (APIs don't work like that). Like I said, you need to write a C++ plugin if you want to deter$$anonymous$$e when your game has lost focus or not.

avatar image fherbst · Jun 13, 2010 at 10:45 AM 0
Share

$$anonymous$$aybe there are differences what functions (Events, Updates, ...) are called in the last frame the application has focus? $$anonymous$$aybe coroutines aren't paused the same way as the normal execution loop? Here is the calling order: http://forum.unity3d.com/viewtopic.php?t=2719 ... Just some thoughts, I haven't tried it out.

avatar image Ezzerland · Jun 15, 2010 at 08:46 PM 0
Share

I'm wondering if I can manipulate the auto-mated pause to try and get the game to detect when it's been paused, and have it un-pause and open the desired menu ins$$anonymous$$d. I'll fiddle with this myself and if either solution is plausible, I'll post my findings.

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by lathomas64 · Jul 07, 2010 at 06:42 PM

what if you create a screen-wide transparent gui element and use OnMouseExit to pull up your escape menu.

http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnMouseExit.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by googler · Jul 23, 2013 at 01:39 PM

The same problem. OnApplicationFocus detects minimizing only on Windows, but I need on Mac too.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by BobbyDoogle · Jun 14, 2015 at 08:42 PM

Has anything been updated in 5.0+ to support this, I'm looking at the same problem now.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

properly handling pause functionality with javascript/unityscript? 3 Answers

I am creating a pause button and when I click it the score keeps rising. How can I stop it? 1 Answer

A Proper Way To Pause A Game 9 Answers

show pause menu issues 1 Answer

OnMouseDown not firing 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges