• 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 Ric · May 12, 2011 at 02:56 AM · runtime

Will it be possible to import mp3 files to be the background music at runtime?

Hi there! I am developing a game now, which is designed to let players to personalize the game. And I am wondering if it is possible to allow players to import their own music to be the background music when they are playing the game. Anyone know about this?

Thanks in advance!

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
1

Answer by Eric5h5 · May 12, 2011 at 03:26 AM

Unity doesn't have any support for MP3 (except for iOS/Android), so it has to be Ogg Vorbis format, which you can load with the WWW class (can use "file://" instead of "http://").

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 Ric · May 12, 2011 at 08:18 AM 0
Share

Ye, I think WWW class can do the job to load the mp3s. But question is, after WWW retrieves the mp3s, then what is next? I now use a audio.play() to play the clip, so I have to make clip to store it? I donot quite sure about this part. And if the players restart the game, the background music will be the default one again. So, do I have to setup a log so that the game will load the certain mp3 to be the background music each time when starting the game? Thanks!

avatar image Eric5h5 · May 12, 2011 at 10:54 AM 0
Share

Have you read the docs? http://unity3d.com/support/documentation/ScriptReference/WWW.GetAudioClip.html

avatar image Yarashiel · Oct 23, 2012 at 10:30 AM 0
Share

This answer was very useful to me!

Just to clarify it, this means that the user can load his file from disk AT RUNTI$$anonymous$$E , just by specifying the directory in the WWW class?

Thanks again for these answers !

avatar image
-1

Answer by lil_billy · May 12, 2011 at 03:12 AM

heres a thought, background music is always playing right, in order to hear things a player has to be close to an audio source right, so what if you put an audio source on your player with that mp3 looping

+tweek it with code to make it cleaner

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 Eric5h5 · May 12, 2011 at 03:28 AM 2
Share

That's not correct. If you turn off 3D for the sound, then it can be positioned anywhere and won't change the volume. This is what you use for music. Also that has nothing to do with the question.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Export objects to a .3DS file at runtime 1 Answer

Add a gameobject/transform present in a scene to a script on runtime 1 Answer

PrefabUtility.ReplacePrefab trouble 0 Answers

Missing reference to object 1 Answer

Problems accessing other script's variable 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