PopUpPanel.cs 810 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using UnityEngine;
  2. using System.Collections;
  3. public class PopUpPanel : MonoBehaviour
  4. {
  5. private bool _modal;
  6. public bool modal
  7. {
  8. set{_modal = value;}
  9. get{return _modal;}
  10. }
  11. public void Open()
  12. {
  13. BeforeShow ();
  14. Animator animator = GetComponent<Animator>();
  15. if(animator != null)
  16. animator.Play("PanelShow", 0, 0);
  17. else
  18. OpenComplete();
  19. }
  20. public void OpenComplete()
  21. {
  22. Shown ();
  23. }
  24. protected virtual void BeforeShow()
  25. {
  26. }
  27. protected virtual void Shown()
  28. {
  29. }
  30. public void Close()
  31. {
  32. Animator animator = GetComponent<Animator>();
  33. if(animator != null)
  34. animator.Play("PanelHide", 0, 0);
  35. else
  36. CloseComplete();
  37. }
  38. public void CloseComplete()
  39. {
  40. Remove ();
  41. }
  42. protected virtual void Remove()
  43. {
  44. Destroy(this.gameObject);
  45. PopUpManager.UpdateModal();
  46. }
  47. }