ResizeWindow.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using Button = UnityEngine.UI.Button;
  4. using Toggle = UnityEngine.UI.Toggle;
  5. public class ResizeWindow : MonoBehaviour
  6. {
  7. private static readonly int OpenHash = Animator.StringToHash("Open");
  8. private static readonly int CloseHash = Animator.StringToHash("Close");
  9. public Animator anim;
  10. public Toggle fullScreenToggle;
  11. public List<Button> switchWindowSizeButtons = new List<Button>();
  12. public void Init()
  13. {
  14. Off();
  15. }
  16. public void Open()
  17. {
  18. SetButtonsInteractable();
  19. gameObject.SetActive(true);
  20. anim.SafeSetInt(OpenHash, 1);
  21. anim.SafeSetInt(CloseHash, 0);
  22. if (fullScreenToggle != null)
  23. {
  24. fullScreenToggle.isOn = Screen.fullScreen;
  25. }
  26. }
  27. public void Off()
  28. {
  29. gameObject.SetActive(false);
  30. }
  31. public void Close()
  32. {
  33. Close_(true);
  34. }
  35. public void Close_(bool playSE)
  36. {
  37. if (playSE)
  38. {
  39. if (Opening.instance != null)
  40. {
  41. Opening.instance.PlayCancelSE();
  42. }
  43. else if (GManager.instance != null)
  44. {
  45. GManager.instance.PlayCancelSE();
  46. }
  47. }
  48. anim.SafeSetInt(OpenHash, 0);
  49. anim.SafeSetInt(CloseHash, 1);
  50. }
  51. public void SetUpWindowSize(string resolution)
  52. {
  53. #if UNITY_EDITOR || !UNITY_STANDALONE
  54. return;
  55. #endif
  56. //if (Opening.instance != null)
  57. //{
  58. // Opening.instance.PlayDecisionSE();
  59. //}
  60. //else if (GManager.instance != null)
  61. //{
  62. // GManager.instance.PlayDecisionSE();
  63. //}
  64. ////float height = width / 16f * 9f;
  65. //int heightstring = 4;
  66. //if (resolution.Length <= 7)
  67. //{
  68. // heightstring = 3;
  69. //}
  70. //string temp = resolution.Substring(0, 4);
  71. //var width = int.Parse(temp);
  72. //temp = resolution.Substring(4, heightstring);
  73. //var height = int.Parse(temp);
  74. ////Screen.SetResolution((int)width, (int)height, false);
  75. //Screen.SetResolution((int)width, (int)height, UnityEngine.Device.Screen.fullScreen);
  76. //SetButtonsInteractable();
  77. }
  78. public /*async*/ void SetFullScreen(Toggle isFullScreen)
  79. {
  80. #if UNITY_EDITOR || !UNITY_STANDALONE
  81. Debug.Log(isFullScreen.isOn);
  82. return;
  83. #endif
  84. //if (Opening.instance != null)
  85. //{
  86. // Opening.instance.PlayDecisionSE();
  87. //}
  88. //else if (GManager.instance != null)
  89. //{
  90. // GManager.instance.PlayDecisionSE();
  91. //}
  92. //UnityEngine.Device.Screen.fullScreen = isFullScreen.isOn;
  93. //await Task.Delay(TimeSpan.FromSeconds(Time.deltaTime));
  94. //SetButtonsInteractable();
  95. }
  96. void SetButtonsInteractable()
  97. {
  98. return;
  99. //foreach (Button button in switchWindowSizeButtons)
  100. //{
  101. // button.interactable = !UnityEngine.Device.Screen.fullScreen;
  102. //}
  103. }
  104. }