1 minute read

using UnityEngine

Professional Experience at NBBJ

1 using UnityEngine; 2 using UnityEngine.XR.MagicLeap; 3 4 namespace MagicLeap 5 { 6 /// <summary> 7 /// Updates the transform an color on the Hit Position and Normal from the assigned object. 8 /// </summary> 9 public class RaycastPlaneVivo 10 { 11 #region Private Variables 12 [SerializeField, Tooltip("The reference to the class to handle results from." 13 private BaseRaycast _raycast 14 15 [SerializeField, Tooltip("The default distance for the cursor when a hit is not detected." 16 private float _defaultDistance 17 18 [SerializeField, Tooltip("When enabled the cursor will scale down once a certain minimum distance is hit.")] 19 private bool _scaleWhenClose 20 21 // Stores default color 22 private Color _color; 23 24 // Stores result of raycast 25 private bool _hit = false; 26 27 // Stores Renderer component 28 private Renderer _render; 29 #endregion 30 31 #region Public Properties 32 /// <summary> 33 /// Gettor for _hit. 34 /// </summary> 35 public bool Hit 36 { 37 get 38 { 39 return _hit; 40 41 } 42 public GameObject prefab; 43 #endregion 44 45 #region Unity Methods 46 /// <summary> 47 /// Initializes variables and makes sure needed components exist. 48 /// </summary> 49 void Awake() 50 { 51 // Check if the Layer is set to Default and disable any child colliders. 52 53 54

Advertisement

55 56 57 58 59 60 61 62 63 64 65

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

84 } 85 #endregion 86 87 #region Event Handlers 88 /// <summary> 89 /// Callback handler called when raycast has a result. 90 /// Updates the transform an color on the Hit Position and Normal from the assigned object. 91 /// </summary> 92 /// <param name="state"> The state of the raycast result.</param> 93 /// <param name="result"> The hit results (point, normal, distance).</param> 94 /// <param name="confidence"> Confidence value of hit. 0 no hit, 1 sure hit.</param> 95 public void OnRaycastHit(MLWorldRays confidence) 96 { 97 //Debug.Log("RaycastPlaneVivo Called Hit Function!"); 98 if (state != MLWorldRays

99 100 101 102 103 104 105 106 107

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

This article is from: