OptionPanel.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.Events;
  6. public class OptionPanel : OffAnimation
  7. {
  8. [SerializeField] VolumePanel _volumePanel;
  9. [SerializeField] ResizeWindow _resizeWindowPanel;
  10. [SerializeField] GameplayOption _gameplayOption;
  11. [SerializeField] GraphicsOptionPanel _graphicsOptionPanel;
  12. [SerializeField] ServerRegionPanel _serverRegionPanel;
  13. [SerializeField] LanguagePanel _languagePanel;
  14. [SerializeField] Animator _anim;
  15. bool _isOpen = false;
  16. public void OnClickOpenOptionPanelButton()
  17. {
  18. if (_isOpen)
  19. {
  20. CloseOptionPanel();
  21. }
  22. else
  23. {
  24. if (Opening.instance != null)
  25. {
  26. Opening.instance.PlayDecisionSE();
  27. }
  28. else if (GManager.instance != null)
  29. {
  30. GManager.instance.PlayDecisionSE();
  31. }
  32. Open();
  33. }
  34. }
  35. public void Open()
  36. {
  37. _isOpen = true;
  38. gameObject.SetActive(true);
  39. _anim.SetInteger("Open", 1);
  40. _anim.SetInteger("Close", 0);
  41. if (_volumePanel != null)
  42. {
  43. _volumePanel.Off();
  44. }
  45. if (_resizeWindowPanel != null)
  46. {
  47. _resizeWindowPanel.Off();
  48. }
  49. if (_gameplayOption != null)
  50. {
  51. _gameplayOption.Off();
  52. }
  53. if (_graphicsOptionPanel != null)
  54. {
  55. _graphicsOptionPanel.Off();
  56. }
  57. if (_serverRegionPanel != null)
  58. {
  59. _serverRegionPanel.Off();
  60. }
  61. if (_languagePanel != null)
  62. {
  63. _languagePanel.Off();
  64. }
  65. }
  66. public void Close()
  67. {
  68. Close_(true);
  69. }
  70. public void CloseOptionPanel()
  71. {
  72. _isOpen = false;
  73. bool playSE = false;
  74. if (gameObject.activeSelf)
  75. {
  76. playSE = true;
  77. }
  78. if (_resizeWindowPanel != null)
  79. {
  80. if (_resizeWindowPanel.gameObject.activeSelf)
  81. {
  82. playSE = true;
  83. }
  84. }
  85. if (_volumePanel != null)
  86. {
  87. if (_volumePanel.gameObject.activeSelf)
  88. {
  89. playSE = true;
  90. }
  91. }
  92. if (_gameplayOption != null)
  93. {
  94. if (_gameplayOption.gameObject.activeSelf)
  95. {
  96. playSE = true;
  97. }
  98. }
  99. if (_graphicsOptionPanel != null)
  100. {
  101. if (_graphicsOptionPanel.gameObject.activeSelf)
  102. {
  103. playSE = true;
  104. }
  105. }
  106. if (_serverRegionPanel != null)
  107. {
  108. if (_serverRegionPanel.gameObject.activeSelf)
  109. {
  110. playSE = true;
  111. }
  112. }
  113. if (_languagePanel != null)
  114. {
  115. if (_languagePanel.gameObject.activeSelf)
  116. {
  117. playSE = true;
  118. }
  119. }
  120. Close_(playSE);
  121. if (_resizeWindowPanel != null)
  122. {
  123. _resizeWindowPanel.Close_(false);
  124. }
  125. if (_volumePanel != null)
  126. {
  127. _volumePanel.Close_(false);
  128. }
  129. if (_gameplayOption != null)
  130. {
  131. _gameplayOption.Close_(false);
  132. }
  133. if (_graphicsOptionPanel != null)
  134. {
  135. _graphicsOptionPanel.Close_(false);
  136. }
  137. if (_serverRegionPanel != null)
  138. {
  139. _serverRegionPanel.Close_(false);
  140. }
  141. if (_languagePanel != null)
  142. {
  143. _languagePanel.Close_(false);
  144. }
  145. }
  146. public void Close_(bool playSE)
  147. {
  148. if (playSE)
  149. {
  150. if (Opening.instance != null)
  151. {
  152. Opening.instance.PlayCancelSE();
  153. }
  154. else if (GManager.instance != null)
  155. {
  156. GManager.instance.PlayCancelSE();
  157. }
  158. }
  159. _anim.SetInteger("Open", 0);
  160. _anim.SetInteger("Close", 1);
  161. }
  162. public void Init()
  163. {
  164. Off();
  165. if (_volumePanel != null)
  166. {
  167. _volumePanel.Init();
  168. }
  169. if (_resizeWindowPanel != null)
  170. {
  171. _resizeWindowPanel.Init();
  172. }
  173. if (_gameplayOption != null)
  174. {
  175. _gameplayOption.Init();
  176. }
  177. if (_graphicsOptionPanel != null)
  178. {
  179. _graphicsOptionPanel.Init();
  180. }
  181. if (_serverRegionPanel != null)
  182. {
  183. _serverRegionPanel.Init();
  184. }
  185. if (_languagePanel != null)
  186. {
  187. _languagePanel.Init();
  188. }
  189. }
  190. public void OnClickExitGameButton()
  191. {
  192. #if UNITY_EDITOR || !UNITY_STANDALONE
  193. return;
  194. #endif
  195. //Application.Quit();
  196. }
  197. }