Beispiel #1
0
        private void TryRenderControllerModelFromOculus()
        {
#if OCULUSINTEGRATION_PRESENT
            OculusXRSDKDeviceManager deviceManager = CoreServices.GetInputSystemDataProvider <OculusXRSDKDeviceManager>();

            if (deviceManager.IsNotNull())
            {
                GameObject platformVisualization = null;
                if (ControllerHandedness == Handedness.Left)
                {
                    platformVisualization = deviceManager.leftControllerHelper.gameObject;
                }
                else if (ControllerHandedness == Handedness.Right)
                {
                    platformVisualization = deviceManager.rightControllerHelper.gameObject;
                }
                RegisterControllerVisualization(platformVisualization);
            }
#endif

            if (this != null)
            {
                if (OculusControllerVisualization != null &&
                    MixedRealityControllerModelHelpers.TryAddVisualizationScript(OculusControllerVisualization, GetType(), ControllerHandedness) &&
                    TryAddControllerModelToSceneHierarchy(OculusControllerVisualization))
                {
                    OculusControllerVisualization.SetActive(true);
                    return;
                }

                Debug.LogWarning("Failed to obtain Oculus controller model; defaulting to BaseController behavior.");
                base.TryRenderControllerModel(GetType(), InputSource.SourceType);
            }
        }
        private async void TryRenderControllerModelWithModelProvider()
        {
            if (controllerModelProvider == null)
            {
                controllerModelProvider = new OpenXRControllerModelProvider(ControllerHandedness);
            }

            GameObject controllerModel = await controllerModelProvider.TryGenerateControllerModelFromPlatformSDK();

            if (this != null)
            {
                if (controllerModel != null &&
                    MixedRealityControllerModelHelpers.TryAddVisualizationScript(controllerModel, GetType(), ControllerHandedness) &&
                    TryAddControllerModelToSceneHierarchy(controllerModel))
                {
                    controllerModel.SetActive(true);
                    return;
                }

                Debug.LogWarning("Failed to create controller model from driver; defaulting to BaseController behavior.");
                base.TryRenderControllerModel(GetType(), InputSource.SourceType);
            }

            if (controllerModel != null)
            {
                // If we didn't successfully set up the model and add it to the hierarchy (which returns early), set it inactive.
                controllerModel.SetActive(false);
            }
        }
        private async void TryRenderControllerModelFromOculus()
        {
            await WaitForOculusVisuals();

            if (this != null)
            {
                if (OculusControllerVisualization != null &&
                    MixedRealityControllerModelHelpers.TryAddVisualizationScript(OculusControllerVisualization, GetType(), ControllerHandedness) &&
                    TryAddControllerModelToSceneHierarchy(OculusControllerVisualization))
                {
                    OculusControllerVisualization.SetActive(true);
                    return;
                }

                Debug.LogWarning("Failed to obtain Oculus controller model; defaulting to BaseController behavior.");
                base.TryRenderControllerModel(GetType(), InputSource.SourceType);
            }
        }