public static bool Start(TobiiXR_Settings settings = null) { if (!TobiiEula.IsEulaAccepted()) { Debug.LogWarning("You need to accept Tobii Software Development License Agreement to use Tobii XR Unity SDK."); } if (Internal.Provider != null) { Debug.LogWarning(string.Format("TobiiXR already started with provider ({0})", Internal.Provider)); VerifyInstanceIntegrity(); return(false); } if (settings == null) { settings = new TobiiXR_Settings(); } if (settings.FieldOfUse == FieldOfUse.NotSelected) { //For more info, see https://developer.tobii.com/vr/develop/unity/documentation/configure-tobii-xr/ Debug.LogWarning("Field of use has not been selected. Please specify intended field of use in TobiiXR_Settings"); } 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)); Internal.Settings = settings; if (settings.G2OM != null) { Internal.G2OM = settings.G2OM; } else { Internal.G2OM = Tobii.G2OM.G2OM.Create(new G2OM_Description { LayerMask = settings.LayerMask, HowLongToKeepCandidatesInSeconds = settings.HowLongToKeepCandidatesInSeconds }); } VerifyInstanceIntegrity(); return(true); }
public void ShowDropDown(TobiiXR_Settings settings, ref string eyeTrackingProviderTypeString) { var changed = ShowDropDown(ref eyeTrackingProviderTypeString); if (changed) { Undo.RecordObject(settings, _targetGroup.ToString() + " Provider changed"); TobiiXR_SettingsEditorWindow.SetDirty(settings); EditorUtils.UpdateCompilerFlags(settings); } }
public void ShowDropDown(TobiiXR_Settings settings, ref string eyeTrackingProviderTypeString) { EditorGUI.BeginChangeCheck(); var selected = EditorGUILayout.Popup(_targetGroup.ToString(), SelectedType, TypeStrings); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, _targetGroup.ToString() + " Provider changed"); SelectedType = selected; eyeTrackingProviderTypeString = TypeString; SetDirty(settings); EditorUtils.UpdateCompilerFlags(settings); } }
public static bool Start(TobiiXR_Settings settings = null) { if (!TobiiEula.IsEulaAccepted()) { Debug.LogWarning("You need to accept Tobii Software Development License Agreement to use Tobii XR Unity SDK."); } if (Internal.Provider != null) { Debug.LogWarning(string.Format("TobiiXR already started with provider ({0})", Internal.Provider)); VerifyInstanceIntegrity(); return(false); } if (settings == null) { settings = new TobiiXR_Settings(); } 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)); Internal.Settings = settings; if (settings.G2OM != null) { Internal.G2OM = settings.G2OM; } else { Internal.G2OM = Tobii.G2OM.G2OM.Create(new G2OM_Description { LayerMask = settings.LayerMask, HowLongToKeepCandidatesInSeconds = settings.HowLongToKeepCandidatesInSeconds }); } VerifyInstanceIntegrity(); return(true); }
private void OnEnable() { _settings = LoadOrCreateDefaultConfiguration(); _settingsExtensions = AppDomain.CurrentDomain.GetAssemblies() // Read from all loaded assemblies in domain .SelectMany(s => s.GetTypes()).Where(p => typeof(ISettingsEditorExtension).IsAssignableFrom(p) && p.IsClass) // Get all derived classes of interface ISettingsEditorExtension .Select(x => (ISettingsEditorExtension)Activator.CreateInstance(x)) // Instantiate them .OrderBy(x => x.Priority) // Sort them by Priority .ToList(); foreach (var extension in _settingsExtensions) { extension.Init(_settings); } _standaloneDropDownData.SetSelectedType(_settings.EyeTrackingProviderTypeStandAlone); _androidDropDownData.SetSelectedType(_settings.EyeTrackingProviderTypeAndroid); EditorUtils.UpdateCompilerFlags(_settings); }
public static bool Start(TobiiXR_Settings settings = null) { if (!TobiiEulaFile.IsEulaAccepted()) { Debug.LogError("You need to accept Tobii Software Development License Agreement to be able to use Tobii XR Unity SDK."); return(false); } if (_eyeTrackingProvider != null) { Debug.LogWarning(string.Format("TobiiXR already started with provider ({0})", _eyeTrackingProvider)); VerifyInstanceIntegrity(); return(false); } if (settings == null) { settings = TobiiXR_Settings.CreateDefaultSettings(); } if (settings.FieldOfUse == FieldOfUse.NotSelected) { //For more info, see https://developer.tobii.com/vr/develop/unity/documentation/configure-tobii-xr/ Debug.LogError("Field of use has not been selected. Please specify intended field of use in TobiiXR_Settings (can also be edited in Window->Tobii->Tobii Settings)"); } _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)); Internal.Settings = settings; Internal.G2OM = settings.G2OM; VerifyInstanceIntegrity(); return(true); }
private static TobiiXR_Settings LoadOrCreateDefaultConfiguration() { bool resourceExists; var settings = TobiiXR_Settings.CreateDefaultSettings(out resourceExists); if (!resourceExists) { var sdkPath = Path.GetDirectoryName(FindPathToClass(typeof(TobiiXR))); var filePath = PathCombine(sdkPath, TobiiXR_SettingsAssetPath); var assetPath = filePath.Replace(Application.dataPath, "Assets"); if (File.Exists(filePath)) { AssetDatabase.Refresh(); settings = AssetDatabase.LoadAssetAtPath <TobiiXR_Settings>(assetPath); return(settings); } AssetDatabase.CreateAsset(settings, assetPath); AssetDatabase.SaveAssets(); } return(settings); }
internal static void UpdateCompilerFlags(TobiiXR_Settings settings, IEditorSettings editorSettings) { SetCompilerflagForBuildTarget(settings.EyeTrackingProviderTypeAndroid, editorSettings, BuildTargetGroup.Android); SetCompilerflagForBuildTarget(settings.EyeTrackingProviderTypeStandAlone, editorSettings, BuildTargetGroup.Standalone); }
internal static void UpdateCompilerFlags(TobiiXR_Settings settings) { UpdateCompilerFlags(settings, _editorSettings); }
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); }