ResizeWindow.cs 3.1 KB

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