- Home /
gui label works in js but not in cs
Hello, this is my first time posting on the unity community. I have recently been having problems with a script on my player that collides with triggers and uses the tags on the other object to determine whether or not the object increases or deceases your score.I know that this part worked because I inserted code that would put your score in the debug log, And this works correctly. I think it is a problem within the onGUI but I will post the whole code just in case it is not . PS: the guistyle on the text is a black arial font code:
using UnityEngine;
using System.Collections;
public class Reset : MonoBehaviour {
public float health = 4;
public GUIStyle myStyle = new GUIStyle();
// Use this for initialization
void onGUI () {
GUI.Label(new Rect(10,10, 100, 30), "Score: "+health.ToString(), myStyle);
}
// Update is called once per frame
void Update () {
Debug.Log ("Score: "+health.ToString());
if (health<0)
{
Destroy(this.gameObject);
}
}
void OnTriggerEnter2D (Collider2D other)
{
if (other.gameObject.CompareTag ("Enemy"))
health = health - 1;
//pb
if (other.gameObject.CompareTag ("boxpoint"))
health = health + 1;
}
}
Comment
Your answer
Follow this Question
Related Questions
Factory script not working 0 Answers
GUI text shown on collision 1 Answer
Distribute terrain in zones 3 Answers
Help with GUIText health bar please 1 Answer