Patch_VideoController.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using SC.XR.Unity.Module_InputSystem;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using static BoundingBox;
  5. public class Patch_VideoController : AbstractController
  6. {
  7. [SerializeField] private BoundingBox boundingBox;
  8. [SerializeField] private ManipulationHandler manipulationHandler;
  9. [SerializeField] private BoxCollider boxCollider;
  10. void Start()
  11. {
  12. boundingBox = GetComponent<BoundingBox>();
  13. manipulationHandler = GetComponent<ManipulationHandler>();
  14. boxCollider = GetComponent<BoxCollider>();
  15. if (manipulationHandler != null)
  16. {
  17. manipulationHandler.enabled = false;
  18. }
  19. if (boundingBox != null)
  20. {
  21. boundingBox.enabled = false;
  22. }
  23. if (boxCollider != null)
  24. {
  25. boxCollider.enabled = false;
  26. }
  27. if (GameObject.Find("SetBtn/2.1/Canvas/Parent/EditorBtn/Toggle"))
  28. toggle = GameObject.Find("SetBtn/2.1/Canvas/Parent/EditorBtn/Toggle").GetComponent<Toggle>();
  29. }
  30. private Toggle toggle;
  31. private void Update()
  32. {
  33. // Debug.Log("GameManager.m_IsStart20Editor Update");
  34. if (toggle&&!UserInfo.Instance.is20)
  35. {
  36. // Debug.Log("GameManager.m_IsStart20Editor !is20");
  37. if (!toggle.isOn)
  38. {
  39. if (manipulationHandler != null)
  40. manipulationHandler.enabled=false;
  41. if (boundingBox != null)
  42. {
  43. boundingBox.enabled = false;
  44. if (transform.Find("BoundingBox")&&transform.Find("BoundingBox").gameObject != null)
  45. transform.Find("BoundingBox").gameObject.SetActive(false);
  46. }
  47. if (boxCollider != null)
  48. boxCollider.enabled = false;
  49. }
  50. else
  51. {
  52. if (manipulationHandler == null)
  53. {
  54. manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
  55. }
  56. else
  57. {
  58. manipulationHandler.enabled = true;
  59. }
  60. if (boundingBox == null)
  61. {
  62. boundingBox = gameObject.AddComponent<BoundingBox>();
  63. boundingBox.FlattenAxis = FlattenModeType.FlattenZ;
  64. boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
  65. }else
  66. {
  67. boundingBox.enabled = true;
  68. if (transform.Find("BoundingBox") && transform.Find("BoundingBox").gameObject != null)
  69. transform.Find("BoundingBox").gameObject.SetActive(true);
  70. }
  71. if (boxCollider != null)
  72. boxCollider.enabled = true;
  73. else
  74. {
  75. boxCollider = gameObject.AddComponent<BoxCollider>();
  76. }
  77. }
  78. }else if(UserInfo.Instance.is20)
  79. {
  80. Debug.Log("GameManager.m_IsStart20Editor !GameManager.m_IsStart20Editor");
  81. if (!GameManager.m_IsStart20Editor)
  82. {
  83. Debug.Log("GameManager.m_IsStart20Editor");
  84. if (manipulationHandler != null)
  85. manipulationHandler.enabled = false;
  86. if (boundingBox != null)
  87. {
  88. boundingBox.enabled = false;
  89. if (transform.Find("BoundingBox") && transform.Find("BoundingBox").gameObject != null)
  90. transform.Find("BoundingBox").gameObject.SetActive(false);
  91. }
  92. if (boxCollider != null)
  93. boxCollider.enabled = false;
  94. }
  95. else
  96. {
  97. if (manipulationHandler == null)
  98. {
  99. manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
  100. }
  101. else
  102. {
  103. manipulationHandler.enabled = true;
  104. }
  105. if (boundingBox == null)
  106. {
  107. boundingBox = gameObject.AddComponent<BoundingBox>();
  108. boundingBox.FlattenAxis = FlattenModeType.FlattenZ;
  109. boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
  110. }
  111. else
  112. {
  113. boundingBox.enabled = true;
  114. if (transform.Find("BoundingBox") && transform.Find("BoundingBox").gameObject != null)
  115. transform.Find("BoundingBox").gameObject.SetActive(true);
  116. }
  117. if (boxCollider != null)
  118. boxCollider.enabled = true;
  119. else
  120. {
  121. boxCollider = gameObject.AddComponent<BoxCollider>();
  122. }
  123. }
  124. isBox = boxCollider.enabled;
  125. isMan = manipulationHandler.enabled;
  126. isboud = boundingBox.enabled;
  127. }
  128. }
  129. public bool isBox;
  130. public bool isMan;
  131. public bool isboud;
  132. }