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; [SerializeField] private BoxCollider boxCollider; void Start() { boundingBox = GetComponent(); manipulationHandler = GetComponent(); boxCollider = GetComponent(); if (manipulationHandler != null) { manipulationHandler.enabled = false; } if (boundingBox != null) { boundingBox.enabled = false; } if (boxCollider != null) { boxCollider.enabled = false; } if (GameObject.Find("SetBtn/2.1/Canvas/Parent/EditorBtn/Toggle")) toggle = GameObject.Find("SetBtn/2.1/Canvas/Parent/EditorBtn/Toggle").GetComponent(); } private Toggle toggle; private void Update() { if (toggle && !UserInfo.Instance.is20) { if (!toggle.isOn) { if (manipulationHandler != null) { Destroy(manipulationHandler); manipulationHandler = null; } if (boundingBox != null) { Destroy(boundingBox); boundingBox = null; if (transform.Find("BoundingBox")!=null&&transform.Find("BoundingBox").gameObject != null) Destroy(transform.Find("BoundingBox").gameObject); } if (boxCollider != null) boxCollider.enabled = false; } else { if (manipulationHandler == null) { manipulationHandler = gameObject.AddComponent(); } if (boundingBox == null) { boundingBox = gameObject.AddComponent(); boundingBox.FlattenAxis = FlattenModeType.DoNotFlatten; boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale; } if (boxCollider != null) boxCollider.enabled = true; else { boxCollider = gameObject.AddComponent(); } } } else if (UserInfo.Instance.is20) { if (!GameManager.m_IsStart20Editor) { if (manipulationHandler != null) manipulationHandler.enabled = false; if (boundingBox != null) { boundingBox.enabled = false; if (transform.Find("BoundingBox") && transform.Find("BoundingBox").gameObject != null) transform.Find("BoundingBox").gameObject.SetActive(false); } if (boxCollider != null) boxCollider.enabled = false; } else { if (manipulationHandler == null) { manipulationHandler = gameObject.AddComponent(); } else { manipulationHandler.enabled = true; } if (boundingBox == null) { boundingBox = gameObject.AddComponent(); boundingBox.FlattenAxis = FlattenModeType.DoNotFlatten; boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale; } else { boundingBox.enabled = true; if (transform.Find("BoundingBox") && transform.Find("BoundingBox").gameObject != null) transform.Find("BoundingBox").gameObject.SetActive(true); } if (boxCollider != null) boxCollider.enabled = true; else { boxCollider = gameObject.AddComponent(); } } } } }