Patch_VideoController.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System.Collections;
  2. using Blue;
  3. using SC.XR.Unity.Module_InputSystem;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class Patch_VideoController : AbstractController
  7. {
  8. [SerializeField] private BoundingBox boundingBox;
  9. [SerializeField] private ManipulationHandler manipulationHandler;
  10. [SerializeField] private GameObject obj_BoundingBox;
  11. void Start()
  12. {
  13. if (GetComponent<ManipulationHandler>() != null)
  14. {
  15. Destroy(manipulationHandler);
  16. }
  17. /*
  18. this.RegisterEvent<Patch_VideoEvent>(e=>
  19. {
  20. if(e.set)
  21. {
  22. manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
  23. //Debug.LogError("manipulationHandler:"+manipulationHandler==null);
  24. boundingBox.enabled = true;
  25. manipulationHandler.enabled = true;
  26. }
  27. else
  28. {
  29. if (transform.Find("BoundingBox").gameObject != null)
  30. Destroy(transform.Find("BoundingBox").gameObject);
  31. boundingBox.enabled = false;
  32. Destroy(manipulationHandler);
  33. }
  34. });
  35. */
  36. toggle = GameObject.Find("SetBtn/Canvas/Parent/EditorBtn/Toggle").GetComponent<Toggle>();
  37. }
  38. private Toggle toggle;
  39. private bool des;
  40. private void Update()
  41. {
  42. if(!toggle.isOn)
  43. {
  44. if(des)
  45. {
  46. if (transform.Find("BoundingBox").gameObject != null)
  47. Destroy(transform.Find("BoundingBox").gameObject);
  48. boundingBox.enabled = false;
  49. Destroy(manipulationHandler);
  50. des = false;
  51. }
  52. }
  53. else
  54. {
  55. if(!des)
  56. {
  57. manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
  58. //Debug.LogError("manipulationHandler:"+manipulationHandler==null);
  59. boundingBox.enabled = true;
  60. manipulationHandler.enabled = true;
  61. des = true;
  62. }
  63. }
  64. }
  65. }