How do I keep two UI text unity3d on the scene
I'm having a problem with my UI text. I have a countdown timer text and Score text . The problem I am having is the zero is not showing up along with the score text . When I click on play the score text shows like this on the scene : Score : . The Score text should be showing this way Score : 0 and their is no errors showing up in the unity console . Here is my script :
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class GameManagerSingleton : MonoBehaviour { public static GameManagerSingleton instance = null;
public static int score;
private Text text;
void Awake()
{
text = GetComponent <Text> ();
score = 0;
if (instance != null && instance != this)
Destroy(gameObject); // Ensures that there aren't multiple Singletons
instance = this;
}
void Update()
{
text.text = "Score : " + score;
}
Answer by $$anonymous$$ · May 18, 2016 at 06:52 AM
I would think that your text isn't updated at all and that your text in the inspector is "Score : ". Could you add a Debug.Log("Score: " + score); in your Update routine to see in the console if the code is actually called.
Answer by importguru88 · May 18, 2016 at 06:36 PM
I've add the Debug.Log("Score: " + score) in the update function and the number still didn't show up in the scene.
Debug.Log is only for debugging and only shows in the console window of Unity. If it doesn't show up there then your code isn't called at all.