Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by MadWork · Jun 16, 2016 at 11:06 PM · audioscript.audioclip

How do you add audio to Audio Clip (via scripting) during gameplay?

I'm trying to let the user be able to add audio to an audio source during gameplay with the click of a button (or something like that). How do I do this?

So far I have scripts that allow me to create audio source objects but I'm not sure how to let the user be able to add specific audio clips they want to the audio sources. Is this possible? Any help would be appreciated, please.

Preferably in C# but anything would be helpful.

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

Answer by JedBeryll · Jun 17, 2016 at 06:01 AM

 public AudioSource source;
 
 public void ChangeClip (AudioClip clip) {
     source.clip = clip;
 }

A clip can be loaded like this: Resources.Load<AudioClip>("path to the clip");

Also there is a static method AudioSource.PlayClipAtPoint(clip, position);

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 MadWork · Jun 18, 2016 at 01:44 AM 0
Share

@JedBeryll

Sorry, this doesn't work for me. Would you elaborate, please?

What exactly does this script do? What should it do?

I'm trying to be make something where the user can change an audio source's audio clip during gameplay mode. Something where they can access a folder of audio clips and insert the audio clip themselves...

Any help/ elaboration you can give would be appreciated.

avatar image JedBeryll · Jun 18, 2016 at 05:10 AM 0
Share

In itself it doesn't do much but this is how you change the audioclip of a source at runtime. You would still have to call Play() on the source by the way.

If you want to load from a local folder you can use the WWW class to load the audioclips ins$$anonymous$$d of Resources. I think you can only play ogg and wav files this way (not sure).

avatar image MadWork JedBeryll · Jul 15, 2016 at 12:57 AM 0
Share

@JedBeryll Thanks for your advice. I'm currently working through it all trying to get it to work... I'll let you know how it goes.

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

66 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 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 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 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 avatar image avatar image

Related Questions

How to mute multi-able audioclips within a single audiosource? 0 Answers

Detecting when two different audio sources are emitting sound in Unity 0 Answers

Audio doesnt play in the phone but play on the editor 0 Answers

Is there any known way of sharing audio files from unity to other platforms i.e whatsapp 0 Answers

Precisely timestamping when audio leaves speaker 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