Page 1 of 1

Create multiple response buttons in order for SMS

Posted: Sun Apr 03, 2022 1:31 am
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).

Re: Create multiple response buttons in order for SMS

Posted: Sun Apr 03, 2022 8:56 am
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.

Re: Create multiple response buttons in order for SMS

Posted: Sun Apr 03, 2022 2:29 pm
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.

Re: Create multiple response buttons in order for SMS

Posted: Sun Apr 03, 2022 2:52 pm
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;
    }
}

Re: Create multiple response buttons in order for SMS

Posted: Sun Apr 03, 2022 3:15 pm
by xyztankman
Perfect, super helpful as always Tony, thanks!

Re: Create multiple response buttons in order for SMS

Posted: Sun Apr 03, 2022 5:00 pm
by Tony Li
Glad to help!