- Home /
Have Unity 5, don't understand text/GUI/coin pickup???
I have two scripts for the coin pickup. When the ball collides, the capsule gets destroyed as it should. I want to have a simple capsule counter at the top right. I have two scripts I'm going to display. a Coin and a CoinCounter script. I appreciate the help! :D I just don't understand the new system without GUI.
COIN SCRIPT
private CoinCounter coinCounter; public int capsulz = 1;
// 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.AddPoints(capsulz);
Destroy (gameObject);
}
}
}
CoinCounter
using UnityEngine; using System.Collections; [ExecuteInEditMode]
public class CoinCounter : MonoBehaviour {
public int score;
// Update is called once per frame
void Update ()
{
}
/* public void AddPoints(int points)
{
score += points;
}
void OnGui()
{
GUILayout.Label(score.ToString());
*/
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613200717im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Grab/Release object while pressing a key 1 Answer
Collision of a constantly moving object 0 Answers
Ignore Character Controller Collision 1 Answer
How to create a semi-passable barrier 1 Answer
NavMesh Collision Detection? 0 Answers