YarnSpinnerTool / YarnSpinner

Yarn Spinner is a tool for building interactive dialogue in games!
https://yarnspinner.dev
MIT License
2.3k stars 201 forks source link

Is there support for customizing the choice buttons from the yarn script? #344

Closed stardrive7 closed 1 year ago

stardrive7 commented 1 year ago

Could I put a tag in the Yarn script to look up a different button image to make those specific options appear blue/red, or replace the dialogue choice entirely with an image?

I found only the old way via DialogueUIBehaviour:

-> This is the paragon choice! #paragon
-> This is the renegade choice! #renegade
public override IEnumerator RunOptions (
    Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser)
{

    string option = // one of the options in optionsCollection
    if (option.IndexOf("#paragon") != -1) {
        // change the button to be blue or something
    }
}

but how to do it in new version? Thanks!

McJones commented 1 year ago

You can get this information from the metadata field on the line inside of the option, see https://docs.yarnspinner.dev/api/csharp/yarn.unity/yarn.unity.localizedline/yarn.unity.localizedline.metadata for details.