static void Init() { BaseWitWindow.RefreshConfigList(); bool hasConfig = false; for (int i = 0; i < witConfigs.Length; i++) { if (!string.IsNullOrEmpty(witConfigs[i].clientAccessToken)) { hasConfig = true; break; } } if (hasConfig) { WitUnderstandingViewer window = EditorWindow.GetWindow( typeof(WitUnderstandingViewer)) as WitUnderstandingViewer; window.titleContent = new GUIContent("Understanding Viewer", WitStyles.WitIcon); window.autoRepaintOnSceneChange = true; window.Show(); } else { WitWelcomeWizard.ShowWizard(Init); } }
protected override bool DrawWizardGUI() { maxSize = minSize = new Vector2(400, 375); BaseWitWindow.DrawHeader("https://wit.ai/apps"); GUILayout.BeginHorizontal(); GUILayout.Space(16); GUILayout.BeginVertical(); GUILayout.Label("Build Natural Language Experiences", WitStyles.LabelHeader); GUILayout.Label( "Empower people to use your product with voice and text", WitStyles.LabelHeader2); GUILayout.EndVertical(); GUILayout.Space(16); GUILayout.EndHorizontal(); GUILayout.Space(32); BaseWitWindow.BeginCenter(296); GUILayout.BeginHorizontal(); GUILayout.Label("Paste your Server Access Token here", WitStyles.Label); GUILayout.FlexibleSpace(); if (GUILayout.Button(WitStyles.PasteIcon, WitStyles.Label)) { serverToken = EditorGUIUtility.systemCopyBuffer; WitAuthUtility.ServerToken = serverToken; ValidateAndClose(); } GUILayout.EndHorizontal(); if (null == serverToken) { serverToken = WitAuthUtility.ServerToken; } serverToken = EditorGUILayout.PasswordField(serverToken, WitStyles.TextField); BaseWitWindow.EndCenter(); return(WitAuthUtility.IsServerTokenValid()); }
protected override bool DrawWizardGUI() { base.DrawWizardGUI(); GUILayout.BeginHorizontal(); GUILayout.Space(24); GUILayout.BeginVertical(); GUILayout.Label("Building App Voice Experiences", WitStyles.LabelHeader, GUILayout.Height(64)); GUILayout.Label( "Empowering developers to build engaging voice interactions.", GUILayout.Height(EditorGUIUtility.singleLineHeight * 2)); GUILayout.EndVertical(); GUILayout.Space(24); GUILayout.EndHorizontal(); BaseWitWindow.BeginCenter(296); GUILayout.Label("Select language to use Built-In NLP", WitStyles.Label); int selected = EditorGUILayout.Popup("", witBuiltInIndex, builtinAppNames); if (selected != witBuiltInIndex) { witBuiltInIndex = selected; WitAuthUtility.ServerToken = AppBuiltIns.builtInPrefix + AppBuiltIns.appNames[witBuiltInIndex]; } BaseWitWindow.EndCenter(); if (witBuiltInIndex <= 0) { GUILayout.Space(16); BaseWitWindow.BeginCenter(296); GUILayout.BeginHorizontal(); var color = "blue"; if (EditorGUIUtility.isProSkin) { color = "#ccccff"; } if (GUILayout.Button( $"Paste your <color={color}>Wit.ai</color> Server Access Token here", WitStyles.Label)) { Application.OpenURL("https://wit.ai/apps"); } GUILayout.FlexibleSpace(); if (GUILayout.Button(WitStyles.PasteIcon, WitStyles.Label)) { serverToken = EditorGUIUtility.systemCopyBuffer; WitAuthUtility.ServerToken = serverToken; } GUILayout.EndHorizontal(); if (null == serverToken) { serverToken = WitAuthUtility.ServerToken; } serverToken = EditorGUILayout.PasswordField(serverToken); BaseWitWindow.EndCenter(); } return(WitAuthUtility.IsServerTokenValid()); }
public override void OnInspectorGUI() { if (!initialized || configuration != target) { Initialize(); initialized = true; } if (drawHeader) { string link = null; if (configuration && null != configuration.application && !string.IsNullOrEmpty(configuration.application.id)) { link = $"https://wit.ai/apps/{configuration.application.id}/settings"; } BaseWitWindow.DrawHeader(headerLink: link); } GUILayout.BeginVertical(EditorStyles.helpBox); GUILayout.BeginHorizontal(); GUILayout.Space(16); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); appConfigurationFoldout = EditorGUILayout.Foldout(appConfigurationFoldout, "Application Configuration", true); if (!string.IsNullOrEmpty(configuration?.application?.name)) { GUILayout.FlexibleSpace(); GUILayout.Label(configuration?.application?.name); } GUILayout.EndHorizontal(); bool hasApplicationInfo = configuration && null != configuration.application; if (appConfigurationFoldout || !IsTokenValid) { GUILayout.BeginHorizontal(); var token = EditorGUILayout.PasswordField("Server Access Token", currentToken); if (token != currentToken) { currentToken = token; ApplyToken(token); } if (configuration && GUILayout.Button("Refresh", GUILayout.Width(75))) { ApplyToken(currentToken); } if (GUILayout.Button(WitStyles.PasteIcon, WitStyles.ImageIcon)) { currentToken = EditorGUIUtility.systemCopyBuffer; ApplyToken(currentToken); } GUILayout.EndHorizontal(); if (configuration) { var clientToken = EditorGUILayout.PasswordField("Client Access Token", configuration.clientAccessToken); if (clientToken != configuration.clientAccessToken) { configuration.clientAccessToken = clientToken; EditorUtility.SetDirty(configuration); } var timeout = EditorGUILayout.IntField(new GUIContent("Request Timeout (ms)", "The amount of time a server request can take to respond to voice."), configuration.timeoutMS); if (timeout != configuration.timeoutMS) { configuration.timeoutMS = timeout; EditorUtility.SetDirty(configuration); } GUILayout.BeginHorizontal(); GUILayout.Space(16); GUILayout.BeginVertical(); endpointConfigurationFoldout = EditorGUILayout.Foldout(endpointConfigurationFoldout, "Endpoint Configuration", true); GUILayout.BeginHorizontal(); GUILayout.Space(16); GUILayout.BeginVertical(); if (endpointConfigurationFoldout) { if (null == configuration.endpointConfiguration) { configuration.endpointConfiguration = new WitEndpointConfig(); EditorUtility.SetDirty(configuration); } var confSerializedObject = new SerializedObject(configuration); var epConfProp = confSerializedObject.FindProperty("endpointConfiguration"); EditorGUILayout.PropertyField(epConfProp); confSerializedObject.ApplyModifiedProperties(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (hasApplicationInfo) { if (configuration.application.id != null && !configuration.application.id.StartsWith("voice")) { selectedToolPanel = GUILayout.Toolbar(selectedToolPanel, toolPanelNames); } else { selectedToolPanel = GUILayout.Toolbar(selectedToolPanel, toolPanelNamesOnlyAppInfo); } } else { selectedToolPanel = GUILayout.Toolbar(selectedToolPanel, toolPanelNamesWithoutAppInfo); } scroll = GUILayout.BeginScrollView(scroll); switch (hasApplicationInfo ? selectedToolPanel : selectedToolPanel + 1) { case TOOL_PANEL_APP: DrawApplication(configuration.application); break; case TOOL_PANEL_INTENTS: DrawIntents(); break; case TOOL_PANEL_ENTITIES: DrawEntities(); break; case TOOL_PANEL_TRAITS: DrawTraits(); break; } GUILayout.EndScrollView(); if (GUILayout.Button("Open Wit.ai")) { if (!string.IsNullOrEmpty(configuration.application?.id)) { Application.OpenURL($"https://wit.ai/apps/{configuration.application.id}"); } else { Application.OpenURL("https://wit.ai"); } } }