Hi guys, I’m learning Unity by watching some Digital Tutors tutorial, yet the code is a bit old and I can’t figure out how to make it work on Unity. Any suggestions? Thanks in advance.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
[ExecuteInEditMode]
public class CoinCounter : MonoBehaviour
{
public int coinCount = 0;
// Update is called once per frame
void LateUpdate ()
{
GUIText.text = "x" + coinCount;
}
}
using UnityEngine;
using System.Collections;
public class Coin : MonoBehaviour
{
private CoinCounter coinCounter;
// Use this for initialization
void Awake ()
{
coinCounter = GameObject.Find ("coinText").GetComponent <CoinCounter>();
}
// Update is called once per frame
void Update ()
{
}
void OnTriggerEnter (Collider other)
{
if (other.gameObject.tag == "Player")
{
coinCounter.coinCount++;
gameObject.SetActive (false);
}
}
}