Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by Zita · Feb 12, 2015 at 11:10 AM · editor

How do I get OnApplicationPause to trigger?

When I run my project in the editor I first get a call to OnApplicationPause with false which seems ok. But when pressing the pause-button in the editor I don't get any call to OnApplicationPause. I expected a call with true this time.

Do I have to have "Run in background" unchecked for this to work?

The problem I'm having with that is that the checkbox keeps check itself whenever I run the project, then go back to unchecked again when I stop it.

I'm using Unity 4.6.2

Comment
Add comment · Show 1
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 hexagonius · Feb 12, 2015 at 11:26 AM 0
Share

I tried this and you're right, it's not called. I recommend you to file a bug report on this (Unity -> Help -> Report a Bug). Seems there was once a "resume" function but is not anymore. $$anonymous$$aybe they screwed something up when they switched to that single function.

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Fattie · Jan 26, 2016 at 01:33 AM

Simply

CLICK ON THE DESKTOP OF YOUR MAC OR PC

it's that simple.

Comment
Add comment · Show 4 · 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 Zardify · Feb 09, 2016 at 05:58 PM 0
Share

Best answer ewur! :D

avatar image ForceMagic · Aug 24, 2016 at 06:09 PM 0
Share

THAT DOESN'T WOR$$anonymous$$, BOOOOOO! https://issuetracker.unity3d.com/issues/onapplicationpause-doesnt-get-called-when-switching-from-editor-to-another-application It's that simple, a failed fix!

avatar image Fattie ForceMagic · Aug 24, 2016 at 07:03 PM 0
Share

hey bra - (1) are you on a $$anonymous$$ac? (2) exactly what version of Unity?

Sure, this tip is a year old - that's 25 years in dog computer years

avatar image CasualT_Bossfight · Nov 30, 2017 at 09:59 PM 0
Share

You also have to have Run in Background unchecked

avatar image
1

Answer by instruct9r · Feb 12, 2015 at 11:32 AM

OnApplicationPause is not going to be called, if you pause the project in Unity simply because, when you pause it, everything in your game pauses. When running the game in the editor press ALT + TAB, to switch to another window, or just minimize Unity down and then reveal it again. This way the application continues to work and it knows that it was pulled down. If you pause the editor, everything pauses and there is no way, that the code knows, if it was paused...

Comment
Add comment · Show 8 · 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 hexagonius · Feb 12, 2015 at 11:38 AM 0
Share

Doesn't make sense to me since a boolean parameter is supposed to have 2 values. If that wasn't an option, why even have that? For ALT + TAB there's $$anonymous$$onoBehaviour.OnApplicationFocus

avatar image instruct9r · Feb 12, 2015 at 12:28 PM 3
Share

OnApplicationPause is called, when the application is paused by the system (Not by the editor). So if you run a game on iPhone and while playing you press the home button, OnApplicationPause will be called with pauseState = true. When you run the game again, OnApplicationPause will be called with pauseState = false.

There is no need for Unity to call OnApplicationPause, if you pause the game in the editor, simply because it will be useless. Pausing in editor is for debugging, not for calling functions.

Or maybe i don't undestand what you need to achieve? If you are trying to make the application to call OnAPplicationPause, when it's pulled down, then this is the function that you need to call

avatar image Zita · Feb 12, 2015 at 01:08 PM 0
Share

I just assumed that the "pause"-button in the editor should call "OnApplicationPause". It seemed logical. But if not, how do I then debug this behaviour without deploying on a real device?

avatar image instruct9r · Feb 12, 2015 at 01:14 PM 1
Share

Put this code in some script in your game:

 void OnApplicationPause (bool : pauseState)
 
 {
       print (pauseState);
 }


Now run the game in the editor and while running $$anonymous$$imize unity (Or just reveal some other window) and then maximize again. You will see the 2 states in the console (true and false).

avatar image Zita · Feb 12, 2015 at 01:28 PM 0
Share

How odd. Okey I will try that. Thanks!

Show more comments

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Header attribute and Custom Property Drawer overlap in inspector, repeat header text 2 Answers

Unity Editor 'actively refused' attaching debugger 4 Answers

Add same go as a child to multiple gameObjects in hierarchy 0 Answers

Set MinWidth for EditorWindow 1 Answer

Why my Roguelike 2D graphics are naughty in devices? 1 Answer


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