MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Bounding box improperly uses LayerMask.NameToLayer

Open StephenHodgson opened this issue 8 years ago • 3 comments

Overview

NameToLayer is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'BoundingBox' on game object 'BoundingBoxBasic'.
	See "Script Serialization" page in the Unity Manual for further details.
	UnityEngine.LayerMask:NameToLayer(String)
	HoloToolkit.Unity.UX.BoundingBox:.ctor() (at Assets/HoloToolkit/UX/Scripts/BoundingBoxes/BoundingBox.cs:175)
	
UnityException: NameToLayer is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'BoundingBox' on game object 'BoundingBoxBasic'.
	See "Script Serialization" page in the Unity Manual for further details.
	HoloToolkit.Unity.UX.BoundingBox..ctor () (at Assets/HoloToolkit/UX/Scripts/BoundingBoxes/BoundingBox.cs:175)

StephenHodgson avatar Jan 05 '18 20:01 StephenHodgson

@Railboy

StephenHodgson avatar Jan 05 '18 20:01 StephenHodgson

Now I remember why I used an integer in the first place.

Removing the NameToLayer initialization will result in an empty mask by default, which is perfectly acceptable. Let's make that change immediately.

Railboy avatar Jan 05 '18 20:01 Railboy

I've already got a fix

StephenHodgson avatar Jan 05 '18 20:01 StephenHodgson