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 cogswellSteve · Feb 24, 2013 at 02:08 AM · javascriptaudioaudiocliplooping

Looping an AudioClip var...

I have a declared variable(soundvar), an AudioClip, that I need to loop. It is not attached to a audio source. Can I make a variable loop independent of an audio source?

I was thinking along the syntax of soundvar.loop = true?

My javascript is not very strong, thank you for humoring my inquiry.

Comment
Add comment · Show 3
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 AlucardJay · Feb 24, 2013 at 03:47 AM 1
Share

This just doesn't make sense. To play an audio, you need an audio source, that's where the sound comes from, yeah?! Source.

To toggle looping on an audioSource, use http://docs.unity3d.com/Documentation/ScriptReference/AudioSource-loop.html

avatar image cogswellSteve · Feb 24, 2013 at 05:09 PM 0
Share

There is a source on the object in question, but it has an assigned clip in the inspector; I'm composing a script that will independently trigger audio not assigned to the source, but my question is can I get that audio to loop by not using the source directly?

avatar image Golan2781 · Feb 24, 2013 at 05:20 PM 0
Share

Your question doesn't make sense. There is no audio without the source so you cannot get the audio to loop without it.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Tarlius · Feb 24, 2013 at 05:26 PM

You can play sound without attaching it to the source, but you lose control of it, and if I recall correctly, you cannot loop it (without writing extra logic to tell it to play again, which will run into a whole new set of problems)

The command for playing once is PlayOneShot.

What you could do, is have a prefab of an AudioSource and instantiate and attach the clip to it in code.

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 AlucardJay · Feb 25, 2013 at 03:11 AM 0
Share

This is correct, Upvoted. PlayOneShot and PlayClipAtPoint does not loop, therefore as suggested create a prefab with an audioSource, audioClip in the inspector and set to loop.

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

12 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

Related Questions

What could make the audio loop? 2 Answers

JavaScript Play Audiosource Problem 1 Answer

Audio source play stop in Unity5 3 Answers

Why does the audio sound different than the original ? 0 Answers

Sound wont play when triggered (javascript) 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