public void OpenFileDialog() { var fileFilter = "eap"; var result = EditorUtility.OpenFilePanel("Select file", "C://", fileFilter); if (result != "") { FileInfo file = new FileInfo(result); if (file.Exists) { // Insert code to read the stream here. Debug.Log("Opening project"); selectedGameProjectPath = file.FullName; GameRources.LoadGameProject(selectedGameProjectPath); Controller.OpenEditorWindow(); EditorWindowBase.RefreshWindows(); } } }
private void CreateNewAdventure() { int type; switch (selectedGameType) { default: Debug.LogError("Wrong adventure type selected"); return; case GameType.FPS: type = Controller.FILE_ADVENTURE_1STPERSON_PLAYER; break; case GameType.TPS: type = Controller.FILE_ADVENTURE_3RDPERSON_PLAYER; break; } if (EditorUtility.DisplayDialog("Warning", "Creating a new adventure deletes all previous existing files. Do you want to continue?", "Yes", "No")) { Controller.Instance.NewAdventure(type); Controller.OpenEditorWindow(); EditorWindowBase.RefreshWindows(); } }
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(); } } } }