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

No Way to Have Extension Service Marked as UWP Only? (i.e. not for editor?)

Open mtaulty opened this issue 7 years ago • 4 comments

Describe the bug

I have a Mixed Reality Extension Service. I have marked it so that the only "supported platform" is "WindowsUniversal". I do not want that service to be instantiated inside of the Unity Editor.

However, when I run my code in the editor I find that the service is instantiated.

To reproduce

Make a MixedRealityExtensionService by deriving from BaseExtensionService. Mark it with a MixedRealityExtensionService attribute and specify only "WindowsUniversal" for the supported platforms.

Add it to your extension services configuration in the toolkit configuration and then debug the project in Visual Studio and see whether your service is created or not.

Expected behavior

I would not expect the service to be instantiated in the editor, only on a UWP device.

Screenshots

N/A

Your Setup (please complete the following information)

  • Unity Version [e.g. 2018.4.3f1]
  • MRTK Version [e.g. v2.0 RC2.1]

Target Platform (please complete the following information)

  • HoloLens/2

Additional context

The code in PlatformUtility.cs seems to do the checking here.

I am looking at a call to GetSupportedPlatformMask and when running in the editor it is returning "WindowsUniversal | WindowsEditor". My service says it supports "WindowsUniversal" and so the code decides to instantiate my service inside of the editor but by marking my service as "WindowsUniversal" only, I expected to keep it away from running inside of the editor.

Is the logic there correct?

mtaulty avatar Jul 04 '19 11:07 mtaulty

@davidkline-ms

wiwei avatar Jul 08 '19 21:07 wiwei

Looks like primary logic is here: MixedRealityToolkit.cs line 171

#if !UNITY_EDITOR
            if (!Application.platform.IsPlatformSupported(supportedPlatforms))
#else
            if (!EditorUserBuildSettings.activeBuildTarget.IsPlatformSupported(supportedPlatforms))
#endif
            {
                return false;
            }

I think we can just remove the macro and use Application.platform.IsPlatformSupported directly. As @mtaulty said, if a service wants to run in editor they can add WindowsUniversal | WindowsEditor

Troy-Ferrell avatar Aug 13 '19 23:08 Troy-Ferrell

This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.

stale[bot] avatar Jun 20 '20 16:06 stale[bot]

This issue has been closed by an automated process because it is stale. If this is still an issue please add a new comment with more recent details and repro steps.

stale[bot] avatar Jul 20 '20 16:07 stale[bot]