Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int timerBottle;
- public Text txtBottle;
- public Text txtTimerBottle;
- public Button button;
- public void ButtonClick()
- {
- timerBottle = 16;
- button.interactable = false;
- StartCoroutine(ButtonBottle());
- StartCoroutine(ButtonTimerBottle());
- IEnumerator ButtonBottle()
- {
- while (true)
- {
- txtBottle.enabled = true;
- txtBottle.text = "Cобираем бутылки";
- yield return new WaitForSeconds(0.5f);
- txtBottle.text = "Собираем бутылки.";
- yield return new WaitForSeconds(0.5f);
- txtBottle.text = "Собираем бутылки..";
- yield return new WaitForSeconds(0.5f);
- txtBottle.text = "Собираем бутылки...";
- yield return new WaitForSeconds(0.5f);
- txtBottle.text = "Собираем бутылки....";
- }
- }
- IEnumerator ButtonTimerBottle()
- {
- while (true)
- {
- txtTimerBottle.enabled = true;
- yield return new WaitForSeconds(1f);
- timerBottle -= 1;
- txtTimerBottle.text = timerBottle.ToString();
- if(timerBottle == 0)
- {
- txtBottle.text = "Вы собрали null бутылок";
- StopCoroutine(ButtonTimerBottle());
- StopCoroutine(ButtonBottle());
- button.interactable = true;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement