Response option colors

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hellwalker
Posts: 112
Joined: Tue Jan 19, 2016 11:37 pm

Response option colors

Post by hellwalker »

Hey!
What would be easiest way to change response option colors from a script? (Via OnConversationResponseMenu().)

Wrapping formatted text in rich text tags ignores the number text. And I think it might conflict with UI tint colors?
I guess accessing buttons themselves would be the cleanest way but is the OnConversationResponseMenu's "Response[] responses" ordering same as they would appear in the Response list? (So I can use Response[] array to match indexes with button list?)

My use case is that I have some response items that I want to mark as "Main", "Optional", "Starts Combat" etc. I wrote some custom tags to mark responses that way and now I want to apply special colors, icons and suffix texts to responses.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Response option colors

Post by Tony Li »

Hi,

The StandardUIMenuPanel's SetResponseButton method adds the auto-numbers.

OnConversationResponseMenu is called before SetResponseButton.

If you need to include the auto-number inside your rich text tags, make a subclass of StandardUIMenuPanel. Override SetResponseButton. For example:

Code: Select all

public class MyMenuPanel : StandardUIMenuPanel
{
    protected override void SetResponseButton(StandardUIResponseButton button, Response response, Transform target, int buttonNumber)
    {
        base.SetResponseButton(button, response, target, buttonNumber);
        
        // If response's StartsCombat field is true, make the text red:
        if (Field.LookupBool(response.destinationEntry.fields, "StartsCombat"))
        {
            button.text = UITools.WrapTextInColor(button.text, Color.red);
        }
    }
}
I used UITools.WrapTextInColor instead adding tags to the string directly because WrapTextInColor properly handles nested rich text tags.
Post Reply