Last active
June 3, 2016 09:56
-
-
Save pouhiro1224/a11ee348e3a64327b0ae41172d88a710 to your computer and use it in GitHub Desktop.
Unityカウントダウンタイマーのサンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//試合時間に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