Game Development Reference
In-Depth Information
Making the ScorePlate active
Let's create a simple script to update the text field of this score as shown in the fol-
lowing screenshot:
The following script will update the text field in the upper-right corner of the screen so
that it reflects the score stored in PlayerData:
1. Switch to the MAIN scene. Create a new script, and name it
scoreScript.cs .
2. Attach an instance of this script to the score GameObject.
3. In the start method of this script, find the GameObject named Player , and
then store a reference to the PlayerData component on this script.
4. The score script needs to update a member of the GUIText GameObject
score , so the update loop that this script should be called from is OnGUI() .
Inside this loop, we check for a PlayerData component as shown in the fol-
lowing code:
void OnGUI() { }
GameObject go = GameObject.Find("Player")
Search WWH ::




Custom Search