コード例 #1
0
        private void Init(SerializedProperty property)
        {
            if (_initialized == true)
            {
                return;
            }

            _allStandaloneProviders = EditorUtils.GetAvailableProviders(BuildTargetGroup.Standalone);
            _allAndroidProviders    = EditorUtils.GetAvailableProviders(BuildTargetGroup.Android);
            _standaloneProviderList = CreateReorderableList("Standalone Eye Tracking Providers", property, property.FindPropertyRelative("StandaloneEyeTrackingProviders"), _allStandaloneProviders);
            _androidProviderList    = CreateReorderableList("Android Eye Tracking Providers", property, property.FindPropertyRelative("AndroidEyeTrackingProviders"), _allAndroidProviders);

            var flags = EditorUtils.GetCompilerFlagsForBuildTarget(BuildTargetGroup.Standalone);

            _viveProviderEnabled = flags.Contains(ViveProviderCompilerFlagString);
            _initialized         = true;
        }
コード例 #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (_scriptsReloaded)
            {
                _scriptsReloaded = false;
                _initialized     = false;
                Init(property);
            }

            if (EditorApplication.isCompiling)
            {
                _initialized = false;
            }
            else if (!_initialized)
            {
                Init(property);
            }

            _lineEndings = 0;

            var layerMask         = property.FindPropertyRelative("LayerMask");
            var eyeTrackingFilter = property.FindPropertyRelative("EyeTrackingFilter");
            var advancedEnabled   = property.FindPropertyRelative("AdvancedEnabled");

            position.height = EditorGUIUtility.singleLineHeight;

            EditorGUI.LabelField(position, "Information", EditorStyles.boldLabel);
            CarriageReturn(ref position);

            EditorGUI.LabelField(position, "Change settings used to initialize Tobii XR. For more info click the button below.");
            CarriageReturn(ref position);

            var buttonPosition = position;
            var buttonContent  = new GUIContent("Open website");

            buttonPosition.width = GUI.skin.button.CalcSize(buttonContent).x;

            if (GUI.Button(buttonPosition, buttonContent))
            {
                Application.OpenURL("https://vr.tobii.com/sdk/develop/unity/documentation/tobii-settings/");
            }

            CarriageReturn(ref position, 2);

            EditorGUI.BeginDisabledGroup(Application.isPlaying);

            EditorGUI.PropertyField(position, layerMask, new GUIContent("G2OM Layer Mask", "Choose in which layers G2OM looks for potential candidates."));
            CarriageReturn(ref position);

            // ***************************
            // Advanced eye tracking
            // ***************************
            if (Resources.Load("TobiiOcumenLicense") != null)
            {
                EditorGUI.LabelField(position, "", GUI.skin.horizontalSlider);
                CarriageReturn(ref position);

                EditorGUI.LabelField(position, new GUIContent("Advanced Eye Tracking", "This section adds settings for advanced usages of the XR SDK."), EditorStyles.boldLabel);
                CarriageReturn(ref position);

                EditorGUI.LabelField(position, "Requires a Tobii Ocumen license. For more info click the button below.");
                CarriageReturn(ref position);

                buttonPosition       = position;
                buttonContent        = new GUIContent("Open website");
                buttonPosition.width = GUI.skin.button.CalcSize(buttonContent).x;


                if (GUI.Button(buttonPosition, buttonContent))
                {
                    Application.OpenURL("https://vr.tobii.com/sdk/technology/tobii-ocumen/");
                }

                CarriageReturn(ref position);
                CarriageReturn(ref position);
                EditorGUI.PropertyField(position, advancedEnabled, new GUIContent("Enable Advanced API", "Advanced eye tracking is only available with the Tobii provider"));
                CarriageReturn(ref position);
                CarriageReturn(ref position);
            }

            // ***************************
            // Providers
            // ***************************
            EditorGUI.LabelField(position, "", GUI.skin.horizontalSlider);
            CarriageReturn(ref position);

            EditorGUI.LabelField(position, new GUIContent("Eye Tracking Providers", "If no provider is initialized successfully TobiiXR will use Nose Direction Provider even if it is removed from this list."), EditorStyles.boldLabel);
            CarriageReturn(ref position);

            if (advancedEnabled.boolValue)
            {
                EditorGUI.LabelField(position, "Tobii Provider is the only provider that supports advanced eye tracking.");
                CarriageReturn(ref position);
                EditorGUI.LabelField(position, "The core API can still be used when advanced is enabled.");
                CarriageReturn(ref position);
                EditorGUI.LabelField(position, "Disable advanced if you want to use another provider.");
                CarriageReturn(ref position);
                CarriageReturn(ref position);
            }
            else
            {
                var providerList = EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Android ? _androidProviderList : _standaloneProviderList;
                providerList.DoList(position);
                CarriageReturn(ref position);
                _providerListHeight = providerList.GetHeight();
                position.y         += _providerListHeight;
            }

            // ***************************
            // Filter
            // ***************************
            if (eyeTrackingFilter.objectReferenceValue != null && eyeTrackingFilter.objectReferenceValue is EyeTrackingFilterBase == false)
            {
                Debug.LogError("Filter must implement interface EyeTrackingFilterBase.");
                eyeTrackingFilter.objectReferenceValue = null;
            }

            EditorGUI.PropertyField(position, eyeTrackingFilter, new GUIContent("Eye Tracking Filter", "If you want the eye tracking data to be filtered. One example is the Gaze Modifier Filter."));
            CarriageReturn(ref position);

            EditorGUI.EndDisabledGroup();

            // ***************************
            // Player settings
            // ***************************
            if (advancedEnabled.boolValue == false)
            {
                if (EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Standalone ||
                    EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Android)
                {
                    CarriageReturn(ref position);
                    CarriageReturn(ref position);
                    EditorGUI.LabelField(position, new GUIContent(EditorUserBuildSettings.selectedBuildTargetGroup.ToString() + " Player Settings*", "Settings specific to a player."), EditorStyles.boldLabel);
                    CarriageReturn(ref position);

                    if (EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Standalone)
                    {
                        var viveProviderEnabled = EditorGUI.ToggleLeft(position, new GUIContent("Support VIVE Pro Eye (requires SRanipal SDK)", "Please add VIVE SRanipal SDK to your project before enabling VIVE Pro Eye support"), _viveProviderEnabled);
                        if (viveProviderEnabled != _viveProviderEnabled)
                        {
                            var flags = EditorUtils.GetCompilerFlagsForBuildTarget(BuildTargetGroup.Standalone);
                            if (viveProviderEnabled)
                            {
                                flags.Add(ViveProviderCompilerFlagString);
                            }
                            else
                            {
                                flags.RemoveAll(x => x == ViveProviderCompilerFlagString);
                            }

                            EditorUtils.SetCompilerFlagsForBuildTarget(BuildTargetGroup.Standalone, flags);
                            _viveProviderEnabled = viveProviderEnabled;
                        }
                    }
                    else if (EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Android)
                    {
                        var picoProviderEnabled = EditorGUI.ToggleLeft(position, new GUIContent("Support Pico (requires Pico VR SDK)", "Please add Pico VR SDK to your project before enabling Pico support"), _picoProviderEnabled);
                        if (picoProviderEnabled != _picoProviderEnabled)
                        {
                            var flags = EditorUtils.GetCompilerFlagsForBuildTarget(BuildTargetGroup.Android);
                            if (picoProviderEnabled)
                            {
                                flags.Add(PicoProviderCompilerFlagString);
                            }
                            else
                            {
                                flags.RemoveAll(x => x == PicoProviderCompilerFlagString);
                            }

                            EditorUtils.SetCompilerFlagsForBuildTarget(BuildTargetGroup.Android, flags);
                            _picoProviderEnabled = picoProviderEnabled;
                        }
                    }
                }

                CarriageReturn(ref position);
                CarriageReturn(ref position);
                EditorGUI.LabelField(position, "*Changing player settings will trigger a recompile.");
            }
        }
コード例 #3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (_scriptsReloaded)
            {
                _scriptsReloaded = false;
                _initialized     = false;
                Init(property);
            }

            if (EditorApplication.isCompiling)
            {
                _initialized = false;
            }
            else if (!_initialized)
            {
                Init(property);
            }
            _lineEndings = 0;

            var layerMask = property.FindPropertyRelative("LayerMask");
            var howLongToKeepCandidatesInSeconds = property.FindPropertyRelative("HowLongToKeepCandidatesInSeconds");
            var eyeTrackingFilter = property.FindPropertyRelative("EyeTrackingFilter");

            position.height = EditorGUIUtility.singleLineHeight;

            EditorGUI.LabelField(position, "Information", EditorStyles.boldLabel);
            CarriageReturn(ref position);

            EditorGUI.LabelField(position, "Change settings used to initialize Tobii XR. More info at the site below:");
            CarriageReturn(ref position);

            var buttonPosition = position;
            var buttonContent  = new GUIContent("Open Tobii Settings documentation website");

            buttonPosition.width = GUI.skin.button.CalcSize(buttonContent).x;

            if (GUI.Button(buttonPosition, buttonContent))
            {
                Application.OpenURL("https://vr.tobii.com/sdk/develop/unity/documentation/tobii-settings/");
            }

            CarriageReturn(ref position, 2);

            EditorGUI.BeginDisabledGroup(Application.isPlaying);

            CarriageReturn(ref position);
            EditorGUI.LabelField(position, new GUIContent("G2OM Settings", "Gaze-2-object mapping is a machine learning algorithm determining what object the user is looking at."), EditorStyles.boldLabel);
            CarriageReturn(ref position);

            EditorGUI.PropertyField(position, layerMask, new GUIContent("Layer Mask", "Set which layers G2OM looks for potential candidates."));
            CarriageReturn(ref position);

            EditorGUI.PropertyField(position, howLongToKeepCandidatesInSeconds);
            CarriageReturn(ref position, 2);

            EditorGUI.LabelField(position, new GUIContent("Eye Tracking Providers", "If no provider is initialized successfully TobiiXR will use Nose Direction Provider even if it is removed from this list."), EditorStyles.boldLabel);
            CarriageReturn(ref position);

            var providerList = EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Android ? _androidProviderList : _standaloneProviderList;

            providerList.DoList(position);
            CarriageReturn(ref position);
            _providerListHeight = providerList.GetHeight();
            position.y         += _providerListHeight;

            EditorGUI.EndDisabledGroup();

            if (eyeTrackingFilter.objectReferenceValue != null && eyeTrackingFilter.objectReferenceValue is EyeTrackingFilterBase == false)
            {
                Debug.LogError("Filter must implement interface EyeTrackingFilterBase.");
                eyeTrackingFilter.objectReferenceValue = null;
            }

            EditorGUI.PropertyField(position, eyeTrackingFilter, new GUIContent("Eye Tracking Filter", "If you want the eye tracking data to be filtered. One example is the Gaze Modifier Filter."));
            CarriageReturn(ref position);

            if (EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Standalone || EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Android)
            {
                CarriageReturn(ref position);
                EditorGUI.LabelField(position, new GUIContent(EditorUserBuildSettings.selectedBuildTargetGroup.ToString() + " Player Settings*", "Settings specific to a player."), EditorStyles.boldLabel);
                CarriageReturn(ref position);

                if (EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Standalone)
                {
                    var viveProviderEnabled = EditorGUI.ToggleLeft(position, new GUIContent("Support VIVE Pro Eye (requires SRanipal SDK)", "Please add VIVE SRanipal SDK to your project before enabling VIVE Pro Eye support"), _viveProviderEnabled);
                    if (viveProviderEnabled != _viveProviderEnabled)
                    {
                        var flags = EditorUtils.GetCompilerFlagsForBuildTarget(BuildTargetGroup.Standalone);
                        if (viveProviderEnabled)
                        {
                            flags.Add(ViveProviderCompilerFlagString);
                        }
                        else
                        {
                            flags.RemoveAll(x => x == ViveProviderCompilerFlagString);
                        }

                        EditorUtils.SetCompilerFlagsForBuildTarget(BuildTargetGroup.Standalone, flags);
                        _viveProviderEnabled = viveProviderEnabled;
                    }
                }
                else if (EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Android)
                {
                    var picoProviderEnabled = EditorGUI.ToggleLeft(position, new GUIContent("Support Pico (requires Pico VR SDK)", "Please add Pico VR SDK to your project before enabling Pico support"), _picoProviderEnabled);
                    if (picoProviderEnabled != _picoProviderEnabled)
                    {
                        var flags = EditorUtils.GetCompilerFlagsForBuildTarget(BuildTargetGroup.Android);
                        if (picoProviderEnabled)
                        {
                            flags.Add(PicoProviderCompilerFlagString);
                        }
                        else
                        {
                            flags.RemoveAll(x => x == PicoProviderCompilerFlagString);
                        }

                        EditorUtils.SetCompilerFlagsForBuildTarget(BuildTargetGroup.Android, flags);
                        _picoProviderEnabled = picoProviderEnabled;
                    }
                }
            }

            CarriageReturn(ref position);
            CarriageReturn(ref position);
            EditorGUI.LabelField(position, "*Changing player settings will trigger a recompile.");
        }
コード例 #4
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (_scriptsReloaded)
            {
                _scriptsReloaded = false;
                _initialized     = false;
                Init(property);
            }

            if (EditorApplication.isCompiling)
            {
                _initialized = false;
            }
            else if (!_initialized)
            {
                Init(property);
            }

            _lineEndings = 0;

            var layerMask         = property.FindPropertyRelative("LayerMask");
            var eyeTrackingFilter = property.FindPropertyRelative("EyeTrackingFilter");
            var advancedEnabled   = property.FindPropertyRelative("AdvancedEnabled");
            var licenseProp       = property.FindPropertyRelative("LicenseAsset");

            position.height = EditorGUIUtility.singleLineHeight;

            EditorGUI.LabelField(position, "Information", EditorStyles.boldLabel);
            CarriageReturn(ref position);

            EditorGUI.LabelField(position, "Change settings used to initialize Tobii XR. For more info click the button below.");
            CarriageReturn(ref position);

            var buttonPosition = position;
            var buttonContent  = new GUIContent("Open website");

            buttonPosition.width = GUI.skin.button.CalcSize(buttonContent).x;

            if (GUI.Button(buttonPosition, buttonContent))
            {
                Application.OpenURL("https://vr.tobii.com/sdk/develop/unity/documentation/tobii-settings/");
            }

            CarriageReturn(ref position, 2);

            EditorGUI.BeginDisabledGroup(Application.isPlaying);

            EditorGUI.PropertyField(position, layerMask, new GUIContent("G2OM Layer Mask", "Choose in which layers G2OM looks for potential candidates."));
            CarriageReturn(ref position);

            // ***************************
            // Ocumen
            // ***************************
            EditorGUI.LabelField(position, "", GUI.skin.horizontalSlider);
            CarriageReturn(ref position);

            EditorGUI.LabelField(position, new GUIContent("Tobii Ocumen", "This section adds settings for Ocumen usages of the XR SDK."), EditorStyles.boldLabel);
            CarriageReturn(ref position);

            EditorGUI.LabelField(position, "Ocumen features require a license and will only work with the Tobii Provider.");
            CarriageReturn(ref position);
            EditorGUI.LabelField(position, "For more info click the button below.");
            CarriageReturn(ref position);

            buttonPosition       = position;
            buttonContent        = new GUIContent("Open website");
            buttonPosition.width = GUI.skin.button.CalcSize(buttonContent).x;

            if (GUI.Button(buttonPosition, buttonContent))
            {
                Application.OpenURL("https://vr.tobii.com/sdk/solutions/tobii-ocumen/");
            }

            CarriageReturn(ref position);
            CarriageReturn(ref position);
            EditorGUI.PropertyField(position, licenseProp, new GUIContent("License Asset", "Choose license asset to use."));
            CarriageReturn(ref position);

            EditorGUI.indentLevel++;

            if (licenseProp.objectReferenceValue != null)
            {
                var licenseAsset = licenseProp.objectReferenceValue as TextAsset;
                var lic          = new LicenseParser(Encoding.Unicode.GetString(licenseAsset.bytes));
                if (lic.LicenseIsParsed)
                {
                    var style = new GUIStyle();

                    EditorGUI.LabelField(position, "Licensee:", lic.Licensee);
                    CarriageReturn(ref position);

                    if (lic.ValidTo != null)
                    {
                        var time = (DateTime)lic.ValidTo;
                        EditorGUI.LabelField(position, "Expiry Date:", time.ToString("yyyy-MM-dd"), GetExpiryDateColor(lic.ValidTo, style));
                    }
                    else
                    {
                        EditorGUI.LabelField(position, "Expiry Date:", "No Expiry Date", GetExpiryDateColor(lic.ValidTo, style));
                    }

                    // CarriageReturn(ref position);
                    // var signalsFiltersAvailable = lic.FeatureGroup == FeatureGroup.Professional;
                    // EditorGUI.LabelField(position, "Signals & Filters:", GetLicenseAvailablityString(signalsFiltersAvailable), GetLicenseStyle(signalsFiltersAvailable, style));
                    // CarriageReturn(ref position);
                    //
                    // var configurationAvailable = lic.FeatureGroup >= FeatureGroup.Config;
                    // EditorGUI.LabelField(position, "Configuration:", GetLicenseAvailablityString(configurationAvailable), GetLicenseStyle(configurationAvailable, style));
                    // CarriageReturn(ref position);
                    //
                    // var eyeImagesAvailable = lic.EyeImages;
                    // EditorGUI.LabelField(position, "Eye Images:", GetLicenseAvailablityString(eyeImagesAvailable), GetLicenseStyle(eyeImagesAvailable, style));
                    // CarriageReturn(ref position);

                    advancedEnabled.boolValue = lic.FeatureGroup == FeatureGroup.Professional;
                }
                else
                {
                    var style = new GUIStyle {
                        normal = { textColor = _redColor }
                    };
                    EditorGUI.LabelField(position, "Invalid License", style);
                    advancedEnabled.boolValue = false;
                }
            }
            else
            {
                advancedEnabled.boolValue = false;
            }
            CarriageReturn(ref position);
            EditorGUI.indentLevel--;


            // ***************************
            // Providers
            // ***************************
            EditorGUI.LabelField(position, "", GUI.skin.horizontalSlider);
            CarriageReturn(ref position);

            EditorGUI.LabelField(position, new GUIContent("Eye Tracking Providers", "If no provider is initialized successfully TobiiXR will use Nose Direction Provider even if it is removed from this list."), EditorStyles.boldLabel);
            CarriageReturn(ref position);

            if (licenseProp.objectReferenceValue != null) // A license was provided
            {
                EditorGUI.LabelField(position, "Tobii Provider is the only provider that supports licenses.");
                CarriageReturn(ref position);
                EditorGUI.LabelField(position, "The core API can still be used when advanced is enabled.");
                CarriageReturn(ref position);
                EditorGUI.LabelField(position, "Clear the license field if you want to use another provider.");
                CarriageReturn(ref position);
                CarriageReturn(ref position);
            }
            else
            {
                var providerList = EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Android ? _androidProviderList : _standaloneProviderList;
                providerList.DoList(position);
                CarriageReturn(ref position);
                _providerListHeight = providerList.GetHeight();
                position.y         += _providerListHeight;
            }

            // ***************************
            // Filter
            // ***************************
            if (eyeTrackingFilter.objectReferenceValue != null && eyeTrackingFilter.objectReferenceValue is EyeTrackingFilterBase == false)
            {
                Debug.LogError("Filter must implement interface EyeTrackingFilterBase.");
                eyeTrackingFilter.objectReferenceValue = null;
            }

            EditorGUI.PropertyField(position, eyeTrackingFilter, new GUIContent("Eye Tracking Filter", "If you want the eye tracking data to be filtered. One example is the Gaze Modifier Filter."));
            CarriageReturn(ref position);

            EditorGUI.EndDisabledGroup();

            // ***************************
            // Player settings
            // ***************************
            if (licenseProp.objectReferenceValue == null) // No player settings are currently relevant when using a license
            {
                if (EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Standalone ||
                    EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Android)
                {
                    CarriageReturn(ref position);
                    CarriageReturn(ref position);
                    EditorGUI.LabelField(position, new GUIContent(EditorUserBuildSettings.selectedBuildTargetGroup.ToString() + " Player Settings*", "Settings specific to a player."), EditorStyles.boldLabel);
                    CarriageReturn(ref position);

                    if (EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Standalone)
                    {
                        var viveProviderEnabled = EditorGUI.ToggleLeft(position, new GUIContent("Support VIVE Pro Eye (requires SRanipal SDK)", "Please add VIVE SRanipal SDK to your project before enabling VIVE Pro Eye support"), _viveProviderEnabled);
                        if (viveProviderEnabled != _viveProviderEnabled)
                        {
                            var flags = EditorUtils.GetCompilerFlagsForBuildTarget(BuildTargetGroup.Standalone);
                            if (viveProviderEnabled)
                            {
                                flags.Add(ViveProviderCompilerFlagString);
                            }
                            else
                            {
                                flags.RemoveAll(x => x == ViveProviderCompilerFlagString);
                            }

                            EditorUtils.SetCompilerFlagsForBuildTarget(BuildTargetGroup.Standalone, flags);
                            _viveProviderEnabled = viveProviderEnabled;
                        }
                    }
                    else if (EditorUserBuildSettings.selectedBuildTargetGroup == BuildTargetGroup.Android)
                    {
                        var picoProviderEnabled = EditorGUI.ToggleLeft(position, new GUIContent("Support Pico (requires Pico VR SDK)", "Please add Pico VR SDK to your project before enabling Pico support"), _picoProviderEnabled);
                        if (picoProviderEnabled != _picoProviderEnabled)
                        {
                            var flags = EditorUtils.GetCompilerFlagsForBuildTarget(BuildTargetGroup.Android);
                            if (picoProviderEnabled)
                            {
                                flags.Add(PicoProviderCompilerFlagString);
                            }
                            else
                            {
                                flags.RemoveAll(x => x == PicoProviderCompilerFlagString);
                            }

                            EditorUtils.SetCompilerFlagsForBuildTarget(BuildTargetGroup.Android, flags);
                            _picoProviderEnabled = picoProviderEnabled;
                        }
                    }
                }

                CarriageReturn(ref position);
                CarriageReturn(ref position);
                EditorGUI.LabelField(position, "*Changing player settings will trigger a recompile.");
            }
        }