/// <summary> /// Initializes the EyeX host and enables the connection to the EyeX Engine. /// </summary> public virtual void Start() { if (_context != null) { throw new InvalidOperationException("The EyeX host cannot be re-started."); } // Initialize the EyeX Engine client library. _environment = Environment.Initialize(LogTarget.Trace); // Create a context, register event handlers, and enable the connection to the engine. _context = new Context(false); _context.RegisterQueryHandlerForCurrentProcess(HandleQuery); _context.RegisterEventHandler(HandleEvent); _context.ConnectionStateChanged += OnConnectionStateChanged; _screenBoundsStateAccessor.OnContextCreated(_context); _displaySizeStateAccessor.OnContextCreated(_context); _eyeTrackingDeviceStatusStateAccessor.OnContextCreated(_context); _userPresenceStateAccessor.OnContextCreated(_context); _userProfileNameStateAccessor.OnContextCreated(_context); _context.EnableConnection(); // Execute deferred initialization logic. while (_deferredInitialization.Count > 0) { _deferredInitialization.Dequeue().Invoke(); } }
/// <summary> /// Initializes the EyeX engine. /// </summary> public void InitializeEyeX() { if (IsInitialized) { return; } try { Tobii.EyeX.Client.Interop.EyeX.EnableMonoCallbacks("mono"); _environment = Environment.Initialize(); } catch (InteractionApiException ex) { Debug.LogError("EyeX initialization failed: " + ex.Message); } catch (DllNotFoundException) { #if UNITY_EDITOR Debug.LogError("EyeX initialization failed because the client access library 'Tobii.EyeX.Client.dll' could not be loaded. " + "Please make sure that it is present in the Unity project directory. " + "You can find it in the SDK package, in the lib/x86 directory. (Currently only Windows is supported.)"); #else Debug.LogError("EyeX initialization failed because the client access library 'Tobii.EyeX.Client.dll' could not be loaded. " + "Please make sure that it is present in the root directory of the game/application."); #endif return; } try { _context = new Context(false); _context.RegisterQueryHandlerForCurrentProcess(HandleQuery); _context.RegisterEventHandler(HandleEvent); _context.ConnectionStateChanged += OnConnectionStateChanged; _context.EnableConnection(); print("EyeX is running."); } catch (InteractionApiException ex) { Debug.LogError("EyeX context initialization failed: " + ex.Message); } }