private void DrawProviderBox(string field, ProviderId provider) { bool isEditorDefault = _editorProvider.enumValueIndex == (int)provider; bool isRuntimeDefault = _runtimeProvider.enumValueIndex == (int)provider; if (isEditorDefault || isRuntimeDefault) { GUILayoutTools.LineSeparator(); StringBuilder titleBuilder = new StringBuilder(); titleBuilder.Append(Enum.GetName(typeof(ProviderId), provider)); if (isEditorDefault) { titleBuilder.Append(TitleSeparator); titleBuilder.Append(EditorDefaultTitle); } if (isRuntimeDefault) { titleBuilder.Append(TitleSeparator); titleBuilder.Append(RuntimeDefaultTitle); } EditorGUILayout.LabelField(titleBuilder.ToString(), WearableConstants.EmptyLayoutOptions); EditorGUILayout.PropertyField(serializedObject.FindProperty(field), WearableConstants.EmptyLayoutOptions); } }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty(UpdateModeField), WearableConstants.EmptyLayoutOptions); EditorGUILayout.PropertyField(_editorProvider, WearableConstants.EmptyLayoutOptions); EditorGUILayout.PropertyField(_runtimeProvider, WearableConstants.EmptyLayoutOptions); DrawProviderBox(DebugProviderField, ProviderId.DebugProvider); DrawProviderBox(ProxyProviderField, ProviderId.WearableProxy); DrawProviderBox(MobileProviderField, ProviderId.MobileProvider); DrawProviderBox(USBProviderField, ProviderId.USBProvider); DrawProviderBox(DeviceProviderField, ProviderId.WearableDevice); if (_editorProvider.enumValueIndex == (int)ProviderId.WearableDevice) { EditorGUILayout.HelpBox(WearableDeviceProviderUnsupportedEditorWarning, MessageType.Error); } if (_runtimeProvider.enumValueIndex == (int)ProviderId.USBProvider) { EditorGUILayout.HelpBox(USBProviderUnsupportedOutsideEditorWarning, MessageType.Error); } if (Application.isPlaying) { GUILayoutTools.LineSeparator(); if (_wearableControl.IsOverridingDeviceConfig) { EditorGUILayout.LabelField(OverrideDeviceConfigTitle, WearableConstants.EmptyLayoutOptions); EditorGUILayout.HelpBox(OverrideConfigPresentWarning, MessageType.Warning); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField( serializedObject.FindProperty(OverrideWearableDeviceConfigField), WearableConstants.EmptyLayoutOptions); } else { EditorGUILayout.LabelField(ResolvedDeviceConfigTitle, WearableConstants.EmptyLayoutOptions); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField( serializedObject.FindProperty(FinalWearableDeviceConfigField), WearableConstants.EmptyLayoutOptions); } EditorGUI.EndDisabledGroup(); } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { var listProp = serializedObject.FindProperty(ListPropertyName); var originalIndentLevel = EditorGUI.indentLevel; GUI.changed = false; EditorGUI.indentLevel = 0; for (var i = 0; i < listProp.arraySize; i++) { var entryProp = listProp.GetArrayElementAtIndex(i); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField(entryProp.FindPropertyRelative(GestureIdPropertyName)); EditorGUI.EndDisabledGroup(); EditorGUILayout.PropertyField(entryProp.FindPropertyRelative(GestureIconPropertyName)); GUILayoutTools.LineSeparator(); } EditorGUI.indentLevel = originalIndentLevel; if (GUI.changed) { serializedObject.ApplyModifiedProperties(); } }
public override void OnInspectorGUI() { serializedObject.Update(); GUI.changed = false; AppIntentProfile profile = target as AppIntentProfile; if (profile == null) { // Nothing we can do, so give up. return; } // Sensors EditorGUILayout.LabelField(SensorsLabel, EditorStyles.boldLabel); _newSensors.Clear(); bool sensorsChanged = false; for (int i = 0; i < WearableConstants.SensorIds.Length; i++) { SensorId id = WearableConstants.SensorIds[i]; bool prior = profile.GetSensorInProfile(id); bool post = EditorGUILayout.Toggle(id.ToString(), prior, WearableConstants.EmptyLayoutOptions); sensorsChanged |= prior != post; if (post) { _newSensors.Add(id); } } if (sensorsChanged) { profile.SetSensorIntent(_newSensors); } // Intervals GUILayoutTools.LineSeparator(); EditorGUILayout.LabelField(IntervalsLabel, EditorStyles.boldLabel); _newIntervals.Clear(); bool intervalsChanged = false; for (int i = 0; i < WearableConstants.UpdateIntervals.Length; i++) { SensorUpdateInterval interval = WearableConstants.UpdateIntervals[i]; string label = string.Format( IntervalFormat, ((int)WearableTools.SensorUpdateIntervalToMilliseconds(interval)).ToString()); bool prior = profile.GetIntervalInProfile(interval); bool post = EditorGUILayout.Toggle(label, prior, WearableConstants.EmptyLayoutOptions); intervalsChanged |= prior != post; if (post) { _newIntervals.Add(interval); } } if (intervalsChanged) { profile.SetIntervalIntent(_newIntervals); } // Gestures GUILayoutTools.LineSeparator(); EditorGUILayout.LabelField(GesturesLabel, EditorStyles.boldLabel); _newGestures.Clear(); bool gesturesChanged = false; for (int i = 0; i < WearableConstants.GestureIds.Length; i++) { GestureId id = WearableConstants.GestureIds[i]; if (id == GestureId.None) { continue; } bool prior = profile.GetGestureInProfile(id); bool post = EditorGUILayout.Toggle(id.ToString(), prior, WearableConstants.EmptyLayoutOptions); gesturesChanged |= prior != post; if (post) { _newGestures.Add(id); } } if (gesturesChanged) { profile.SetGestureIntent(_newGestures); } if (HasDeviceSpecificGesturesEnabled(profile)) { EditorGUILayout.HelpBox(WearableConstants.DeviceSpecificGestureDiscouragedWarning, MessageType.Warning); } if (GUI.changed) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { serializedObject.Update(); // Update mode EditorGUILayout.PropertyField(serializedObject.FindProperty(UpdateModeField), WearableConstants.EmptyLayoutOptions); // Provider defaults using (new EditorGUI.DisabledScope(Application.isPlaying)) { // Editor Default Provider string editorProviderName = GetNameForProvider((ProviderId)_editorProvider.intValue); int optionIndex = Array.IndexOf(_editorProviderOptions, editorProviderName); _editorProviderIndex = EditorGUILayout.Popup( ObjectNames.NicifyVariableName(EditorDefaultProviderField), optionIndex >= 0 ? optionIndex : (int)WearableConstants.EditorDefaultProvider, _editorProviderOptions ); _editorProvider.intValue = (int)_editorProviderMap[_editorProviderOptions[_editorProviderIndex]]; // Runtime Default Provider string runtimeProviderName = GetNameForProvider((ProviderId)_runtimeProvider.intValue); optionIndex = Array.IndexOf(_runtimeProviderOptions, runtimeProviderName); _runtimeProviderIndex = EditorGUILayout.Popup( ObjectNames.NicifyVariableName(RuntimeDefaultProviderField), optionIndex >= 0 ? optionIndex : (int)WearableConstants.RuntimeDefaultProvider, _runtimeProviderOptions ); _runtimeProvider.intValue = (int)_runtimeProviderMap[_runtimeProviderOptions[_runtimeProviderIndex]]; } // Intent profile GUILayoutTools.LineSeparator(); DrawIntentsSection(); // Providers DrawProviderBox(DebugProviderField, ProviderId.DebugProvider); DrawProviderBox(ProxyProviderField, ProviderId.WearableProxy); DrawProviderBox(USBProviderField, ProviderId.USBProvider); DrawProviderBox(DeviceProviderField, ProviderId.WearableDevice); if (Application.isPlaying) { GUILayoutTools.LineSeparator(); if (_wearableControl.IsOverridingDeviceConfig) { EditorGUILayout.LabelField(OverrideDeviceConfigTitle, WearableConstants.EmptyLayoutOptions); EditorGUILayout.HelpBox(OverrideConfigPresentWarning, MessageType.Warning); using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.PropertyField( serializedObject.FindProperty(OverrideWearableDeviceConfigField), WearableConstants.EmptyLayoutOptions); } } else { EditorGUILayout.LabelField(ResolvedDeviceConfigTitle, WearableConstants.EmptyLayoutOptions); using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.PropertyField( serializedObject.FindProperty(FinalWearableDeviceConfigField), WearableConstants.EmptyLayoutOptions); } } } serializedObject.ApplyModifiedProperties(); }