Create multiple response buttons in order for SMS

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
xyztankman
Posts: 54
Joined: Mon Jun 21, 2021 7:48 pm

Create multiple response buttons in order for SMS

Post by xyztankman »

Hey Tony,

I am attempting to create a trivia minigame with a version of the SMS dialogue UI but I'm having an issue where the answers are cut off due to being too long. Is there a way to put responses on separate lines instead of one?. If possible, I wanted to make 2 answers on each line. (screenshots attached).
Attachments
Trivia2.PNG
Trivia2.PNG (14.71 KiB) Viewed 993 times
Trivia1.PNG
Trivia1.PNG (15.84 KiB) Viewed 993 times
User avatar
Tony Li
Posts: 21676
Joined: Thu Jul 18, 2013 1:27 pm

Re: Create multiple response buttons in order for SMS

Post by Tony Li »

Hi,

The SMS Dialogue UI prefab's Response Panel has a Horizontal Layout Group, which lays out the response buttons horizontally.

You can replace this with a Vertical Layout Group to lay out the buttons vertically.

The Unity UI tutorial on raywenderlich.com is really helpful if you need an introduction to Unity UI layout.
xyztankman
Posts: 54
Joined: Mon Jun 21, 2021 7:48 pm

Re: Create multiple response buttons in order for SMS

Post by xyztankman »

Thanks Tony, that did it! Is there also a way to randomize the order of the responses? I tried a couple ways with RandomizeNextEntry() and x = math.random() but I couldn't get it to work right.
User avatar
Tony Li
Posts: 21676
Joined: Thu Jul 18, 2013 1:27 pm

Re: Create multiple response buttons in order for SMS

Post by Tony Li »

You can shuffle the responses in an OnConversationResponseMenu() method on a script on the Dialogue Manager. Example:

Code: Select all

void OnConversationResponseMenu(Response[] responses)
{
    for (int i = 0; i < responses.Length - 1; i++)
    {
        int j = Random.Range(i, responses.Length);
        Response temp = responses[i];
        responses[i] = responses[j];
        responses[j] = temp;
    }
}
xyztankman
Posts: 54
Joined: Mon Jun 21, 2021 7:48 pm

Re: Create multiple response buttons in order for SMS

Post by xyztankman »

Perfect, super helpful as always Tony, thanks!
User avatar
Tony Li
Posts: 21676
Joined: Thu Jul 18, 2013 1:27 pm

Re: Create multiple response buttons in order for SMS

Post by Tony Li »

Glad to help!
Post Reply