123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using SC.XR.Unity.Module_InputSystem;
- using UnityEngine;
- using UnityEngine.UI;
- using static BoundingBox;
- public class Patch_ModelController : AbstractController
- {
- [SerializeField] private BoundingBox boundingBox;
- [SerializeField] private ManipulationHandler manipulationHandler;
- void Start()
- {
- if (GetComponent<ManipulationHandler>() != null)
- {
- Destroy(manipulationHandler);
- }
- if (GetComponent<BoundingBox>() != null)
- {
- Destroy(boundingBox);
- }
- toggle = GameObject.Find("SetBtn/Canvas/Parent/EditorBtn/Toggle").GetComponent<Toggle>();
- }
- private Toggle toggle;
- private void Update()
- {
- if(!toggle.isOn)
- {
- if(manipulationHandler!=null)
- Destroy(manipulationHandler);
- if (boundingBox != null)
- {
- Destroy(boundingBox);
- if (transform.Find("BoundingBox").gameObject != null)
- Destroy(transform.Find("BoundingBox").gameObject);
- }
- }
- else
- {
- if (manipulationHandler == null)
- {
- manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
- }
- if (boundingBox == null)
- {
- boundingBox = gameObject.AddComponent<BoundingBox>();
- boundingBox.FlattenAxis = FlattenModeType.DoNotFlatten;
- boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
- }
- }
- }
- }
|