Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unityカウントダウンタイマーのサンプルコード
//試合時間に3秒足すこと
private float maxTime = 63f;
Timer gameTimer = new Timer ();
gameTimer.Start (maxTime, 1f);
gameTimer.Elapsed += delegate(float rest) {
if(rest == maxTime - 2f){
gameStatusText.text = "GO!!";
}
if(rest <= maxTime - 3f){
gameStatusText.text = "";
isGameStart = true;
timerPrefab.GetComponentsInChildren<Image>()[1].fillAmount = rest / (maxTime - 3f);
timerPrefab.GetComponentInChildren<Text>().text = ((int)rest).ToString();
}
};
gameTimer.Finished += delegate {
isGameStart = false;
gameStatusText.text = "FINISH!!";
startButton.interactable = true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment