magique
Full Member
Posts: 194
Posts: 194
|
Post by magique on Aug 12, 2017 18:09:04 GMT
I thought I must be doing something wrong, but I can't even get WorldVariableListener to work in the Demo Scene 2. I am using TextMeshPro, but I don't think that's the issue at all. I Imported the updated script for TextMeshPro so that is all as it should be. I have added an object to the Canvas and added the WorldVariableListener script to it. Then assigned it the Score variable. I made sure that my Killable enemies have the Death World Variable Modifier Scenarios setup so that it Adds 100 to score. But when the killables are destroyed, the score is not updated. I know the world variable is correctly tied to the TMPro object because if I set a default value then I see that value correctly set for the Score text. It just doesn't seem to trigger a change when the killable is destroyed.
|
|
|
Post by DarkTonic Dev on Aug 12, 2017 19:04:02 GMT
Check the "real value" of the World Variable by going to its Game Object in the Inspector at runtime. It will show there. Is it what you thought?
If so, make sure the Listener is actually hooked up as a Listener. If it is, add a line of code in the UpdateX method in the Listener so you'll know it's getting called.
|
|
magique
Full Member
Posts: 194
Posts: 194
|
Post by magique on Aug 12, 2017 19:10:41 GMT
Yes, the real value is updating as I would expect. I added code to the Update method and it never gets called. As far as making sure the Listener is actually hooked up as a Listener, this is the part that I may not be understanding. The Score text object has the WorldVariableListener attached to it and it is set to the Score variable. But it still doesn't work. Is there something else I could be missing?
|
|
|
Post by DarkTonic Dev on Aug 12, 2017 19:26:18 GMT
Listeners have to be hooked up to what they're listening to. You find the Listener field in the Inspector and drag the Listener game object there. In this case the Listener field is on the World Variable game object itself (Score).
|
|
magique
Full Member
Posts: 194
Posts: 194
|
Post by magique on Aug 12, 2017 20:14:18 GMT
Thanks. I totally missed that field. It works now. One thing I think should be added is a way to specify the integer formatting. For score, for example, I want it to show all the digits even if the number is small. So, something like this:
000006000
instead of just
6000
I'm adding code to do that myself, but it would be nice if it was built-in already.
|
|
|
Post by DarkTonic Dev on Aug 12, 2017 20:36:17 GMT
Will do, thanks.
|
|