7 namespace HoloToolkit.Examples.SpatialUnderstandingFeatureOverview
23 [Tooltip(
"Distance, in meters, to offset the cursor from the collision point.")]
24 public float DistanceFromCollision = 0.01f;
26 private Quaternion cursorDefaultRotation;
28 private MeshRenderer meshRenderer;
34 meshRenderer = gameObject.GetComponent<MeshRenderer>();
36 if (meshRenderer == null)
38 Debug.LogError(
"This script requires that your cursor asset has a MeshRenderer component on it.");
43 meshRenderer.enabled =
false;
46 cursorDefaultRotation = gameObject.transform.rotation;
53 if (gazeManager == null)
55 Debug.LogError(
"Must have a GazeManager somewhere in the scene.");
60 Debug.LogError(
"The cursor has a layer that is checked in the GazeManager's Raycast Layer Mask. Change the cursor layer (e.g.: to Ignore Raycast) or uncheck the layer in GazeManager: " +
61 LayerMask.LayerToName(gameObject.layer));
79 if (meshRenderer == null || gazeManager == null)
88 meshRenderer.enabled = rayResult.
Hit;
91 gameObject.transform.position = rayResult.
Position + rayResult.
Normal * DistanceFromCollision;
94 gameObject.transform.up = rayResult.
Normal;
95 gameObject.transform.rotation *= cursorDefaultRotation;