Created
April 23, 2018 21:13
-
-
Save listopad/cf710bd6a847bebe2860631c27413398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
using UnityEngine.Events; | |
public class Collector : MonoBehaviour | |
{ | |
private int score; | |
public int goal; | |
public string objectTag; | |
public Text textWindow; | |
public UnityEvent GoalAchieved; | |
private void OnTriggerEnter(Collider other) | |
{ | |
if (other.gameObject.CompareTag(objectTag)) | |
{ | |
score++; | |
textWindow.text = score.ToString(); | |
other.gameObject.SetActive(false); | |
if (score == goal) GoalAchieved.Invoke(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment