public void OpenFileDialog() { Stream myStream = null; ofd.InitialDirectory = "c:\\"; ofd.Filter = "ead files (*.ead) | *.ead |eap files (*.eap) | *.eap | All files(*.*) | *.* "; ofd.FilterIndex = 2; ofd.RestoreDirectory = true; if (ofd.ShowDialog() == DialogResult.OK) { if ((myStream = ofd.OpenFile()) != null) { using (myStream) { // Insert code to read the stream here. selectedGameProjectPath = ofd.FileName; GameRources.LoadGameProject(selectedGameProjectPath); EditorWindowBase.Init(); EditorWindowBase window = (EditorWindowBase)EditorWindow.GetWindow(typeof(EditorWindowBase)); window.Show(); } myStream.Dispose(); } } }
public void OnEnable() { if (!thisWindowReference) { thisWindowReference = this; EditorApplication.playModeStateChanged += Return; } else { DestroyImmediate(thisWindowReference); return; } if (!Language.Initialized) { Language.Initialize(); } if (!Controller.Instance.Initialized) { Controller.ResetInstance(); Controller.Instance.Init(); } var initialScene = AssetDatabase.LoadAssetAtPath <SceneAsset>("Assets/uAdventure/Scenes/_Scene1.unity"); if (initialScene) { EditorSceneManager.playModeStartScene = initialScene; } else { var title = "EditorWindow.MainSceneNotFound.Title".Traslate(); var body = "EditorWindow.MainSceneNotFound.Body".Traslate(); var ok = "GeneralText.OK".Traslate(); EditorUtility.DisplayDialog(title, body, ok); } if (!redoTexture) { redoTexture = Resources.Load <Texture2D>("EAdventureData/img/icons/redo"); } if (!undoTexture) { undoTexture = Resources.Load <Texture2D>("EAdventureData/img/icons/undo"); } if (!adaptationTexture) { adaptationTexture = Resources.Load <Texture2D>("EAdventureData/img/icons/adaptationProfiles"); } fileMenu = new FileMenu(); editMenu = new EditMenu(); adventureMenu = new AdventureMenu(); chaptersMenu = new ChaptersMenu(); configurationMenu = new ConfigurationMenu(); aboutMenu = new AboutMenu(); }
public AbstractEditorComponent(Rect rect, GUIContent content, GUIStyle style, params GUILayoutOption[] options) : base(rect, content, style, options) { var attr = Attribute; if (attr != null) { foreach (var t in attr.Types) { EditorWindowBase.RegisterComponent(t, this); } } }
public static void RegisterComponent(EditorComponent component) { var attr = GetAttribute(component.GetType()); if (attr != null) { foreach (var t in attr.Types) { EditorWindowBase.RegisterComponent(t, component); } } }
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(); } }
public void OnEnable() { if (!thisWindowReference) { thisWindowReference = this; } else { DestroyImmediate(thisWindowReference); } if (!Controller.getInstance().Initialized()) { Controller.resetInstance(); Language.Initialize(); Controller.getInstance().init(); } if (!redoTexture) { redoTexture = (Texture2D)Resources.Load("EAdventureData/img/icons/redo", typeof(Texture2D)); } if (!undoTexture) { undoTexture = (Texture2D)Resources.Load("EAdventureData/img/icons/undo", typeof(Texture2D)); } if (!adaptationTexture) { adaptationTexture = (Texture2D)Resources.Load("EAdventureData/img/icons/adaptationProfiles", typeof(Texture2D)); } fileMenu = new FileMenu(); editMenu = new EditMenu(); adventureMenu = new AdventureMenu(); chaptersMenu = new ChaptersMenu(); runMenu = new RunMenu(); configurationMenu = new ConfigurationMenu(); aboutMenu = new AboutMenu(); }
private void startNewGame() { int type = -1; switch (selectedGameType) { default: case GameType.FPS: type = Controller.FILE_ADVENTURE_1STPERSON_PLAYER; break; case GameType.TPS: type = Controller.FILE_ADVENTURE_3RDPERSON_PLAYER; break; } Stream myStream = null; sfd.InitialDirectory = "c:\\"; sfd.Filter = "ead files (*.ead) | *.ead |eap files (*.eap) | *.eap | All files(*.*) | *.* "; sfd.FilterIndex = 2; sfd.RestoreDirectory = true; if (sfd.ShowDialog() == DialogResult.OK) { if ((myStream = sfd.OpenFile()) != null) { using (myStream) { // Insert code to read the stream here. selectedGameProjectPath = sfd.FileName; if (GameRources.CreateGameProject(selectedGameProjectPath, type)) { GameRources.LoadGameProject(selectedGameProjectPath); EditorWindowBase.Init(); EditorWindowBase window = (EditorWindowBase)EditorWindow.GetWindow(typeof(EditorWindowBase)); window.Show(); } } myStream.Dispose(); } } }
protected override void Callback(object obj) { if ((obj as AddChapterMenuItem) != null) { add.OnCliked(); } else if ((obj as DeleteChapterMenuItem) != null) { delete.OnCliked(); } else if ((obj as ImportChapterMenuItem) != null) { import.OnCliked(); } else if ((obj as MoveUpChapterMenuItem) != null) { moveUp.OnCliked(); } else if ((obj as MoveDownChapterMenuItem) != null) { moveDown.OnCliked(); } else if ((obj as EditFlagsVariablesMenuItem) != null) { variablesFlags.OnCliked(); } else if ((obj is int)) { if ((int)obj != Controller.getInstance().getCharapterList().getSelectedChapter()) { Controller.getInstance().getCharapterList().setSelectedChapterInternal((int)obj); SetMenuItems(); EditorWindowBase.RefreshChapter(); } } }
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(); } } } }
public void OnCliked() { TC.loadstrings(ReleaseFolders.getLanguageFilePath4Editor(true, ReleaseFolders.LANGUAGE_CHINA)); EditorWindowBase.LanguageChanged(); }
public static void Init() { thisWindowReference = EditorWindow.GetWindow <EditorWindowBase>(); thisWindowReference.Show(); }