void OnGUI()
{
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), background_texture);
// this must come before the TextEditor line below
halfbook.draw();
GUI.SetNextControlName("EditableCode");
stateObj = GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl) as TextEditor;
//GUI.FocusControl("EditableCode");
// Give the appropriate text area keyboard control -> this prevents us from moving the player while in the IDE
// if (Event.current.rawType == EventType.MouseDown) {
// Debug.Log("caught mousedown event");
// if (editorPanel.isWithin(Event.current.mousePosition))
// GUI.FocusControl("EditableCode");
// else
// GUI.FocusControl("ReferenceCode");
// Debug.Log("focus control: "+GUI.GetNameOfFocusedControl());
// }
if (shouldPopup)
{
// GUI.DrawTexture(editorPanel.getRect(),left_panel_background);
// //GUI.DrawTexture(new Rect(0,0,Screen.width*3/4,Screen.height),left_panel_background);
// GUILayout.BeginArea(new Rect(120,40,Screen.width*3/4,Screen.height));
//
// scroll_position = GUILayout.BeginScrollView (scroll_position, GUILayout.Width(Screen.width*3/4-200), GUILayout.Height(Screen.height-60 )); // Should vary the size of the last rect by how much text we have??
//
// GUILayout.EndScrollView ();
// GUILayout.EndArea();
editorPanel.draw(false);
int boxWidth = 300;
int boxHeight = 75;
GUIStyle style = GUI.skin.box;
style.alignment = TextAnchor.UpperCenter;
GUI.Box(new Rect(Screen.width / 2 - boxWidth / 2, Screen.height / 2 - boxHeight / 2, boxWidth, boxHeight), "Are you sure you want to delete your script?", style);
if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + box_height / 2 - 20, 50, 30), "Yes"))
{
no_edit = false;
shouldRemove = true;
shouldPopup = false;
}
if (GUI.Button(new Rect(Screen.width / 2 + 30, Screen.height / 2 + box_height / 2 - 20, 50, 30), "No"))
{
no_edit = false;
shouldPopup = false;
}
}
else
{
//leftPanel();
editorPanel.draw(true);
}
if (shouldRemove)
{
removeScript();
}
//rightPanel();
errorPanel.draw();
buttonPanel.draw();
if (GUI.GetNameOfFocusedControl() == "EditableCode")
{
adjustScroll();
catchTabs();
detectKeyboardActivity();
logKeyboardActivity();
}
// check if the spellbook (outside of the code region) was clicked
// if so, we want to make it full screen
if (Event.current.type == EventType.MouseDown)
{
Vector2 pos = Event.current.mousePosition;
if (halfbook.getBookRect().Contains(pos) && !halfbook.getTextRect().Contains(pos) && !errorPanel.getErrorRect().Contains(pos) && !editorPanel.getEditorRect().Contains(pos))
{
spellbook.setNoCopyDisplay(true);
spellbook.show(GameObject.Find("IDE"));
}
}
// make it so that we can't click through to the game
// NOTE: This must appear LAST in the OnGUI. Otherwise, other buttons won't work!
GUI.Button(new Rect(0, 0, Screen.width, Screen.height), "", empty_style);
}