123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using UnityEngine;
- namespace SC.XR.Unity.Module_InputSystem {
-
-
-
- public enum TouchableEventType {
- Touch,
- Pointer,
- Auto,
- }
- public enum NormalType {
- X,
- Y,
- Z,
- NX,
- NY,
- NZ,
- }
-
-
-
-
- public abstract class BaseNearInteractionTouchable : MonoBehaviour {
- [SerializeField]
- protected TouchableEventType eventsToReceive = TouchableEventType.Touch;
-
-
-
- public TouchableEventType EventsToReceive { get => eventsToReceive; set => eventsToReceive = value; }
- public NormalType NormalType = NormalType.NZ;
- public Vector3 Normal {
- get {
- if(NormalType == NormalType.NZ) {
- return -transform.forward;
- } else if(NormalType == NormalType.Z) {
- return transform.forward;
- } else if(NormalType == NormalType.X) {
- return transform.right;
- } else if(NormalType == NormalType.NX) {
- return -transform.right;
- } else if(NormalType == NormalType.Y) {
- return transform.up;
- } else {
- return -transform.up;
- }
- }
- }
- [SerializeField]
- private Transform center;
- public Transform Center {
- get {
- return center != null ? center : transform;
- }
- }
- [Tooltip("Distance in front of the surface at which you will receive a touch completed event")]
- [SerializeField]
- protected float debounceThreshold = 0.01f;
-
-
-
-
-
-
-
- public float DebounceThreshold { get => debounceThreshold; set => debounceThreshold = value; }
- protected virtual void OnValidate() {
- debounceThreshold = Math.Max(debounceThreshold, 0);
- }
- public abstract float DistanceToTouchable(Vector3 samplePoint, out Vector3 normal);
- }
- }
|