Patch_VideoController.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. void Start()
  10. {
  11. if (GetComponent<ManipulationHandler>() != null)
  12. {
  13. GetComponent<ManipulationHandler>().enabled = false;
  14. }
  15. if (GetComponent<BoundingBox>() != null)
  16. {
  17. GetComponent<BoundingBox>().enabled = false;
  18. }
  19. toggle = GameObject.Find("SetBtn/2.1/Canvas/Parent/EditorBtn/Toggle").GetComponent<Toggle>();
  20. }
  21. private Toggle toggle;
  22. private void Update()
  23. {
  24. if(toggle)
  25. {
  26. if (!toggle.isOn)
  27. {
  28. if (manipulationHandler != null)
  29. manipulationHandler.enabled=false;
  30. if (boundingBox != null)
  31. {
  32. boundingBox.enabled = false;
  33. if (transform.Find("BoundingBox")&&transform.Find("BoundingBox").gameObject != null)
  34. transform.Find("BoundingBox").gameObject.SetActive(false);
  35. }
  36. }
  37. else
  38. {
  39. if (manipulationHandler == null)
  40. {
  41. manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
  42. }
  43. else
  44. {
  45. manipulationHandler.enabled = true;
  46. }
  47. if (boundingBox == null)
  48. {
  49. boundingBox = gameObject.AddComponent<BoundingBox>();
  50. boundingBox.FlattenAxis = FlattenModeType.FlattenZ;
  51. boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
  52. }else
  53. {
  54. boundingBox.enabled = true;
  55. }
  56. }
  57. }
  58. }
  59. }