Hello. I am making a game that is 2D and for Android. I recently made a post asking how to set a score to zero using a button. Before the post, I made the score update every second and the text would carry over. Now the score is only updated every time you score a point, which is good, and pressing the button does make it to zero. The score does transfer over, but the text doesn’t actually show it. What I mean is that it knows how many points are scored but the text just says New Text instead of saying Score: 24 ( For example ) What needs to be done for it to show the score instead of saying New Text?
The scoremanager script is
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ScoreManager : MonoBehaviour
{
public static int score; // The player's score.
Text text; // Reference to the Text component.
void Awake ()
{
text = GetComponent <Text> ();
}
public void SetScore (int newScore)
{
ScoreManager.score = newScore; //update the static score variable
text.text = "Score: " + score;
}
}
and the script that actually detects for a point to be added is
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour {
public int scoreValue = 1;
public ScoreManager scoreManager;
void OnMouseDown () {
scoreManager.SetScore(ScoreManager.score + scoreValue);
}
}