Response buttons and AudioClip

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
stansison
Posts: 10
Joined: Thu Jun 03, 2021 11:44 pm

Response buttons and AudioClip

Post by stansison »

This is similar to the topic https://www.pixelcrushers.com/phpbb/vie ... nse#p15392

Hello Tony,

I wish to play a sound when the response button is clicked. I followed along the previous post and the sounds works, but the response button is no longer catching the onclick event and the response is not caught. I added an OnClick event to play the audioSource on the Button Component.

My Response panel uses the option to automatically create buttons and the Response template button has the component StandardUI Response Button. It seems one

Am I missing a step?
stansison
Posts: 10
Joined: Thu Jun 03, 2021 11:44 pm

Re: Response buttons and AudioClip

Post by stansison »

StandardUIResposnseButton has this at the start

if (button != null && button.onClick.GetPersistentEventCount() == 0)
{
button.onClick.AddListener(OnClick);
}

Is there anything to watch out for if I remove the check?
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Response buttons and AudioClip

Post by Tony Li »

Hi,

No need to remove the check. Just configure your Button's OnClick() UnityEvent to also call its StandardUIResponseButton.OnClick method.
stansison
Posts: 10
Joined: Thu Jun 03, 2021 11:44 pm

Re: Response buttons and AudioClip

Post by stansison »

Thank you for the guidance Tony!
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Response buttons and AudioClip

Post by Tony Li »

Glad to help!
Post Reply