public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUILayout.HelpBox(DescriptionBox, MessageType.None); EditorGUILayout.Space(); GUI.enabled = EditorApplication.isPlaying; bool shouldDisconnect = GUILayout.Button(DisconnectLabel, WearableConstants.EmptyLayoutOptions); GUI.enabled = true; if (shouldDisconnect) { WearableMobileProvider provider = fieldInfo.GetValue(property.serializedObject.targetObject) as WearableMobileProvider; provider.SimulateDisconnect(); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { WearableMobileProvider provider = (WearableMobileProvider)fieldInfo.GetValue(property.serializedObject.targetObject); EditorGUI.BeginProperty(position, label, property); EditorGUILayout.HelpBox(DescriptionBox, MessageType.None); EditorGUILayout.Space(); // Gesture triggers GUILayout.Label(GesturesLabel, WearableConstants.EmptyLayoutOptions); for (int i = 0; i < WearableConstants.GestureIds.Length; i++) { GestureId gesture = WearableConstants.GestureIds[i]; if (gesture == GestureId.None) { continue; } using (new EditorGUI.DisabledScope(!(provider.GetGestureEnabled(gesture) && EditorApplication.isPlaying))) { bool shouldTrigger = GUILayout.Button(Enum.GetName(typeof(GestureId), gesture), WearableConstants.EmptyLayoutOptions); if (shouldTrigger) { provider.SimulateGesture(gesture); } } } // Disconnect button EditorGUILayout.Space(); using (new EditorGUI.DisabledScope(!EditorApplication.isPlaying)) { bool shouldDisconnect = GUILayout.Button(DisconnectLabel, WearableConstants.EmptyLayoutOptions); if (shouldDisconnect) { provider.SimulateDisconnect(); } } EditorGUI.EndProperty(); }