NearInterationGrabbable.cs 834 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine;
  7. namespace SC.XR.Unity.Module_InputSystem {
  8. public class NearInterationGrabbable : MonoBehaviour {
  9. public Transform GrabbaleTransform;
  10. BoxCollider boxCollider;
  11. public virtual float DistanceToGrabbable(Vector3 samplePoint) {
  12. if(GrabbaleTransform == null) {
  13. GrabbaleTransform = transform;
  14. }
  15. if(boxCollider == null) {
  16. boxCollider = GrabbaleTransform.GetComponent<BoxCollider>();
  17. if(boxCollider == null) {
  18. return float.PositiveInfinity;
  19. }
  20. }
  21. return (samplePoint - GrabbaleTransform.position).magnitude;
  22. }
  23. }
  24. }