Forum rules - please read before posting.

Action to replace portion of TextMeshProGUI text?

Hi all!

I was wondering if it is possible to replace portions of TextMeshProGUI text with decorations.

For my specific context, once the player gets a certain item, I want it to be crossed-out from their list with the strikethrough decoration.

E.g.:
Subtask of "picking up a bell pepper"

Before bell pepper obtained: Screenshot, text is "<color=green> 1 bell pepper"

After bell pepper obtained: Screenshot, text is replaced with <color=green> 1 bell pepper

In both cases, I am replacing only a portion of the entire text with the strikethrough decoration when the subtask is completed.

Is it possible to do something like this within adventure creator? If not, how would one go about creating a custom action to achieve this?

Thank you so much!

Comments

  • If you've linked up the Text box to AC's Menu Manager via a Label element, you can set its content within the Label element's properties. That will mean you can make use of variable tokens within the text, which you can use to make the display text dynamic.

    Variable tokens take the form of:

    [var:X]
    

    Where X is the ID number of a Global Variable. When inserted into a Label element's display text, it will be replaced by that variable's value at runtime.

    So, if you create a Global String Variable for each item, e.g. "1 bell pepper", you can replace "1 bell pepper" in your Label element with that variable's token.

    Then, when the item is taken, you just need to use the Variable: Set Action to update the String variable's value to "1 bell pepper".

  • Perfect, thank you so much!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.