Change background of dialogue option depending on state

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Adeoon
Posts: 33
Joined: Fri Dec 02, 2022 5:53 am

Change background of dialogue option depending on state

Post by Adeoon »

Hi, so my dialogue options once read should have grey background as a highlight that player already ask about tha for example. I want to do it as simple as possible. One way to do that is make variable for each dialogue option, but that is very not optimal I would say. Do dialogue system supports that feature?
User avatar
Tony Li
Posts: 22142
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change background of dialogue option depending on state

Post by Tony Li »

Without any scripting, you can set the format of the text (color, italics, bold, etc.), but not the background. To do this:

1. Tick the Dialogue Manager GameObject's Other Settings > Include SimStatus.

2. Set the Dialogue Manager's Input Settings > [em#] Tag For Old Responses.

3. In the Dialogue Editor window's Database tab, set the appearance of the selected [em#] tag under the Emphasis Settings foldout.


If you want to change the background, you'll need to do a little scripting. You can make a subclass of StandardUIMenuPanel. (See this post for how to replace your StandardUIMenuPanel component.) Override SetResponseButton(). Something like:

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);
        var alreadyAsked = DialogueLua.GetSimStatus(response.destinationEntry) == DialogueLua.WasDisplayed;
        var backgroundImage = button.GetComponent<Image>();
        backgroundImage.color = alreadyAsked ? Color.gray : Color.clear;
    }
}
Post Reply