- Home /
Audio doesn't play
Hi I am trying to play a movie texture and it's appropriate sound at the same time via a GUI button press.
I have managed to get the movie texture to play however the sound does not.
So, I seperated the sound so that the movie texture is just the video no audio, put the sound on a seperate script and activate two seperate game objects with one script on each: one plays just a movie texture one plays just the sound
When I play my game and press the GUI button the movie texture plays as it should on a button press however the sound does not, but when I open up Monodevelop to see where I might be going wrong the sound plays so I know it's working just at the right time.
This doesn't make any sense to me at all does anyone know how to solve this?
My code below.
 using UnityEngine;
     using System.Collections;
     
     public class Tutorial_Vids_audio : MonoBehaviour {
         
         
     //Tutorial audioclips    
     public AudioClip tutorialAudio_1;
     
         
     //Play tutorial bool's
     public bool Play_tutorialAudio_1;
         
     
         // Use this for initialization
         void Awake () 
         {
         Play_tutorialAudio_1 = true;
         }
         
         void Play_TutorialAudio_1 ()
         {
             if(Play_tutorialAudio_1)
             {
             audio.clip = tutorialAudio_1;
             audio.Play();    
             }
         }
         
         
         
         
         
         // Update is called once per frame
         void Update () 
         {
             Play_TutorialAudio_1 ();
         }
     }
 
 
Answer by Random username · Oct 31, 2012 at 02:35 PM
Looks like the sound is being restarted every frame. Maybe try change your if statement slightly to something like this:
            if(Play_tutorialAudio_1)
            {
            Play_tutorialAudio_1 = false; // set to false so that it doesn't do this every frame
            audio.clip = tutorialAudio_1;
            audio.Play(); 
            }
         }
You are a Legend my man it works beautifully. Thank You it was driving me nuts.
Your answer
 
 
             Follow this Question
Related Questions
AudioServicesPlaySystemSound - iOS System Sounds from Unity 1 Answer
Voice Recording issue ?? 0 Answers
Audio when I shoot 3 Answers
Background Music 2 Answers
Vehicle help 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                