I have a text Ui object where I’d like to be able to change the text shown via script in an action list. It is currently linked to a menu that is called through dialogue options, but the text is not a dialogue choice.
What would be the best way to do this:
https://www.dropbox.com/sh/qyq10lxd9sqytfb/AABd3b7bgBqcHpTUq_T9KKrqa?dl=0
Comments
Create a Global String variable that stores the value you wish to display, and use a variable token in the element's Label to display it.
The [var:X] token is used to display a variable with ID = X. See the Manual's "Text tokens" chapter for full details.
When you say 'stores the value you wish to display' - I do wish to change this easily depending on custcenes etc. This still possible with the description above? Or would I need a different Global Variable for each piece of text I want to display?
Also what would the element in the menu be? Button? Also, this is for a Unity UI prefab text
You can use the Variable: Set Action to update the string's value at any time.
Tokens are supported by all element types, regardless of the menu's Source value.
Thanks Chris, so excusing my coding frailty, can you help change the below to factor in how I have set up my label text? Finding this a little hard to follow. Appreciate your help.
See screenshots:
https://www.dropbox.com/sh/6j3ska70y099jx1/AAA9gssFryXVxbrVx-3sL4LIa?dl=0
Custom tokens are a separate feature - they don't rely on the use of variables.
You're following the custom tokens tutorial, but aren't making use of the Journal menu element that the tutorial covers, so your code is looking for an element that does not exist.
Custom tokens can only be set through script, but variable tokens can be set through Actions.
A tutorial on the use of variable tokens can be found here.
Thanks it works!