Patch_VideoController.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. if(toggle&&!UserInfo.Instance.is20)
  34. {
  35. if (!toggle.isOn)
  36. {
  37. if (manipulationHandler != null)
  38. manipulationHandler.enabled=false;
  39. if (boundingBox != null)
  40. {
  41. boundingBox.enabled = false;
  42. if (transform.Find("BoundingBox")&&transform.Find("BoundingBox").gameObject != null)
  43. transform.Find("BoundingBox").gameObject.SetActive(false);
  44. }
  45. if (boxCollider != null)
  46. boxCollider.enabled = false;
  47. }
  48. else
  49. {
  50. if (manipulationHandler == null)
  51. {
  52. manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
  53. }
  54. else
  55. {
  56. manipulationHandler.enabled = true;
  57. }
  58. if (boundingBox == null)
  59. {
  60. boundingBox = gameObject.AddComponent<BoundingBox>();
  61. boundingBox.FlattenAxis = FlattenModeType.FlattenZ;
  62. boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
  63. }else
  64. {
  65. boundingBox.enabled = true;
  66. if (transform.Find("BoundingBox") && transform.Find("BoundingBox").gameObject != null)
  67. transform.Find("BoundingBox").gameObject.SetActive(true);
  68. }
  69. if (boxCollider != null)
  70. boxCollider.enabled = true;
  71. else
  72. {
  73. boxCollider = gameObject.AddComponent<BoxCollider>();
  74. }
  75. }
  76. }else if(UserInfo.Instance.is20)
  77. {
  78. if (!GameManager.m_IsStart20Editor)
  79. {
  80. if (manipulationHandler != null)
  81. manipulationHandler.enabled = false;
  82. if (boundingBox != null)
  83. {
  84. boundingBox.enabled = false;
  85. if (transform.Find("BoundingBox") && transform.Find("BoundingBox").gameObject != null)
  86. transform.Find("BoundingBox").gameObject.SetActive(false);
  87. }
  88. if (boxCollider != null)
  89. boxCollider.enabled = false;
  90. }
  91. else
  92. {
  93. if (manipulationHandler == null)
  94. {
  95. manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
  96. }
  97. else
  98. {
  99. manipulationHandler.enabled = true;
  100. }
  101. if (boundingBox == null)
  102. {
  103. boundingBox = gameObject.AddComponent<BoundingBox>();
  104. boundingBox.FlattenAxis = FlattenModeType.FlattenZ;
  105. boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
  106. }
  107. else
  108. {
  109. boundingBox.enabled = true;
  110. if (transform.Find("BoundingBox") && transform.Find("BoundingBox").gameObject != null)
  111. transform.Find("BoundingBox").gameObject.SetActive(true);
  112. }
  113. if (boxCollider != null)
  114. boxCollider.enabled = true;
  115. else
  116. {
  117. boxCollider = gameObject.AddComponent<BoxCollider>();
  118. }
  119. }
  120. isBox = boxCollider.enabled;
  121. isMan = manipulationHandler.enabled;
  122. isboud = boundingBox.enabled;
  123. }
  124. }
  125. public bool isBox;
  126. public bool isMan;
  127. public bool isboud;
  128. }