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
0
Question by zannghast · Mar 02, 2011 at 01:38 AM · audioiphoneoptimization

AudioSource.PlayOneShot performance

Hi,

I want to know your views on the performance differences between the use PlayOneShot() and creating/destroying AudioSources (and subsequently assigning audioClips to these sources then playing them) at runtime.

Which method would you guys recommend to play short clips (for SFXs) with performance in mind?

Thanks

Comment
Add comment
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

1 Reply

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

Answer by Jesse Anders · Mar 02, 2011 at 04:28 AM

I can't really comment on the performance characteristics, but I'd imagine that the overhead of repeatedly creating and destroying game objects will generally be greater than that of reusing the same game objects (search the forums for 'pooling' for further discussion on this).

I use pooling for audio sources, and that's worked well for me. (Specifically, all audio playback requests go through a central audio manager that creates persistent 'audio channel' game objects as needed. These objects persist between levels, so they're never destroyed; they're just reused repeatedly.)

Comment
Add comment · Show 2 · 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 zannghast · Mar 02, 2011 at 07:03 AM 0
Share

Hi Jesse, thanks for that. Just curious, do you use PlayOneShot in your persistent 'audio objects' or a combination of all available audio source playback methods?

avatar image Jesse Anders · Mar 02, 2011 at 03:31 PM 0
Share

When a 'sound playback request' comes in (consisting of e.g. audio clip, position, volume, pitch, loop, etc.), I find an available 'sound channel' (which is just a game object with an audio source attached) or create one if needed, assign the clip, position, volume, pitch, etc. to it, and then invoke Play(). So in answer to your question, Play() is used, rather than PlayOneShot().

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

compress recorded audio in an app? 0 Answers

Audio.Pitch not smaller than 0.1f on the iPhone? 1 Answer

Making a GetComponent array 1 Answer

help with iphone 3GS performance (polys and audio) 2 Answers

Large level loading best practices 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