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

AnchorLoaded event in ImportExportAnchorManager #837

Closed FlorianJa closed 7 years ago

FlorianJa commented 7 years ago

Why is the AnchorLoaded Event in ImportExportAnchorManager class disabled for UnityEditor?

https://github.com/Microsoft/HoloToolkit-Unity/blob/master/Assets/HoloToolkit-Tests/Sharing/Scripts/ImportExportAnchorManager.cs#L117

I can not build an app were i hook up on this event because unity throws an error because AnchorLoaded is unknown.

Is this a bug or design decision?

StephenHodgson commented 7 years ago

Design decision because the editor does not initialize the AnchorStore. This class will be depreciated by PR https://github.com/Microsoft/HoloToolkit-Unity/pull/742.

StephenHodgson commented 7 years ago

Also make sure your building for WSA.

FlorianJa commented 7 years ago

Also make sure your building for WSA.

I am building for WSA.

Design decision because the editor does not initialize the AnchorStore.

But how to use this event for example like this in anther class? ImportExportAnchorManager.Instance.AnchorLoaded += Instance_AnchorLoaded;

FlorianJa commented 7 years ago

i solved my problem by adding the same preprocessor directive

#if UNITY_WSA && !UNITY_EDITOR

ImportExportAnchorManager.Instance.AnchorLoaded += Instance_AnchorLoaded;

#endif