Skip to content

Instantly share code, notes, and snippets.

@pouhiro1224
Last active June 3, 2016 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pouhiro1224/a11ee348e3a64327b0ae41172d88a710 to your computer and use it in GitHub Desktop.
Save pouhiro1224/a11ee348e3a64327b0ae41172d88a710 to your computer and use it in GitHub Desktop.
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