microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6.01k stars 2.12k forks source link

Bounding box improperly uses LayerMask.NameToLayer #1592

Closed StephenHodgson closed 6 years ago

StephenHodgson commented 6 years ago

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 commented 6 years ago

@Railboy

Railboy commented 6 years ago

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.

StephenHodgson commented 6 years ago

I've already got a fix