// Configuration select public static void LayoutConfigurationSelect(ref int configIndex) { // Refresh configurations if needed WitConfiguration[] witConfigs = WitConfigurationUtility.WitConfigs; if (witConfigs == null || witConfigs.Length == 0) { // If no configuration exists, provide a means for the user to create a new one. GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (WitEditorUI.LayoutTextButton("New Config")) { WitConfigurationUtility.CreateConfiguration(""); EditorUtility.FocusProjectWindow(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return; } // Clamp Config Index bool configUpdated = false; if (configIndex < 0 || configIndex >= witConfigs.Length) { configUpdated = true; configIndex = Mathf.Clamp(configIndex, 0, witConfigs.Length); } GUILayout.BeginHorizontal(); // Layout popup WitEditorUI.LayoutPopup(WitTexts.Texts.ConfigurationSelectLabel, WitConfigurationUtility.WitConfigNames, ref configIndex, ref configUpdated); if (GUILayout.Button("", GUI.skin.GetStyle("IN ObjectField"), GUILayout.Width(15))) { EditorUtility.FocusProjectWindow(); EditorGUIUtility.PingObject(witConfigs[configIndex]); } GUILayout.EndHorizontal(); }
public static void LayoutKeyObjectLabels(string key, object obj) { // Null if (obj == null) { LayoutKeyLabel(key, "NULL"); return; } // Foldout bool foldoutVoice = WitEditorUI.LayoutFoldout(new GUIContent(key), obj); if (!foldoutVoice) { return; } // Iterate fields EditorGUI.indentLevel++; foreach (var field in obj.GetType().GetFields()) { LayoutKeyLabel(field.Name, field.GetValue(obj).ToString()); } EditorGUI.indentLevel--; }