123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- 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<BoxCollider>() == null || part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent<ManipulationHandler>() == null))
- {
- checkMoveUp(pz, part);
- }
- pz = null;
- NowPart = null;
- }
- public void checkMoveUp(GameObject obj, InputDevicePartBase part)
- {
- if (obj)
- {
- ManipulationHandler m = obj.GetComponent<ManipulationHandler>();
- 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<BoxCollider>() == null || part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent<ManipulationHandler>() == null))
- {
- checkMoveDown(part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject, part);
- }
- NowPart = part;
- }
- public void checkMoveDown(GameObject obj, InputDevicePartBase part)
- {
- if (obj)
- {
- ManipulationHandler m = obj.GetComponent<ManipulationHandler>();
- 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<ManipulationHandler>();
- 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);
- }
- }
- }
- }
- }
|