タイムアタックを作ろう/UIテキストの使い方









タイムアタック
using UnityEngine;
// ★追加
using TMPro;
using UnityEngine.SceneManagement;
public class GameController : MonoBehaviour
{
public TextMeshProUGUI timeLabel;
public float timeCount;
void Start()
{
timeLabel.text = "TIME: " + timeCount;
}
void Update()
{
timeCount -= Time.deltaTime;
// (テクニック)小数点1位まで表示
timeLabel.text = "TIME: " + timeCount.ToString("n1");
if(timeCount < 0)
{
SceneManager.LoadScene("GameOver");
}
}
}


【Unity6版】BallGame(全27回)
他のコースを見る








タイムアタック
using UnityEngine;
// ★追加
using TMPro;
using UnityEngine.SceneManagement;
public class GameController : MonoBehaviour
{
public TextMeshProUGUI timeLabel;
public float timeCount;
void Start()
{
timeLabel.text = "TIME: " + timeCount;
}
void Update()
{
timeCount -= Time.deltaTime;
// (テクニック)小数点1位まで表示
timeLabel.text = "TIME: " + timeCount.ToString("n1");
if(timeCount < 0)
{
SceneManager.LoadScene("GameOver");
}
}
}


タイムアタックを作ろう/UIテキストの使い方