No Way to Have Extension Service Marked as UWP Only? (i.e. not for editor?)
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?
@davidkline-ms
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
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.
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.