123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- 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<BoundingBox>();
- manipulationHandler = GetComponent<ManipulationHandler>();
- boxCollider = GetComponent<BoxCollider>();
- 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<Toggle>();
- }
- 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<ManipulationHandler>();
- }
- if (boundingBox == null)
- {
- boundingBox = gameObject.AddComponent<BoundingBox>();
- boundingBox.FlattenAxis = FlattenModeType.DoNotFlatten;
- boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
- }
- if (boxCollider != null)
- boxCollider.enabled = true;
- else
- {
- boxCollider = gameObject.AddComponent<BoxCollider>();
- }
- }
- }
- 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<ManipulationHandler>();
- }
- else
- {
- manipulationHandler.enabled = true;
- }
- if (boundingBox == null)
- {
- boundingBox = gameObject.AddComponent<BoundingBox>();
- 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<BoxCollider>();
- }
- }
- }
- }
- }
|