Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1.  
  2. private int timerBottle;
  3. public Text txtBottle;
  4. public Text txtTimerBottle;
  5.  
  6. public Button button;
  7.  
  8.  
  9. public void ButtonClick()
  10. {
  11. timerBottle = 16;
  12. button.interactable = false;
  13. StartCoroutine(ButtonBottle());
  14. StartCoroutine(ButtonTimerBottle());
  15.  
  16. IEnumerator ButtonBottle()
  17. {
  18. while (true)
  19. {
  20. txtBottle.enabled = true;
  21. txtBottle.text = "Cобираем бутылки";
  22. yield return new WaitForSeconds(0.5f);
  23. txtBottle.text = "Собираем бутылки.";
  24. yield return new WaitForSeconds(0.5f);
  25. txtBottle.text = "Собираем бутылки..";
  26. yield return new WaitForSeconds(0.5f);
  27. txtBottle.text = "Собираем бутылки...";
  28. yield return new WaitForSeconds(0.5f);
  29. txtBottle.text = "Собираем бутылки....";
  30.  
  31. }
  32. }
  33.  
  34. IEnumerator ButtonTimerBottle()
  35. {
  36. while (true)
  37. {
  38. txtTimerBottle.enabled = true;
  39. yield return new WaitForSeconds(1f);
  40. timerBottle -= 1;
  41. txtTimerBottle.text = timerBottle.ToString();
  42.  
  43. if(timerBottle == 0)
  44. {
  45. txtBottle.text = "Вы собрали null бутылок";
  46. StopCoroutine(ButtonTimerBottle());
  47. StopCoroutine(ButtonBottle());
  48. button.interactable = true;
  49.  
  50. break;
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement