Tracking stats
Now we will add the stat tracking feature that we created in Chapter 6, Keeping Score.
Adding the script
To allow stat tracking, we will simply drag the StatTracker
script and drop it on the main camera. Now, to show the menu for stats, we will need to add an Update
function. Add this to your script:
void Update() { if(Input.GetKeyUp(KeyCode.E)) { if(showStats) showStats = false; else showStats = true; } }
Now when the player presses the E key, it will toggle the showStats
Boolean variable. The stats menu will only show when showStats
is set to true
.