Advertisement
SuperMeatBoy

RestartDialog

Jun 7th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using Entitas.CodeGenerator.Api;
  2. using UniRx;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. [UI, Unique]
  7. public class RestartDialog : Injectable
  8. {
  9. public Button YesButton;
  10. public Button NoButton;
  11. public Transform Root;
  12.  
  13. public bool IsOpened
  14. {
  15. get { return Root.gameObject.activeSelf; }
  16. }
  17.  
  18. void Awake()
  19. {
  20. YesButton.onClick.RemoveListener(OnYes);
  21. YesButton.onClick.AddListener(OnYes);
  22. NoButton.onClick.RemoveListener(OnNo);
  23. NoButton.onClick.AddListener(OnNo);
  24. Show(false);
  25. }
  26.  
  27. private void OnNo()
  28. {
  29. Show(false);
  30. }
  31.  
  32. private void OnYes()
  33. {
  34. Show(true);
  35. _contexts.uI.CreateEntity().isRestart = true;
  36. }
  37.  
  38. protected override void OnInject()
  39. {
  40. _contexts.uI.ReplaceRestartDialog(this);
  41. }
  42.  
  43. public void Show(bool state)
  44. {
  45. Root.gameObject.SetActive(state);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement