Hello again! Completely different issue from yesterday.
My goal is to create a countdown timer that persists through the entire game. The timer would be displayed to the player in a persistent UI. I've got most of it working, but admittedly all through custom scripts outside of AC.
So here's my problem: I have a script that runs / persists that has a public Text element to show the timer. Ordinarily, I would just connect this to the Instantiated UI element associated with it in each scene... but AC generates the Canvas at run-time.
I attempted to plug the prefab version of the UI element into the public variable slot, but that did not work.
I assume that there is some sort of interaction I need to set up with the Menu system, but so far I have not found the combination of options that makes this viable. (I do have other UI elements running through the Menu system, so the system is not 100% foreign to me.)
Any ideas?
Comments
When working with Menus, it's always a good idea to first get things working in AC's built-in menu system before moving it to Unity UI - that way you can rapid prototype the functionality you want before thinking about how it looks.
If you've written a script that sets the timer yourself, you can link this to a Menu via a Global String variable. Create a new String Global variable in the Variables Manager and make a note of it's ID number (the number to the left of its name in the list). You can then assign that string to that of the timer value within your script:
GlobalVariables.SetStringValue (2, "My Timer text"); // Replace '2' with the correct ID number
If the 'show realtime values' option is on the Variables Manager, you can confirm the link is working by viewing it while the game is running.
You can then display the value of this variable within a Label menu element by using the variable token, which gets replaced with the variable's value in-game:
"Time left: [var:2]"
This token will also be listed in the Variable's entry in the Variables Manager.