I’ve spent about an hour trying to figure out why I am not able to get my “score” to show up in the inspector under my ScoreKeeper script. Here is my ScoreKeeper scripts:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ScoreKeeper : MonoBehaviour {
public int score = 0f;
private Text myText;
void Start(){
myText = GetComponent<Text>();
Reset ();
}
public void Score(int points){
score += points;
myText.text = score.ToString ();
}
public void Reset(){
score = 0;
myText.text = score.ToString ();
}
Thanks. I removed the “f” and saved my script and unfortunately I still don’t have the “score” showing up in the “inspector” under my “Score Keeper” script.
Can you pop a screenshot up, with the game object the score keeper scriot is attached to select in the Hierarchy and the details viewable in the Inspector.
And another of the Project view with the ScoreKeeper.cs file selected please.
I just solved it! For some reason my Unity was not responding when I tried loading other scenes. I saved, shut down and reloaded the Unity and now my 'Score" is showing up in the inspector! Just needed a good reboot…
Thanks so much Rob for the fast responses…you ROCK! I’ll try to help others along the way when I can.