Beispiel #1
0
        /// <summary>
        /// Starts the MLInput, initializes the first controller, and registers the connection handlers
        /// </summary>
        void Awake()
        {
            if (_devicesAllowed == 0)
            {
                Debug.LogErrorFormat("Error: ControllerConnectionHandler._devicesAllowed is invalid, disabling script.");
                enabled = false;
                return;
            }

            bool requestCFUID = DevicesAllowed.HasFlag(DeviceTypesAllowed.ControllerLeft) ||
                                DevicesAllowed.HasFlag(DeviceTypesAllowed.ControllerRight);

            if (!MLInput.IsStarted)
            {
                MLInputConfiguration config = new MLInputConfiguration(MLInputConfiguration.DEFAULT_TRIGGER_DOWN_THRESHOLD,
                                                                       MLInputConfiguration.DEFAULT_TRIGGER_UP_THRESHOLD,
                                                                       requestCFUID);
                MLResult result = MLInput.Start(config);
                if (!result.IsOk)
                {
                    Debug.LogErrorFormat("Error: ControllerConnectionHandler failed starting MLInput, disabling script. Reason: {0}", result);
                    enabled = false;
                    return;
                }
            }

            MLInput.OnControllerConnected    += HandleOnControllerConnected;
            MLInput.OnControllerDisconnected += HandleOnControllerDisconnected;

            GetAllowedInput();
        }
        /// <summary/>
        protected override void Start()
        {
            base.Start();

            _headpose = Camera.main;
            if (_headpose == null)
            {
                Debug.LogError("Error: MLInputModule, no camera found tagged as MainCamera, disabling script.");
                enabled = false;
                return;
            }

            // Eye Tracking
            if (_pointerInput == PointerInputType.EyeTracking)
            {
                MLResult result = MLEyes.Start();
                if (!result.IsOk)
                {
                    Debug.LogErrorFormat("Error: MLInputModule failed starting MLEyes, disabling script. Reason: {0}", result);
                    enabled = false;
                    return;
                }
            }

            // Controllers
            if (!MLInput.IsStarted)
            {
                MLInputConfiguration config = new MLInputConfiguration(true);
                MLResult             result = MLInput.Start(config);
                if (!result.IsOk)
                {
                    Debug.LogErrorFormat("Error: MLInputModule failed starting MLInput, disabling script. Reason: {0}", result);
                    enabled = false;
                    return;
                }
            }

            AddController(0);
            AddController(1);

            // Track connect / disconnect
            MLInput.OnControllerConnected    += HandleOnControllerConnected;
            MLInput.OnControllerDisconnected += HandleOnControllerDisconnected;

            _pointerInputDevice = new MLInputDevice();
            _pointerInputDevice.Initialize();
            _cachedTrackedPointerEventData = new MLInputDeviceEventData(eventSystem);
        }
        /// <summary>
        /// Starts the MLInput, initializes the first controller, and registers the connection handlers
        /// </summary>
        private void Awake()
        {
            MLInputConfiguration config = new MLInputConfiguration(MLInputConfiguration.DEFAULT_TRIGGER_DOWN_THRESHOLD,
                                                                   MLInputConfiguration.DEFAULT_TRIGGER_UP_THRESHOLD,
                                                                   true);
            MLResult result = MLInput.Start(config);

            if (!result.IsOk)
            {
                Debug.LogError("Error ControllerConnectionHandler starting MLInput, disabling script.");
                enabled = false;
                return;
            }

            ConnectedController = GetAllowedInput();
            RegisterConnectionHandlers();
        }
Beispiel #4
0
        /// <summary>
        /// Starts the MLInput, initializes the first controller, and registers the connection handlers
        /// </summary>
        void Awake()
        {
            if (!MLInput.IsStarted)
            {
                MLInputConfiguration config = new MLInputConfiguration(MLInputConfiguration.DEFAULT_TRIGGER_DOWN_THRESHOLD,
                                                                       MLInputConfiguration.DEFAULT_TRIGGER_UP_THRESHOLD,
                                                                       true);
                MLResult result = MLInput.Start(config);
                if (!result.IsOk)
                {
                    Debug.LogErrorFormat("Error: ControllerConnectionHandler failed starting MLInput, disabling script. Reason: {0}", result);
                    enabled = false;
                    return;
                }
            }

            MLInput.OnControllerConnected    += HandleOnControllerConnected;
            MLInput.OnControllerDisconnected += HandleOnControllerDisconnected;

            GetAllowedInput();
        }