Markup Tag [position=#] is not working
Posted: Mon Apr 26, 2021 4:25 am
Support and discussion forum for Pixel Crushers products
https://www.pixelcrushers.com:443/phpbb/
https://www.pixelcrushers.com:443/phpbb/viewtopic.php?t=4397
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!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; } }