GameDev : Score System implementation (Part II)!
Now, for AddScore to change the user interface, what do we need?
As always, a handle, or a reference, to UI Manager, right?
Inside Player script we create this reference
In Start, we need to Find this object.
And we make a check
Now, we have a reference, but we nee d amethod to change the UI.
Inside UI Manager, make some change
First, we set in Start Score to 0.
We delete the update method, then we create a method to manage the score.
And like we did with AddScore, let’s create a parameter to pass
And pass this parameter to the Text
We need to add ToString() at the end, because the Text UI is a STRING, but we pass an INT, so we call ToString() to convert the int value to a string.
Now in Player script, go to AddScore() and add the part of UI
And this is WRONG, because we need to Update the global score right?
So we need to pass “score”
If we try now
Everythings works without problems.
If you want you can make a test with “points” and the UI is Update to 10 one time, then never update, it stay forever to 10.
In the next part we setting up the visual component of UI!