Page 1 of 1

Markup Tag [position=#] is not working

Posted: Mon Apr 26, 2021 4:25 am
by r35
Image

Not quite sure I'm using this markup correctly but what I'm trying to do is make the specific response always at the top.

It seems 'SetResponseButtons' is trying to order the buttons when there's a markup for the position

but buttons[] is empty at that point... :?

Is there any fix for this?

Re: Markup Tag [position=#] is not working

Posted: Mon Apr 26, 2021 10:11 am
by Tony Li
Hi,

The [position=#] markup tag doesn't apply to response buttons instantiated from the menu panel's response Button Template. It only applies to response buttons that you've assigned at design-time to the menu panel's Buttons list. (For example, see the Buttons list in the Wheel Standard Dialogue UI prefab, which has 6 design-time buttons.)

If you're using the Button Template to instantiate response buttons at runtime, you can use an OnConversationResponseMenu method to rearrange the Response[] array. For example, say you add a custom Boolean field named "Top" to your dialogue entry template, and you set it true for responses that should appear at the top of the list. Then your method might look like:

Code: Select all

void OnConversationResponseMenu(Response[] responses)
{
     // Look for a response whose "Top" field is true:
     int topIndex = -1;
     for (int i = 0; i < responses.Length; i++)
     {
         if (Field.LookupBool(response[i].destinationEntry.fields, "Top") == true)
         {
             topIndex = i;
             break;
         }
     }
     
     // If we have one, put it at the front of the Response[] array:
     if (topIndex > 0)
     {
         var temp = responses[0];
         response[0] = responses[topIndex];
         responses[topIndex] = temp;
     }
 }

Re: Markup Tag [position=#] is not working

Posted: Mon Apr 26, 2021 1:20 pm
by r35
Tony Li wrote: Mon Apr 26, 2021 10:11 am Hi,

The [position=#] markup tag doesn't apply to response buttons instantiated from the menu panel's response Button Template. It only applies to response buttons that you've assigned at design-time to the menu panel's Buttons list. (For example, see the Buttons list in the Wheel Standard Dialogue UI prefab, which has 6 design-time buttons.)

If you're using the Button Template to instantiate response buttons at runtime, you can use an OnConversationResponseMenu method to rearrange the Response[] array. For example, say you add a custom Boolean field named "Top" to your dialogue entry template, and you set it true for responses that should appear at the top of the list. Then your method might look like:

Code: Select all

void OnConversationResponseMenu(Response[] responses)
{
     // Look for a response whose "Top" field is true:
     int topIndex = -1;
     for (int i = 0; i < responses.Length; i++)
     {
         if (Field.LookupBool(response[i].destinationEntry.fields, "Top") == true)
         {
             topIndex = i;
             break;
         }
     }
     
     // If we have one, put it at the front of the Response[] array:
     if (topIndex > 0)
     {
         var temp = responses[0];
         response[0] = responses[topIndex];
         responses[topIndex] = temp;
     }
 }
Got it, thanks for the solution!

Re: Markup Tag [position=#] is not working

Posted: Mon Apr 26, 2021 1:28 pm
by Tony Li
Happy to help!