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 /
This question was closed Jan 16, 2013 at 11:49 PM by Blasfemmy for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Blasfemmy · Jan 16, 2013 at 12:53 AM · audioaudiosourcetimerpausetime.deltatime

Audio Issue

Greetings, I am trying to get it so that when a counter variable reaches a certain number, that a sound plays on a loop. This, however, is not the issue. I cannot get the sound to play, even though it plays loud and clear in the inspector window. After messing around with the settings to no avail, I eventually stumbled upon something strange. The only way that I can get the audio to play is if I run the scene in the Unity Editor (or in a build, doesn't matter), then alt-tab out of it. The sound plays as normal, yet when I alt-tab back into Unity, the sound stops abruptly. If more detail is necessary to give a proper assessment, just ask ;) Has anyone else had a similar issue? If so, how have you solved it?

Edit: I have played around with it a bit more. I have a timer on the HUD, and when the timer isn't counting up (paused, hence the alt-tab), the audio plays.

tl;dr: Only when the game is paused will the audio play, which is exactly opposite as to what I need.

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

  • Sort: 
avatar image
0
Best Answer

Answer by Blasfemmy · Jan 16, 2013 at 11:49 PM

SOLVED:

I had an infinite loop of playing the audio when the game was running. Here is the working script:

 #pragma strict
 
 @script RequireComponent( AudioSource )
 
  
 
 var papers : CollectPapers;
 
  
 
 var num : float = 0.0;
 
  
 
 var ambiance : AudioSource;
 
  
 
 var hasplayed : boolean = false;
 
  
 
 function Start () {
 
     audio.priority = 0;
 
 }   
 
  
 
 function Update () {
 
     if ( papers.papers >= num )
 
     {
 
         if(hasplayed){} 
 
             else
 
             {
 
                 audio.Play();
 
                 hasplayed=true;
 
  
 
             }
 
     }
 
 }
Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

8 People are following this question.

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

Related Questions

Problem with Footstep System 1 Answer

AudioSource.Pause not working? 3 Answers

How to make menu which is able to list audio files, then load chosen one into the AudioSource in the scene 1 Answer

Poor performance when using AudioSource.Play 0 Answers

Setting a specific Audio Mixer Group through code 2 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