using SC.XR.Unity.Module_InputSystem; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class AllMoveEvent : MonoBehaviour { // Start is called before the first frame update void Start() { DispatcherBase.KeyDownDelegateRegister(downEvent); DispatcherBase.KeyUpDelegateRegister(upEvent); } InputDevicePartBase NowPart; GameObject pz; private void upEvent(InputKeyCode keyCode, InputDevicePartBase part) { if (part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject != null && (part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent() == null || part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent() == null)) { checkMoveUp(pz, part); } pz = null; NowPart = null; } public void checkMoveUp(GameObject obj, InputDevicePartBase part) { if (obj) { ManipulationHandler m = obj.GetComponent(); if (m != null) { if (!m.enabled) { return; } if (!m.isParentDrag && !obj.name.Contains("Root") && !obj.name.Contains("BoundingBox")) { m.OnPointerUp(part.inputDataBase.SCPointEventData); } } else { if (obj.transform.parent != null && !obj.name.Contains("Root") && !obj.name.Contains("BoundingBox")) checkMoveUp(obj.transform.parent.gameObject, part); } } } private void downEvent(InputKeyCode keyCode, InputDevicePartBase part) { if (part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject != null && (part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent() == null || part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent() == null)) { checkMoveDown(part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject, part); } NowPart = part; } public void checkMoveDown(GameObject obj, InputDevicePartBase part) { if (obj) { ManipulationHandler m = obj.GetComponent(); if (m != null) { if (!m.enabled) { return; } if (!m.isParentDrag && !obj.name.Contains("Root") && !obj.name.Contains("BoundingBox")) { m.OnPointerDown(part.inputDataBase.SCPointEventData); pz = obj; } } else { if (obj.transform.parent != null && !obj.name.Contains("Root") && !obj.name.Contains("BoundingBox")) checkMoveDown(obj.transform.parent.gameObject, part); } } } // Update is called once per frame void Update() { if (NowPart != null && pz != null) { checkMoveDrag(pz, NowPart); } } public void checkMoveDrag(GameObject obj, InputDevicePartBase part) { if (obj) { ManipulationHandler m = obj.GetComponent(); if (m != null && !obj.name.Contains("Root") && !obj.name.Contains("BoundingBox")) { if (!m.enabled) { return; } if (!m.isParentDrag) m.OnDrag(part.inputDataBase.SCPointEventData); } else { if (obj.transform.parent != null && !obj.name.Contains("Root") && !obj.name.Contains("BoundingBox")) { checkMoveDrag(obj.transform.parent.gameObject, part); } } } } }