- Home /
Buttons sounds are only playing once, then the sound no longer plays?
I have created an Audio Assistant script and then I call from the script with another script to make sounds become active on button clicks. However, once the button is clicked again, the sound no longer plays.
Here is the script that I am calling the sound to activate on multiple buttons:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class ButtonSoundGamePlay : MonoBehaviour {
public void GeneralButtonClick()
{
AudioAssistant.Shot("GeneralButton");
}
public void StoreButtonClick()
{
AudioAssistant.Shot("StoreButton");
}
public void BuyButtonCoinClick()
{
AudioAssistant.Shot("BuyButtonCoin");
}
public void BuyButtonPowerClick()
{
AudioAssistant.Shot("BuyButtonPower");
}
public void PowerSetButtonClick()
{
AudioAssistant.Shot("PowerSetButton");
}
public void StoreReturnButtonClick()
{
AudioAssistant.Shot("StoreReturnButton");
}
public void ExitButtonClick()
{
AudioAssistant.Shot("ExitButton");
}
public void RakeButtonSoundClick()
{
AudioAssistant.Shot("RakeButtonSound");
}
}
The buttons are assigned with each function and each sound is set in the Audio Assistant script. Any ideas would be very helpful. Thanks.
Comment
Actually I figured it out. I had a Debug Log on that for some reason the engine was disabling the sounds after doing an update with Unity. I turned off the Debug Log called: Debug.Log (music.clip.length); and now all of the sounds and buttons work correctly.