Hi Tony!
I'm trying to get the response index. I'm trying to play a sound effect on button select, and want to know if I'm moving up or down in the menu.
I tried using the GetSiblingIndex(), but since the response menu creates new objects, it's not always correct when a new menu instantiates.
Could you show me a script where I could get the index of the available responses?
All the best!
Get Response Index
Re: Get Response Index
Hi,
There are a few ways you can do this.
1. You can add all your buttons to the Standard UI Menu Panel's Buttons list at design time instead of instantiating a template. Then you'll know their order ahead of time.
2. Or you can make a subclass of StandardUIMenuPanel and override ShowResponses. At the end of the method, set up your sounds:
3. Or, if you don't want to subclass, add a new script to the Dialogue Manager that has an OnConversationResponseMenu method. Wait until the end of the frame, then set up your sounds:
There are a few ways you can do this.
1. You can add all your buttons to the Standard UI Menu Panel's Buttons list at design time instead of instantiating a template. Then you'll know their order ahead of time.
2. Or you can make a subclass of StandardUIMenuPanel and override ShowResponses. At the end of the method, set up your sounds:
Code: Select all
public override void ShowResponses(Subtitle subtitle, Response[] responses, Transform target)
{
base.ShowResponses(subtitle, responses, target);
// Add your code here. The instantiated buttons are in the instantiatedButtons list.
}
Code: Select all
void OnConversationResponseMenu(Response[] responses)
{
StartCoroutine(SetupSounds());
}
IEnumerator SetupSounds()
{
yield return new WaitForEndOfFrame();
// Add your code here.
}