123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using UnityEngine;
- namespace SC.XR.Unity.Module_InputSystem.InputDeviceHand {
- public class HandDetector : DetectorBase {
- private IPointer handPointer;
- public InputDeviceHandPart inputDeviceHandPart {
- get {
- return inputDevicePartBase as InputDeviceHandPart;
- }
- }
- public FarPointer farPointer {
- get {
- return Transition<FarPointer>(pointerBase);
- }
- }
- [SerializeField]
- TouchPointer mTouchPointer;
- public TouchPointer touchPointer {
- get {
- if(mTouchPointer == null) {
- mTouchPointer = GetComponentInChildren<TouchPointer>(true);
- }
- return mTouchPointer;
- }
- set {
- mTouchPointer = value;
- }
- }
- [SerializeField]
- GrabPointer mGrabPointer;
- public GrabPointer grabPointer {
- get {
- if(mGrabPointer == null) {
- mGrabPointer = GetComponentInChildren<GrabPointer>(true);
- }
- return mGrabPointer;
- }
- set {
- mGrabPointer = value;
- }
- }
- public override void OnSCAwake() {
- base.OnSCAwake();
- AddModule(touchPointer);
- AddModule(grabPointer);
- }
- public override void OnSCStart() {
- //base.OnSCStart();
- //touchPointer?.ModuleStart();
- //grabPointer?.ModuleStart();
- }
- public override void OnSCLateUpdate() {
- base.OnSCLateUpdate();
- if(touchPointer.IsFocusLocked || grabPointer.IsFocusLocked || farPointer.IsFocusLocked) {
- } else {
- if(touchPointer.FindClosestTouchableForLayerMask()) {
- if(touchPointer.IsModuleStarted == false) {
- touchPointer.ModuleStart();
- handPointer = touchPointer;
- }
- if(grabPointer.IsModuleStarted) {
- grabPointer.ModuleStop();
- }
- if(farPointer.IsModuleStarted) {
- farPointer.ModuleStop();
- }
- } else if(grabPointer.FindClosestGrabbableForLayerMask()) {
- if(touchPointer.IsModuleStarted ) {
- touchPointer.ModuleStop();
- }
- if(grabPointer.IsModuleStarted == false) {
- grabPointer.ModuleStart();
- handPointer = grabPointer;
- }
- if(farPointer.IsModuleStarted) {
- farPointer.ModuleStop();
- }
- } else {
- if(touchPointer.IsModuleStarted) {
- touchPointer.ModuleStop();
- }
- if(grabPointer.IsModuleStarted ) {
- grabPointer.ModuleStop();
- }
- if(farPointer.IsModuleStarted == false) {
- farPointer.ModuleStart();
- handPointer = farPointer;
- }
- }
- }
- currentPointer = handPointer;
- }
- public override void OnSCDestroy() {
- base.OnSCDestroy();
- touchPointer = null;
- grabPointer = null;
- }
- }
- }
|