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

vNext Task: Expose the currently enabled and loaded XR SDK

Open david-c-kline opened this issue 8 years ago • 17 comments

Overview

At the MR Dev Summit (08/2018) there was a discussion about the desire/need to customize an application's UX based on the platform on which it is running. To enable developers to perform these customizations, we should provide a mechanism for them to ask the MixedRealityManager to return the platform.

I suggest we return values based on the VR SDK setting in Unity. Ex:

  • Windows Mixed Reality
  • OpenVR
  • ARKit
  • ARCore
  • etc

Requirements

Need an enum that defines the platform and an API to ask for it,

Acceptance Criteria

  • [ ] Can ask for the platform
  • [ ] Tested on Windows Mixed Reality and OpenVR

david-c-kline avatar Sep 04 '18 22:09 david-c-kline

Pretty sure this is already built into Unity, but I could be wrong.

StephenHodgson avatar Sep 04 '18 22:09 StephenHodgson

I didn't see something that do exactly what @davidkline-ms ask for. But there's couple of method in PlayerSettings class : https://docs.unity3d.com/ScriptReference/PlayerSettings.GetAvailableVirtualRealitySDKs.html https://docs.unity3d.com/ScriptReference/PlayerSettings.GetVirtualRealitySupported.html https://docs.unity3d.com/ScriptReference/PlayerSettings.GetVirtualRealitySDKs.html https://docs.unity3d.com/ScriptReference/PlayerSettings.GetAvailableVirtualRealitySDKs.html

architekth avatar Sep 05 '18 07:09 architekth

Yeah, most of those only enumerate what is defined in the project and not really what is actively connected. But I suppose it will be easy enough for each device manager to set an enum for the running platform, on top of what Unity provides.

SimonDarksideJ avatar Sep 05 '18 10:09 SimonDarksideJ

Related to #2257

StephenHodgson avatar Sep 06 '18 19:09 StephenHodgson

Additionally it would be nice if the device info contains if it's opaque, and if opaque, has the height of the head above measured ground.

wassx avatar Sep 19 '18 19:09 wassx

We already support that:

MixedRealityManager.Instance.ActiveProfile.CameraProfile.IsOpaque which is cross platform.

StephenHodgson avatar Sep 19 '18 20:09 StephenHodgson

When using like this, I get a "Cannot access static property 'IsOpaque' in non-static context". So MixedRealityCameraProfile.IsOpaque is the way how to use?

wassx avatar Sep 23 '18 08:09 wassx

You've got to get it from the mixed reality manager's active profile.

StephenHodgson avatar Sep 23 '18 15:09 StephenHodgson

Hm, maybe I miss something, but in the MixedRealityManager:157 it is accessed in a static context?

wassx avatar Sep 24 '18 08:09 wassx

The Mixed Reality Manager is the one and only singleton in the entire vNext generation of the Mixed Reality Toolkit. Accessing it anywhere in code simply involves:

MixedRealityManager.Instance

From there, you can interrogate the Current runtime configuration of the Manager, including all the child component configuration from:

MixedRealityManager.Instance.ActiveProfile

There are also some other static properties of the MRManager, to enable quick discovery of certain services and whether the MRManager has been configured.

Behind all this, is also the service discovery framework, used to Get / Add or manage any service / manager / components currently registered with the manager through

MixedRealityManager.Instance.Getmanager<ManagerInterface>
// or
MixedRealityManager.Instance.Getmanager(ManagerType)

Hope that helps clear that up.

SimonDarksideJ avatar Sep 24 '18 09:09 SimonDarksideJ

Ok, but that would include adding a non-static accessor like: public bool IsOpaqueDisplay() { return IsOpaque; // the static } ? I think I'm stumbling over my own feet...

wassx avatar Sep 24 '18 10:09 wassx

Sorry, the IsOpaque property on the MixedRealityCameraProfile is a static, so you can simply access it with

If(Core.Definitions.MixedRealityCameraProfile.IsOpaque)

SimonDarksideJ avatar Sep 24 '18 10:09 SimonDarksideJ

Ah! Maybe we shouldn't have that be static and part of our interface definition. 🤔 Sorry that was on me, when I ported it.

StephenHodgson avatar Sep 24 '18 12:09 StephenHodgson

PR submitted.
@wassx the correct way of accessing the profile should be

MixedRealityManager.ActiveProfile.CameraProfile.IsOpaque

Which should be addressed on that PR, correctly getting it from the profile and not a static property

SimonDarksideJ avatar Sep 24 '18 13:09 SimonDarksideJ

@SimonDarksideJ Thank you!

wassx avatar Sep 24 '18 13:09 wassx

Platform implies what the project is building for (i.e. Android, iOS, Windows Standalone, UWP, etc.) Updating title to reflect VR SDK target.

StephenHodgson avatar Nov 09 '18 15:11 StephenHodgson

This can be checked via XRGeneralSettings.Instance.Manager.activeLoader and comparing against the type or name.

david-c-kline avatar Feb 25 '21 23:02 david-c-kline