public void OnGUI() { if (newGameWindow == null || openGameWindow == null) { newGameWindow = new NewGameWindow(windowRect, new GUIContent("New"), "Window"); openGameWindow = new OpenGameWindow(windowRect, new GUIContent("Open"), "Window"); } windowWidth = position.width; windowHeight = position.height; logoRect = new Rect(0.01f * windowWidth, 0.01f * windowHeight, windowWidth * 0.98f, windowHeight * 0.25f); buttonsRect = new Rect(0.01f * windowWidth, 0.27f * windowHeight, windowWidth * 0.98f, windowHeight * 0.28f); windowRect = new Rect(0.01f * windowWidth, 0.32f * windowHeight, 0.98f * windowWidth, 0.67f * windowHeight); GUI.DrawTexture(logoRect, logo); GUILayout.BeginArea(buttonsRect); GUILayout.BeginHorizontal(); if (GUILayout.Button("New")) { OnWindowTypeChanged(WelcomeWindowType.New); } if (GUILayout.Button("Open")) { OnWindowTypeChanged(WelcomeWindowType.Open); openGameWindow.OpenFileDialog(); } GUILayout.EndHorizontal(); GUILayout.EndArea(); BeginWindows(); switch (openedWindow) { case WelcomeWindowType.New: m_Window1 = newGameWindow; break; case WelcomeWindowType.Open: m_Window1 = openGameWindow; break; } if (m_Window1 != null) { m_Window1.Rect = windowRect; m_Window1.OnGUI(); } EndWindows(); }
public void OnGUI() { GUI.DrawTexture(logoRect, logo); GUILayout.BeginArea(buttonsRect); GUILayout.BeginHorizontal(); //if (GUILayout.Button(TC.get("GeneralText.New"))) if (GUILayout.Button("New")) { OnWindowTypeChanged(WelcomeWindowType.New); } //if (GUILayout.Button(TC.get("GeneralText.Open"))) if (GUILayout.Button("Open")) { OnWindowTypeChanged(WelcomeWindowType.Open); openGameWindow.OpenFileDialog(); } //if (GUILayout.Button(Language.GetText("RECENT_GAME"))) //{ // OnWindowTypeChanged(WelcomeWindowType.Recent); //} GUILayout.EndHorizontal(); GUILayout.EndArea(); BeginWindows(); //GUI.enabled = m_Window1 == null; switch (openedWindow) { case WelcomeWindowType.New: m_Window1 = newGameWindow; break; case WelcomeWindowType.Open: m_Window1 = openGameWindow; break; //case WelcomeWindowType.Recent: // m_Window1 = recentGameWindow; // break; } if (m_Window1 != null) { m_Window1.OnGUI(); } EndWindows(); }
protected void OnGUI() { this.wantsMouseMove = WantsMouseMove; InitWindows(); /** * UPPER MENU */ EditorGUILayout.BeginHorizontal("Toolbar", GUILayout.Height(TOP_MENU_HEIGHT)); if (GUILayout.Button(TC.get("MenuFile.Title"), "toolbarButton")) { fileMenu.menu.ShowAsContext(); } if (GUILayout.Button(TC.get("MenuEdit.Title"), "toolbarButton")) { editMenu.menu.ShowAsContext(); } if (GUILayout.Button(TC.get("MenuAdventure.Title"), "toolbarButton")) { adventureMenu.menu.ShowAsContext(); } if (GUILayout.Button(TC.get("MenuChapters.Title"), "toolbarButton")) { chaptersMenu.menu.ShowAsContext(); } if (GUILayout.Button(TC.get("MenuConfiguration.Title"), "toolbarButton")) { configurationMenu.menu.ShowAsContext(); } if (GUILayout.Button(TC.get("About"), "toolbarButton")) { aboutMenu.menu.ShowAsContext(); } EditorGUILayout.EndHorizontal(); /** * LEFT MENU */ if (Controller.Instance.Loaded) { EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); EditorGUILayout.BeginVertical(GUILayout.Width(LEFT_MENU_WIDTH), GUILayout.ExpandHeight(true)); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); // Button event chapter if (GUILayout.Button(TC.get("Element.Name0"))) { OnWindowTypeChanged(EditorWindowType.Chapter); } // Button event scene extensions.ForEach(e => e.LayoutDrawLeftPanelContent(null, null)); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); /** * WINDOWS */ windowArea = EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); switch (openedWindow) { case EditorWindowType.Chapter: m_Window = chapterWindow; break; default: if (extensionSelected != null) { m_Window = extensionSelected; } break; } if (m_Window != null) { if (Event.current.type == EventType.Repaint && m_Window.Rect != windowArea) { m_Window.Rect = windowArea; extensions.ForEach(e => e.Rect = windowArea); } m_Window.OnGUI(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); var unclippedDrawReceiver = m_Window as IUnclippedDrawReceiver; if (unclippedDrawReceiver != null) { unclippedDrawReceiver.UnclippedDraw(windowArea); } } else { GUILayout.Label("EditorWindow.NotLoaded".Traslate()); if (GUILayout.Button("EditorWindow.OpenWelcome".Traslate())) { Controller.OpenWelcomeWindow(); } if (GUILayout.Button("EditorWindow.Reload".Traslate())) { Controller.ResetInstance(); Controller.Instance.Init(); EditorWindowBase.RefreshWindows(); } if (GUILayout.Button("GeneralText.New".Traslate())) { var title = "EditorWindow.CreateNew.Title".Traslate(); var body = "EditorWindow.CreateNew.Body".Traslate(); var yes = "GeneralText.Yes".Traslate(); var no = "GeneralText.No".Traslate(); if (EditorUtility.DisplayDialog(title, body, yes, no)) { Controller.Instance.NewAdventure(Controller.FILE_ADVENTURE_1STPERSON_PLAYER); Controller.OpenEditorWindow(); EditorWindowBase.RefreshWindows(); } } } }
protected void OnGUI() { if (Locked) { GUI.depth = Int32.MaxValue; if (Event.current.type != EventType.Layout && Event.current.type != EventType.Repaint) { Event.current.Use(); } } else { GUI.depth = 0; } this.wantsMouseMove = WantsMouseMove; if (!inited) { Debug.Log("InitWindows " + inited); RefreshWindows(); } /** * UPPER MENU */ if (Menus != null && Menus.Count > 0) { EditorGUILayout.BeginHorizontal("Toolbar", GUILayout.Height(TOP_MENU_HEIGHT)); foreach (var kv in Menus) { if (GUILayout.Button(kv.Value, "toolbarButton")) { kv.Key.ShowAsContext(); } } EditorGUILayout.EndHorizontal(); } /** * LEFT MENU */ if (Controller.Instance.Loaded) { EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); EditorGUILayout.BeginVertical(GUILayout.Width(LEFT_MENU_WIDTH), GUILayout.ExpandHeight(true)); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); // Button event scene if (Extensions != null) { Extensions.ForEach(e => e.LayoutDrawLeftPanelContent(null, null)); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); /** * WINDOWS */ windowArea = EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); if (extensionSelected != null) { m_Window = extensionSelected; } if (m_Window != null) { if (Event.current.type == EventType.Repaint && m_Window.Rect != windowArea) { m_Window.Rect = windowArea; Extensions.ForEach(e => e.Rect = windowArea); } m_Window.OnGUI(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); var unclippedDrawReceiver = m_Window as IUnclippedDrawReceiver; if (unclippedDrawReceiver != null) { unclippedDrawReceiver.UnclippedDraw(windowArea); } } else { GUILayout.Label("EditorWindow.NotLoaded".Traslate()); if (Controller.Instance.HasError) { EditorGUILayout.TextArea(Controller.Instance.Error); } if (GUILayout.Button("EditorWindow.OpenWelcome".Traslate())) { Controller.OpenWelcomeWindow(); } if (GUILayout.Button("EditorWindow.Reload".Traslate())) { Controller.ResetInstance(); Controller.Instance.Init(); RefreshWindows(); } if (GUILayout.Button("GeneralText.New".Traslate())) { var title = "EditorWindow.CreateNew.Title".Traslate(); var body = "EditorWindow.CreateNew.Body".Traslate(); var yes = "GeneralText.Yes".Traslate(); var no = "GeneralText.No".Traslate(); if (EditorUtility.DisplayDialog(title, body, yes, no)) { Controller.Instance.NewAdventure(Controller.FILE_ADVENTURE_1STPERSON_PLAYER); Controller.OpenEditorWindow(); RefreshWindows(); } } } }
void OnGUI() { if (!Controller.getInstance().Initialized()) { this.OnEnable(); } InitWindows(); /** * UPPER MENU */ EditorGUILayout.BeginHorizontal("Toolbar", GUILayout.Height(TOP_MENU_HEIGHT)); if (GUILayout.Button(TC.get("MenuFile.Title"), "toolbarButton")) { fileMenu.menu.ShowAsContext(); } if (GUILayout.Button(TC.get("MenuChapters.Title"), "toolbarButton")) { chaptersMenu.menu.ShowAsContext(); } if (GUILayout.Button(TC.get("MenuConfiguration.Title"), "toolbarButton")) { configurationMenu.menu.ShowAsContext(); } if (GUILayout.Button(TC.get("About"), "toolbarButton")) { aboutMenu.menu.ShowAsContext(); } EditorGUILayout.EndHorizontal(); /** * LEFT MENU */ EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); var leftMenuRect = EditorGUILayout.BeginVertical(GUILayout.Width(LEFT_MENU_WIDTH), GUILayout.ExpandHeight(true)); //EditorGUILayout.BeginHorizontal(EditorGUILayout.MaxWidth(25), EditorGUILayout.MaxHeight(25)); //if (EditorGUILayout.Button(undoTexture, EditorGUILayout.MaxWidth(25), EditorGUILayout.MaxHeight(25))) //{ // UndoAction(); //} //EditorGUILayout.Space(5); //if (EditorGUILayout.Button(redoTexture, EditorGUILayout.MaxWidth(25), EditorGUILayout.MaxHeight(25))) //{ // RedoAction(); //} //EditorGUILayout.EndHorizontal(); //EditorGUILayout.Space(25); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); // Button event chapter if (GUILayout.Button(TC.get("Element.Name0"))) { OnWindowTypeChanged(EditorWindowType.Chapter); } // Button event scene extensions.ForEach(e => e.LayoutDrawLeftPanelContent(null, null)); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); /** * WINDOWS */ windowArea = EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); /*if (windowArea != null) * { * windowArea = GUILayoutUtility.GetRect(0, 0, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); * Debug.Log(Event.current.type + " " + windowArea); * }*/ //GUI.BeginGroup(windowArea); GUILayout.Label("Here should be windows"); BeginWindows(); //extensionSelected.OnGUI(); switch (openedWindow) { case EditorWindowType.Chapter: m_Window = chapterWindow; break; default: if (extensionSelected != null) { m_Window = extensionSelected; } break; } if (m_Window != null) { //leftMenuRect m_Window.OnGUI(); if (Event.current.type == EventType.repaint) { if (m_Window.Rect != windowArea) { // We first draw it with the old size to make the window respond the size change m_Window.OnGUI(); m_Window.Rect = windowArea; } extensions.ForEach(e => e.Rect = windowArea); } m_Window.OnGUI(); } EndWindows(); //GUI.EndGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }