in Scripts/Editor/Utility/WitUnderstandingViewer.cs [186:274]
protected override void LayoutContent()
{
// Layout wit select
base.LayoutContent();
// Need configuration
if (!witConfiguration)
{
WitEditorUI.LayoutErrorLabel(WitTexts.Texts.UnderstandingViewerMissingConfigLabel);
return;
}
// Need app id
string clientAccessToken = witConfiguration.clientAccessToken;
if (string.IsNullOrEmpty(clientAccessToken))
{
WitEditorUI.LayoutErrorLabel(WitTexts.Texts.UnderstandingViewerNoAppLabel);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (WitEditorUI.LayoutTextButton(WitTexts.Texts.UnderstandingViewerSettingsButtonLabel))
{
Selection.activeObject = witConfiguration;
}
GUILayout.EndHorizontal();
return;
}
bool updated = false;
bool allowInput = !wit || !wit.Active;
GUI.enabled = allowInput;
WitEditorUI.LayoutTextField(new GUIContent(WitTexts.Texts.UnderstandingViewerUtteranceLabel), ref utterance, ref updated);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (allowInput && WitEditorUI.LayoutTextButton(WitTexts.Texts.UnderstandingViewerSubmitButtonLabel))
{
responseText = "";
if (!string.IsNullOrEmpty(utterance))
{
SubmitUtterance();
}
else
{
response = null;
}
}
GUI.enabled = true;
if (EditorApplication.isPlaying && wit)
{
if (!wit.Active && WitEditorUI.LayoutTextButton(WitTexts.Texts.UnderstandingViewerActivateButtonLabel))
{
wit.Activate();
}
if (wit.Active && WitEditorUI.LayoutTextButton(WitTexts.Texts.UnderstandingViewerDeactivateButtonLabel))
{
wit.Deactivate();
}
if (wit.Active && WitEditorUI.LayoutTextButton(WitTexts.Texts.UnderstandingViewerAbortButtonLabel))
{
wit.DeactivateAndAbortRequest();
}
}
GUILayout.EndHorizontal();
// Results
GUILayout.BeginVertical(EditorStyles.helpBox);
if (wit && wit.MicActive)
{
WitEditorUI.LayoutWrapLabel(WitTexts.Texts.UnderstandingViewerListeningLabel);
}
else if (wit && wit.IsRequestActive)
{
WitEditorUI.LayoutWrapLabel(WitTexts.Texts.UnderstandingViewerLoadingLabel);
}
else if (response != null)
{
DrawResponse();
}
else if (string.IsNullOrEmpty(responseText))
{
WitEditorUI.LayoutWrapLabel(WitTexts.Texts.UnderstandingViewerPromptLabel);
}
else
{
WitEditorUI.LayoutWrapLabel(responseText);
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}