ResizeWindow.cs 2.9 KB

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