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
1
Question by Daniel-Brauer · Oct 07, 2010 at 04:36 PM · iosbuttoniphonequithome

On iOS, how do I fade out music when the user presses the home button?

All the well-behaved games I've played on iOS fade out their audio when you push the home button. It's a cool effect, because it lasts until just after the home screen appears, making for a very smooth transition.

From what I have read, Application.Quit(), Application.CancelQuit() and MonoBehaviour.OnApplicationQuit() don't work/aren't called on iOS. This makes it difficult to detect when the user has pushed the home button. By default, my app's music is playing, so it continues to play until just after the home screen appears, and then it cuts off.

How do I make a Unity app handle quitting elegantly?

Comment
Add comment · Show 3
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 Thom Denick · Oct 07, 2010 at 06:06 PM 0
Share

I had always assumed this was an automatic effect because it seemed ubiquitous among games. Perhaps it's working in this manner because you have the debugger running? Have you tried just running your app on the device without being in debug mode?

avatar image Mike 3 · Dec 08, 2010 at 04:49 PM 0
Share

OnApplicationPause and OnApplicationFocus may be what you need, they're called when the iphone app gets paused or refocused

avatar image Daniel-Brauer · Dec 16, 2010 at 05:53 AM 0
Share

Sounds good. I'll check those out.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Dreamora 1 · Oct 15, 2010 at 06:37 AM

just dieing IS by apples definition quitting elegantly actually. you aren't meant to pull resources when the OS kills you.

Comment
Add comment · Show 3 · 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 Daniel-Brauer · Oct 15, 2010 at 08:11 PM 0
Share

Sure, but does Unity just die when the user hits the home button? $$anonymous$$usic keeps playing until a second or two after the home screen has fully appeared. I assume Unity isn't dying the moment the home button is pushed, but ins$$anonymous$$d letting the home screen appear and then dying?

avatar image Dreamora 1 · Oct 18, 2010 at 12:53 AM 0
Share

Thats technically not even possible for Unity or any application to control. The application will get the request to shut down (-> willResignActive), then gets a bit of time and then is pushed into background or gets the kill notifier and then gets killed. it can only react to the notifications but not control them.

the reason the music plays on is the music playback of the iOS which lets the current chunk or whatever play to the end and fades its towards that end then. But the underlying application at that point has commonly stopped its execution. (background special tasks are an exception)

avatar image Daniel-Brauer · Dec 16, 2010 at 05:53 AM 0
Share

What are you talking about? I'm talking about reacting to the request to shut down by fading out audio, which sounds perfectly possible from the rest of your comment.

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

No one has followed this question yet.

Related Questions

iPhone Home button 2 Answers

How can I swipe function that lets the player select buttons? 0 Answers

GUI.Button lags on iPhone 0 Answers

Mapping iOS touchscreen as simple buttons 2 Answers

Simultaneous Android and iOS development 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