Hi
I want to make countdown timer with UI–> Text. So, I can change the font of the number. how to do this ?
Also, how to make game object as a plane hide by touch a button.
Hi
I want to make countdown timer with UI–> Text. So, I can change the font of the number. how to do this ?
Also, how to make game object as a plane hide by touch a button.
You don’t want to change the font of the Text; you want to change the .text of the Text. Something like this should do it:
using UnityEngine;
using UnityEngine.UI;
public class Countdown : MonoBehaviour {
public float timeLeft = 10;
void Update() {
timeLeft -= Time.time();
GetComponent<Text>().text = string.Format("{0:0.0}", timeLeft);
}
}
For that you don’t need any code at all. In your Button, find the onClick event, click the little “+” button to add a new event handler, and then drag your plane (or other object) into the recipient field. Then use the pop-up menu to select GameObject → SetActive, and make sure the checkbox is unchecked (so it becomes not active). Bob’s your uncle.
For more cool stuff you can do with events, and the most fun 15 minutes you’ve ever had blowing up minions, check out The Real Power of UnityEvent.
Thank you so much for your help.
Everything now is fine.
I will continue building my game ^-^.
Note:
public float timeLeft =10f;