void OnGUI()
{
// Disable GUI during the play mode, or when no patch is available.
if (isPlayMode || _patch == null)
{
DrawNoPatchMessage();
return;
}
// Tool bar
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
// - Create node menu
_nodeFactory.CreateNodeMenuGUI(_patch);
GUILayout.Space(100);
// - Patch selector
var patchIndex = _patchManager.GetIndexOf(_patch);
var newPatchIndex = EditorGUILayout.Popup(
patchIndex, _patchManager.MakeNameList(),
EditorStyles.toolbarDropDown
);
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
// View area
EditorGUILayout.BeginHorizontal();
// - Main view
DrawMainViewGUI();
// - Side view (property editor)
DrawSideBarGUI();
EditorGUILayout.EndHorizontal();
// Re-initialize the editor if the patch selection was changed.
if (patchIndex != newPatchIndex)
{
_patch = _patchManager.RetrieveAt(newPatchIndex);
_patchManager.Select(_patch);
Repaint();
}
// Cancel wiring with a mouse click or hitting the esc key.
if (_wiring != null)
{
var e = Event.current;
if (e.type == EventType.MouseUp ||
(e.type == EventType.KeyDown && e.keyCode == KeyCode.Escape))
{
_wiring = null;
e.Use();
}
}
}