Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    Dismiss Notice

music background loop .... how ?

Discussion in 'Editor & General Support' started by josemauriciob, Apr 13, 2012.

  1. josemauriciob

    josemauriciob

    Joined:
    Mar 5, 2009
    Posts:
    623
    Hi ...
    just to ask someone please ......
    What is the best way to use a music background, and
    not consume to much resources.

    in other words .....
    how make a loop background sound ( on all level game ) , using few unity resources,
    to not affect performance and fluidity of the game.

    thanks a loot
     
  2. Spellbound

    Spellbound

    Joined:
    Sep 9, 2011
    Posts:
    50
    The fasted method would be an uncompressed audio file, but regarding music that's not really an alternative because memory usage is way too high. I would not even load a compressed audio into memory, but stream it from disc. Depends on length and target platform.

    You should be able to use a single, compressed audio stream (mp3 on iOS/android/osx, ogg on pc) without a noticeable performance loss. On iOS you can use hardware decoding for one audio stream.

    What is your target platform? On PC everything should usually be using OGG compression without noticing a real performance drop.

    If you want the music to play continuously without restarting on level load, you should have a look at http://unity3d.com/support/documentation/ScriptReference/Object.DontDestroyOnLoad.html. AudioListener and AudioSource should be flagged this way.