Page 96 - MODUL_PEMROGRAMAN 2D & 3D_Neat
P. 96

36. Tambahkan script score di forder script.

                        using UnityEngine;
                        using System.Collections;
                        using UnityEngine.UI;
                        public class score : MonoBehaviour {
                            public static int skor;

                            public Text teks;
                               // Use this for initialization
                               void Start () {

                                    skor=0;
                                 teks =GetComponent<Text>();

                               }
                               // Update is called once per frame
                               void Update () {
                                 teks.text=""+skor;

                               }
                           37. Tambahkan script barusan ke dalam komponen text.
                            public void AddPoint(int poin)

                               {
                                      skor += poin;
                               }

                        }
                                Gambar 4.24 Menambahkan Script Kedalam Komponen Text

























                                                                                                     82
   91   92   93   94   95   96   97   98   99   100   101