// 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(); }
protected override void LayoutContent() { // Server access token GUILayout.BeginHorizontal(); bool updated = false; WitEditorUI.LayoutPasswordField(WitTexts.SettingsServerTokenContent, ref serverToken, ref updated); if (updated) { RelinkServerToken(false); } if (WitEditorUI.LayoutTextButton(WitTexts.Texts.SettingsRelinkButtonLabel)) { RelinkServerToken(true); } if (WitEditorUI.LayoutTextButton(WitTexts.Texts.SettingsAddButtonLabel)) { int newIndex = WitConfigurationUtility.CreateConfiguration(serverToken); if (newIndex != -1) { SetConfiguration(newIndex); } } GUILayout.EndHorizontal(); GUILayout.Space(WitStyles.ButtonMargin); // Configuration select base.LayoutContent(); // Update inspector if needed if (witInspector == null || witConfiguration == null || witInspector.configuration != witConfiguration) { SetWitEditor(); } // Layout configuration inspector if (witConfiguration && witInspector) { witInspector.OnInspectorGUI(); } }
public static void WitCreateConfiguration() { WitConfigurationUtility.CreateConfiguration(WitAuthUtility.ServerToken); }
protected virtual int CreateConfiguration(string newToken) { return(WitConfigurationUtility.CreateConfiguration(newToken)); }