- 1 using System.Collections;
- 2 using System.Collections.Generic;
- 3 using UnityEngine;
- 4 using UnityEngine.UI;
- 5
- 6
- 7 public class EventTest : MonoBehaviour {
- 8
- 9 public Text goldText;
- 10
- 11 // Use this for initialization
- 12 void Start()
- 13 {
- 14 EventDispatcher.AddEventListener<int>(EventKey.OnPlayerGoldChange, OnPlayerGoldValueChange);
- 15 }
- 16
- 17 void OnPlayerGoldValueChange(int gold)
- 18 {
- 19 goldText.text = gold.ToString();
- 20 }
- 21
- 22 // Update is called once per frame
- 23 void Update() {
- 24
- 25 }
- 26 private void OnDestroy()
- 27 {
- 28 EventDispatcher.RemoveEventListener<int>(EventKey.OnPlayerGoldChange, OnPlayerGoldValueChange);
- 29
- 30 }
- 31
- 32 public void OnClickToAddGold()
- 33 {
- 34 PlayerInfoManagerTest.Instance.PlayerGold += 100;
- 35 }
- 36 }