Patch_VideoController.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. }
  67. if (boxCollider != null)
  68. boxCollider.enabled = true;
  69. else
  70. {
  71. boxCollider = gameObject.AddComponent<BoxCollider>();
  72. }
  73. }
  74. }else if(UserInfo.Instance.is20)
  75. {
  76. if (!GameManager.m_IsStart20Editor)
  77. {
  78. if (manipulationHandler != null)
  79. manipulationHandler.enabled = false;
  80. if (boundingBox != null)
  81. {
  82. boundingBox.enabled = false;
  83. if (transform.Find("BoundingBox") && transform.Find("BoundingBox").gameObject != null)
  84. transform.Find("BoundingBox").gameObject.SetActive(false);
  85. }
  86. if (boxCollider != null)
  87. boxCollider.enabled = false;
  88. }
  89. else
  90. {
  91. if (manipulationHandler == null)
  92. {
  93. manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
  94. }
  95. else
  96. {
  97. manipulationHandler.enabled = true;
  98. }
  99. if (boundingBox == null)
  100. {
  101. boundingBox = gameObject.AddComponent<BoundingBox>();
  102. boundingBox.FlattenAxis = FlattenModeType.FlattenZ;
  103. boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
  104. }
  105. else
  106. {
  107. boundingBox.enabled = true;
  108. if (transform.Find("BoundingBox") && transform.Find("BoundingBox").gameObject != null)
  109. transform.Find("BoundingBox").gameObject.SetActive(true);
  110. }
  111. if (boxCollider != null)
  112. boxCollider.enabled = true;
  113. else
  114. {
  115. boxCollider = gameObject.AddComponent<BoxCollider>();
  116. }
  117. }
  118. isBox = boxCollider.enabled;
  119. isMan = manipulationHandler.enabled;
  120. isboud = boundingBox.enabled;
  121. }
  122. }
  123. public bool isBox;
  124. public bool isMan;
  125. public bool isboud;
  126. }