/// <inheritdoc />
        protected override bool TryRenderControllerModel(Type controllerType, InputSourceType inputSourceType)
        {
            MixedRealityControllerVisualizationProfile visualizationProfile = GetControllerVisualizationProfile();

            // Intercept this call if we are using the default driver provided models.
            if (visualizationProfile == null ||
                !visualizationProfile.GetUseDefaultModelsOverride(GetType(), ControllerHandedness))
            {
                return(base.TryRenderControllerModel(controllerType, inputSourceType));
            }
            else if (controllerDictionary.TryGetValue(ControllerHandedness, out GameObject controllerModel))
            {
                TryAddControllerModelToSceneHierarchy(controllerModel);
                controllerModel.SetActive(true);
                return(true);
            }

            Debug.Log("Trying to load controller model from platform SDK");

            GameObject controllerModelGameObject = new GameObject($"{ControllerHandedness} OpenVR Controller");

            bool failedToObtainControllerModel;

            var visualizationType = visualizationProfile.GetControllerVisualizationTypeOverride(GetType(), ControllerHandedness);

            if (visualizationType != null)
            {
                // Set the platform controller model to not be destroyed when the source is lost. It'll be disabled instead,
                // and re-enabled when the same controller is re-detected.
                if (controllerModelGameObject.AddComponent(visualizationType.Type) is IMixedRealityControllerPoseSynchronizer visualizer)
                {
                    visualizer.DestroyOnSourceLost = false;
                }

                OpenVRRenderModel openVRRenderModel = controllerModelGameObject.AddComponent <OpenVRRenderModel>();
                openVRRenderModel.shader      = visualizationProfile.GetDefaultControllerModelMaterialOverride(GetType(), ControllerHandedness).shader;
                failedToObtainControllerModel = !openVRRenderModel.LoadModel(ControllerHandedness);

                if (!failedToObtainControllerModel)
                {
                    TryAddControllerModelToSceneHierarchy(controllerModelGameObject);
                    controllerDictionary.Add(ControllerHandedness, controllerModelGameObject);
                }
            }
            else
            {
                Debug.LogError("Controller visualization type not defined for controller visualization profile");
                failedToObtainControllerModel = true;
            }

            if (failedToObtainControllerModel)
            {
                Debug.LogWarning("Failed to create controller model from driver, defaulting to BaseController behavior");
                UnityEngine.Object.Destroy(controllerModelGameObject);
                return(base.TryRenderControllerModel(GetType(), InputSourceType.Controller));
            }

            return(true);
        }
Пример #2
0
        protected override void OnEnable()
        {
            base.OnEnable();

            defaultLabelWidth = EditorGUIUtility.labelWidth;

            controllerVisualizationProfile = target as MixedRealityControllerVisualizationProfile;

            controllerVisualizationType = serializedObject.FindProperty(nameof(controllerVisualizationType));
            useDefaultModels            = serializedObject.FindProperty(nameof(useDefaultModels));
            model                           = serializedObject.FindProperty(nameof(model));
            pointerPose                     = serializedObject.FindProperty(nameof(pointerPose));
            alternatePointerPose            = serializedObject.FindProperty(nameof(alternatePointerPose));
            controllerVisualizationSettings = serializedObject.FindProperty(nameof(controllerVisualizationSettings));
        }
Пример #3
0
        protected override void OnEnable()
        {
            base.OnEnable();

            defaultLabelWidth = EditorGUIUtility.labelWidth;
            defaultFieldWidth = EditorGUIUtility.fieldWidth;

            controllerVisualizationProfile = target as MixedRealityControllerVisualizationProfile;

            renderMotionControllers         = serializedObject.FindProperty("renderMotionControllers");
            controllerVisualizationType     = serializedObject.FindProperty("controllerVisualizationType");
            useDefaultModels                = serializedObject.FindProperty("useDefaultModels");
            globalLeftHandModel             = serializedObject.FindProperty("globalLeftHandModel");
            globalRightHandModel            = serializedObject.FindProperty("globalRightHandModel");
            controllerVisualizationSettings = serializedObject.FindProperty("controllerVisualizationSettings");
        }
Пример #4
0
        protected override void OnEnable()
        {
            base.OnEnable();

            defaultLabelWidth = EditorGUIUtility.labelWidth;

#if UNITY_2019
            xrPipelineUtility.Enable();
#endif // UNITY_2019

            thisProfile = target as MixedRealityControllerVisualizationProfile;

            renderMotionControllers            = serializedObject.FindProperty("renderMotionControllers");
            defaultControllerVisualizationType = serializedObject.FindProperty("defaultControllerVisualizationType");
            usePlatformControllerModels        = serializedObject.FindProperty("usePlatformModels");
            platformControllerModelMaterial    = serializedObject.FindProperty("platformModelMaterial");
            globalLeftHandedControllerModel    = serializedObject.FindProperty("globalLeftControllerModel");
            globalRightHandedControllerModel   = serializedObject.FindProperty("globalRightControllerModel");
            globalLeftHandModel             = serializedObject.FindProperty("globalLeftHandVisualizer");
            globalRightHandModel            = serializedObject.FindProperty("globalRightHandVisualizer");
            controllerVisualizationSettings = serializedObject.FindProperty("controllerVisualizationSettings");
        }
        protected override void OnEnable()
        {
            base.OnEnable();

            defaultLabelWidth = EditorGUIUtility.labelWidth;
            defaultFieldWidth = EditorGUIUtility.fieldWidth;

            if (!MixedRealityInspectorUtility.CheckMixedRealityConfigured(false))
            {
                return;
            }

            thisProfile = target as MixedRealityControllerVisualizationProfile;

            renderMotionControllers            = serializedObject.FindProperty("renderMotionControllers");
            defaultControllerVisualizationType = serializedObject.FindProperty("defaultControllerVisualizationType");
            useDefaultModels = serializedObject.FindProperty("useDefaultModels");
            globalLeftHandedControllerModel  = serializedObject.FindProperty("globalLeftControllerModel");
            globalRightHandedControllerModel = serializedObject.FindProperty("globalRightControllerModel");
            globalLeftHandModel             = serializedObject.FindProperty("globalLeftHandVisualizer");
            globalRightHandModel            = serializedObject.FindProperty("globalRightHandVisualizer");
            controllerVisualizationSettings = serializedObject.FindProperty("controllerVisualizationSettings");
        }