public static void Stop() { if (_eyeTrackingProvider == null) { return; } _g2om.Destroy(); _eyeTrackingProvider.Destroy(); if (_updaterGameObject != null) { #if UNITY_EDITOR if (Application.isPlaying) { Object.Destroy(_updaterGameObject.gameObject); } else { Object.DestroyImmediate(_updaterGameObject.gameObject); } #else Object.Destroy(_updaterGameObject.gameObject); #endif } _updaterGameObject = null; _g2om = null; _eyeTrackingProvider = null; }
private void Awake() { // Get all objects of the type and save them to a list. _gazeGrabbableObjects = FindObjectsOfType <GazeGrabbableObject>(); _gazeThrowTargets = FindObjectsOfType <GazeThrowTarget>(); var settings = TobiiXR_Settings.CreateDefaultSettings(); // Create a custom G2OM description and set the layer mask to be used for switching between which objects should be focusable var description = new G2OM_Description { LayerMask = EnabledLayer << 1 }; _g2omInstance = G2OM.Create(description); settings.G2OM = _g2omInstance; // Get the G2OM visualization to be able to show what G2OM tries to map to. _visualization = GetComponent <G2OM_DebugVisualization>(); TobiiXR.Start(settings); // Start by enabling the grabbable objects to receive focus from G2OM. EnableGrabbableObjects(); }
public static bool Start(TobiiXR_Settings settings = null) { if (_eyeTrackingProvider != null) { Debug.LogWarning(string.Format("TobiiXR already started with provider ({0})", _eyeTrackingProvider)); VerifyInstanceIntegrity(); return(false); } if (settings == null) { settings = TobiiXR_Settings.CreateDefaultSettings(); } _eyeTrackingProvider = settings.EyeTrackingProvider; if (_eyeTrackingProvider == null) { _eyeTrackingProvider = new NoseDirectionProvider(); Debug.LogWarning(string.Format("Creating ({0}) failed. Using ({1}) as fallback", settings.GetProviderType(), _eyeTrackingProvider.GetType().Name)); } Debug.Log(string.Format("Starting TobiiXR with ({0}) as provider for eye tracking", _eyeTrackingProvider)); _g2om = settings.G2OM; VerifyInstanceIntegrity(); return(true); }
public void Setup(G2OM g2om, Camera mainCamera) { _g2om = g2om; _mat = new Material(Shader.Find("Hidden/Internal-Colored")); _candidates = g2om.GetCandidates(); _candidateResult = g2om.GetCandidateResult(); _deviceData = g2om.GetDeviceData(); _mainCamera = mainCamera; _camera = GetComponent <Camera>(); _camera.enabled = false; }
private void Awake() { // Get all objects of the type and save them to a list. _gazeGrabbableObjects = FindObjectsOfType <GazeGrabbableObject>(); _gazeThrowTargets = FindObjectsOfType <GazeThrowTarget>(); // Create a custom G2OM description and set the layer mask to be used for switching between which objects should be focusable var description = new G2OM_Description { LayerMask = EnabledLayer << 1 }; _g2omInstance = G2OM.Create(description); Settings.G2OM = _g2omInstance; TobiiXR.Start(Settings); // Start by enabling the grabbable objects to receive focus from G2OM. EnableGrabbableObjects(); }
void Start() { var settings = TobiiXR_Settings.CreateDefaultSettings(); var description = new G2OM_Description { HowLongToKeepCandidatesInSeconds = 0, ExpectedNumberOfObjects = settings.ExpectedNumberOfObjects, ObjectFinder = new G2OM_RegisterObjectsFinder(), Distinguisher = new G2OM_RegisterObjectDistinguisher(), LayerMask = settings.LayerMask }; settings.G2OM = G2OM.Create(description); if (DebugVisualization != null) { DebugVisualization.Setup(settings.G2OM, MainCamera); Debug.Log("G2OM debug visualization available."); } TobiiXR.Start(settings); }
public static bool Start(TobiiXR_Settings settings = null) { if (IsRunning) { Stop(); } if (!TobiiEula.IsEulaAccepted()) { Debug.LogWarning( "You need to accept Tobii Software Development License Agreement to use Tobii XR Unity SDK."); } // Create default settings if none were provided if (settings == null) { settings = new TobiiXR_Settings(); } Internal.Settings = settings; // Setup eye tracking provider if (settings.AdvancedEnabled) { Debug.Log("Advanced eye tracking enabled so TobiiXR will use Tobii provider for eye tracking."); var licenseKey = settings.OcumenLicense; if (string.IsNullOrEmpty(licenseKey)) { var licenseResource = Resources.Load("TobiiOcumenLicense") as TextAsset; if (licenseResource != null) { licenseKey = Encoding.Unicode.GetString(licenseResource.bytes); } else { throw new System.Exception("An Ocumen license is required to use the advanced API. Read more about Ocumen here: https://vr.tobii.com/sdk//technology/tobii-ocumen/"); } } var provider = new TobiiProvider(); if (!provider.InitializeAdvanced(licenseKey)) { Debug.LogError("Failed to connect to a supported eye tracker. TobiiXR will NOT be available."); return(false); } if (provider.HasValidOcumenLicense) { Debug.Log("Ocumen license valid"); _advanced = new TobiiXRAdvanced(provider); } else { Debug.LogError("Ocumen license INVALID. Advanced API will NOT be available."); } Internal.Provider = provider; } else { Internal.Provider = settings.EyeTrackingProvider; if (Internal.Provider == null) { Internal.Provider = new NoseDirectionProvider(); Debug.LogWarning(string.Format("All configured providers failed. Using ({0}) as fallback.", Internal.Provider.GetType().Name)); } Debug.Log(string.Format("Starting TobiiXR with ({0}) as provider for eye tracking.", Internal.Provider)); } // Setup G2OM if (settings.G2OM != null) { Internal.G2OM = settings.G2OM; } else { Internal.G2OM = G2OM.Create(new G2OM_Description { LayerMask = settings.LayerMask, HowLongToKeepCandidatesInSeconds = settings.HowLongToKeepCandidatesInSeconds }); } // Create GameObject with TobiiXR_Lifecycle to give us Unity events _updaterGameObject = new GameObject("TobiiXR Updater"); var updater = _updaterGameObject.AddComponent <TobiiXR_Lifecycle>(); updater.OnUpdateAction += Tick; updater.OnDisableAction += Internal.G2OM.Clear; updater.OnApplicationQuitAction += Stop; return(true); }