Example #1
0
        /// <summary>
        /// Look if the controller was already loaded. This could happen if the
        /// GameObject was instantiated at runtime and the model loaded event has already fired.
        /// </summary>
        private void CheckModelAlreadyLoaded()
        {
            if (!MotionControllerVisualizer.ConfirmInitialized())
            {
                // The motion controller visualizer singleton could not be found.
                return;
            }

#if UNITY_WSA && UNITY_2017_2_OR_NEWER
            MotionControllerInfo newController;
            if (MotionControllerVisualizer.Instance.TryGetControllerModel(handedness, out newController))
            {
                AddControllerTransform(newController);
            }
#endif
        }
Example #2
0
        protected virtual void OnEnable()
        {
#if UNITY_WSA && UNITY_2017_2_OR_NEWER
            if (!MotionControllerVisualizer.ConfirmInitialized())
            {
                // The motion controller visualizer singleton could not be found.
                return;
            }

            if (started)
            {
                CheckModelAlreadyLoaded();
            }

            MotionControllerVisualizer.Instance.OnControllerModelLoaded   += AddControllerTransform;
            MotionControllerVisualizer.Instance.OnControllerModelUnloaded += RemoveControllerTransform;
#endif
        }
Example #3
0
        protected virtual void OnEnable()
        {
#if UNITY_WSA && UNITY_2017_2_OR_NEWER
            if (!MotionControllerVisualizer.ConfirmInitialized())
            {
                // The motion controller visualizer singleton could not be found.
                return;
            }
#endif

            // Look if the controller has loaded.
            RefreshControllerTransform();

#if UNITY_WSA && UNITY_2017_2_OR_NEWER
            MotionControllerVisualizer.Instance.OnControllerModelLoaded   += AddControllerTransform;
            MotionControllerVisualizer.Instance.OnControllerModelUnloaded += RemoveControllerTransform;
#endif
        }
Example #4
0
        /// <summary>
        /// Looks to see if the controller model already exists and registers it if so.
        /// </summary>
        protected virtual void TryAndAddControllerTransform()
        {
#if UNITY_WSA && UNITY_2017_2_OR_NEWER
            // Look if the controller was already loaded. This could happen if the
            // GameObject was instantiated at runtime and the model loaded event has already fired.
            if (!MotionControllerVisualizer.ConfirmInitialized())
            {
                // The motion controller visualizer singleton could not be found.
                return;
            }

            MotionControllerInfo newController;
            if (MotionControllerVisualizer.Instance.TryGetControllerModel(handedness, out newController))
            {
                AddControllerTransform(newController);
            }
#endif
        }