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 Doddler · May 06, 2013 at 10:39 PM · audioresourcesaudiolistenerexternal

Best way to handle huge number of audio assets

A project that I'm working on now contains a somewhat unseemly huge number of audio assets; upwards of 10,000 individual audio files (approximately 500mb total). Most of these files are voice clips, usually only a few seconds long. They generally play only one at a time, as the game script calls for them. We're only targeting PC, but it might be cool to do mac or linux in the future.

There's two main issues. Unity often doesn't like working with that many files at a time. It adds a rather long period of time to building, it can freeze if you try to move them, and heaven forbid you want to do something like set them all to 2d audio sources. And secondly, I'd like to easily be able to deploy patches, in case files change, and unity's internal format doesn't make that particularly easy, everything just gets shoved into a big resources.assets file, I'm not even sure you can patch changes to it.

My first thought then was just to pack all the files in a separate archive and load them external to unity. I had originally thought of using unity asset bundles, or perhaps just using simple package files (no compression, just a whole bunch of files in one or two big files). Asset bundles it turns out are a no go; Loading from a local asset bundle containing all the audio files takes anywhere from 30 - 60 seconds. My simple package files plan was similarly thwarted by the fact that there is no way to actually load an AudioClip object from an mp3 or ogg file. You can load external ogg's from a WWW object, but not from a byte array. I suppose it could work if I just threw all the audio files into a folder, but that's not very professional, and the OS doesn't like a lot of small files either.

Does anyone have any thoughts on how perhaps I should approach this?

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

2 Replies

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

Answer by Fattie · May 07, 2013 at 08:05 AM

basically .......... keep them in Resources. In a folder. Have carefully organized subfolders.

per folder, load them more or less like this ..

 clips = Resources.LoadAll("VoiceReads/" + folderTextname, AudioClip );

But that's all the easy part, you've actually stumbled on to (sorry for the bad news) one of the biggest and most annoying snags in Unity ...

http://forum.unity3d.com/threads/162779-Loading-Streaming-Audio-from-the-Resources-Folder

notice me and others ranting about it there.

Hope this helps in some way!

Comment
Add comment · Show 1 · 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 Doddler · May 07, 2013 at 06:18 PM 0
Share

It seems like a rather unusual, the audio handling in unity seems ill equipped for games where you can't pre-load audio per scene or need to rely on external assets/load assets from memory. I guess at the moment I'll have to work around those limitations. Thanks!

avatar image
2

Answer by Bunny83 · May 07, 2013 at 08:21 AM

You could "ban" all the files from your Unity project and load them at runtime via WWW. Unity can only load those types at runtime: Ogg(Web/Standalones), WAV, XM, IT, MOD and S3M. Only on mobile you also have MP3 since they have hardware support for them. There is no MP3 support in Unity due to licencing issues.

For more information see the function WWW.GetAudioClip.

For testing purposes i would temporally replace the filepath to a fix path on your development machine. Once you're done you would place the files in some subfolder of your build after you build the game.

Comment
Add comment · Show 1 · 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 Doddler · May 07, 2013 at 06:15 PM 0
Share

Thanks for the info... I just wish they would let you load an external audio resource from memory rather than only WWW.

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

16 People are following this question.

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

Related Questions

How to load objects from a file outside of unity3d 3 Answers

Strange Audio Output During Awake() 0 Answers

Max amount of simultaneous, hearable sounds? 1 Answer

Audio Problem with multiple audio Sources 0 Answers

Get volume from microphone to make something happen 0 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