I have already asked this question but since there was no answer there i will ask again.
I have made an archery taregt with 5 rings. evrery rign gives an other point when clicking it. but the problem now is that it is not updating. it gives points for every ring of my target but it is nog counting them together. what did i do wrong?
counting script:
using UnityEngine;
using System.Collections;
public class Count : MonoBehaviour
{
public bool isClicked = false;
public GUIText countText;
private int count;
public void Start()
{
count = 0;
SetCountText ();
if(gameObject.GetComponent<Collider> () == null)
gameObject.AddComponent<BoxCollider> ();
}
public void OnMouseDown()
{
isClicked = true;
}
public void OnMouseUp()
{
isClicked = false;
if (gameObject.tag == "White")
{
count = count + 1;
SetCountText ();
}
if (gameObject.tag == "Black")
{
count = count + 2;
SetCountText ();
}
if (gameObject.tag == "Blue")
{
count = count + 3;
SetCountText ();
}
if (gameObject.tag == "Red")
{
count = count + 4;
SetCountText ();
}
if (gameObject.tag == "Yellow")
{
count = count + 5;
SetCountText ();
}
}
public void OnGUI()
{
if (isClicked)
{
GUI.Label (new Rect (5, 5, 400, 100), " This is " + this.name);
}
}
void SetCountText ()
{
countText.text = "Count: " + count.ToString ();
}