Skip to content

Commit 4e64d4a

Browse files
Stephen HodgsonStephen Hodgson
authored andcommitted
Changed Awake to Start function. Fixes Layer reacast mask to use bitwise op for calculation.
1 parent 6add245 commit 4e64d4a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Assets/HoloToolkit/Input/Scripts/BasicCursor.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ public struct RaycastResult
2828

2929
private bool hasLoggedGazeManagerError;
3030

31-
protected virtual void Awake()
31+
protected virtual void Start()
3232
{
33-
if ((GazeManager.Instance.RaycastLayerMask & this.gameObject.layer) == 0)
33+
if ((GazeManager.Instance.RaycastLayerMask & (1 << gameObject.layer)) != 0)
3434
{
3535
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: " +
36-
LayerMask.LayerToName(this.gameObject.layer));
36+
LayerMask.LayerToName(gameObject.layer));
3737
}
3838

39-
meshRenderer = this.gameObject.GetComponent<MeshRenderer>();
39+
meshRenderer = gameObject.GetComponent<MeshRenderer>();
4040

4141
if (meshRenderer == null)
4242
{
@@ -48,7 +48,7 @@ protected virtual void Awake()
4848
meshRenderer.enabled = false;
4949

5050
// Cache the cursor default rotation so the cursor can be rotated with respect to the original orientation.
51-
cursorDefaultRotation = this.gameObject.transform.rotation;
51+
cursorDefaultRotation = gameObject.transform.rotation;
5252
}
5353

5454
protected virtual RaycastResult CalculateRayIntersect()
@@ -83,11 +83,11 @@ protected virtual void LateUpdate()
8383
meshRenderer.enabled = rayResult.Hit;
8484

8585
// Place the cursor at the calculated position.
86-
this.gameObject.transform.position = rayResult.Position + rayResult.Normal * DistanceFromCollision;
86+
gameObject.transform.position = rayResult.Position + rayResult.Normal * DistanceFromCollision;
8787

8888
// Reorient the cursor to match the hit object normal.
89-
this.gameObject.transform.up = rayResult.Normal;
90-
this.gameObject.transform.rotation *= cursorDefaultRotation;
89+
gameObject.transform.up = rayResult.Normal;
90+
gameObject.transform.rotation *= cursorDefaultRotation;
9191
}
9292
}
9393
}

0 commit comments

Comments
 (0)