예제 #1
0
        private void DrawIntentsSection()
        {
            bool isDeviceConnected = _wearableControl.ConnectedDevice.HasValue;

            var status = _wearableControl.GetIntentValidationStatus();

            var profileProperty         = serializedObject.FindProperty(INTENT_PROFILE_FIELD);
            AppIntentProfile oldProfile = profileProperty.objectReferenceValue as AppIntentProfile;

            EditorGUILayout.ObjectField(profileProperty, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
            AppIntentProfile newProfile = profileProperty.objectReferenceValue as AppIntentProfile;

            if (newProfile == null)
            {
                EditorGUILayout.HelpBox(SPECIFY_INTENT_WARNING, MessageType.Warning);
                return;
            }

            // If the profile changed at runtime, and there's a device connected, check intents again.
            if (oldProfile != newProfile && isDeviceConnected)
            {
                _wearableControl.SetIntentProfile(newProfile);
            }

            // Profile description
            EditorGUILayout.HelpBox(newProfile.ToString(), MessageType.None);

            if (!Application.isPlaying || !isDeviceConnected)
            {
                return;
            }

            // Re-validate warning
            if (status == IntentValidationStatus.Unknown)
            {
                EditorGUILayout.HelpBox(INTENT_PROFILE_CHANGED, MessageType.Warning);

                bool validateAgain = GUILayout.Button(VALIDATE_INTENTS_TITLE, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                if (validateAgain)
                {
                    _wearableControl.SetIntentProfile(newProfile);
                    _wearableControl.ValidateIntentProfile();
                }
            }
            else
            {
                // Status box
                switch (status)
                {
                // "Unknown" is checked above, so no need to check it here.
                case IntentValidationStatus.Validating:
                    EditorGUILayout.HelpBox(INTENT_VALIDATION_IN_PROGRESS, MessageType.Info);
                    break;

                case IntentValidationStatus.Success:
                    EditorGUILayout.HelpBox(INTENT_VALIDATION_SUCCEEDED, MessageType.Info);
                    break;

                case IntentValidationStatus.Failure:
                    EditorGUILayout.HelpBox(INTENT_VALIDATION_FAILED, MessageType.Error);
                    break;

                case IntentValidationStatus.Disabled:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
예제 #2
0
        private void DrawIntentsSection()
        {
            bool isDeviceConnected = _wearableControl.ConnectedDevice.HasValue;

            var status = _wearableControl.GetIntentValidationStatus();

            var profileProperty         = serializedObject.FindProperty(IntentProfileField);
            AppIntentProfile oldProfile = profileProperty.objectReferenceValue as AppIntentProfile;

            EditorGUILayout.ObjectField(profileProperty, WearableConstants.EmptyLayoutOptions);
            AppIntentProfile newProfile = profileProperty.objectReferenceValue as AppIntentProfile;

            if (newProfile == null)
            {
                EditorGUILayout.HelpBox(SpecifyIntentWarning, MessageType.Warning);
                return;
            }

            // If the profile changed at runtime, and there's a device connected, check intents again.
            if (oldProfile != newProfile && isDeviceConnected)
            {
                _wearableControl.SetIntentProfile(newProfile);
            }

            // Profile description
            EditorGUILayout.HelpBox(newProfile.ToString(), MessageType.None);

            if (!Application.isPlaying || !isDeviceConnected)
            {
                return;
            }

            // Re-validate warning
            if (status == IntentValidationStatus.Unknown)
            {
                EditorGUILayout.HelpBox(IntentProfileChanged, MessageType.Warning);

                bool validateAgain = GUILayout.Button(ValidateIntentsTitle, WearableConstants.EmptyLayoutOptions);
                if (validateAgain)
                {
                    _wearableControl.SetIntentProfile(newProfile);
                    _wearableControl.ValidateIntentProfile();
                }
            }
            else
            {
                // Status box
                switch (status)
                {
                // "Unknown" is checked above, so no need to check it here.
                case IntentValidationStatus.Validating:
                    EditorGUILayout.HelpBox(IntentValidationInProgress, MessageType.Info);
                    break;

                case IntentValidationStatus.Success:
                    EditorGUILayout.HelpBox(IntentValidationSucceeded, MessageType.Info);
                    break;

                case IntentValidationStatus.Failure:
                    EditorGUILayout.HelpBox(IntentValidationFailed, MessageType.Error);
                    break;

                case IntentValidationStatus.Disabled:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }