private static void LoadScene() { string[] scenePaths; if (BrowseDialog.OpenFile(ProjectLibrary.ResourceFolder, "", false, out scenePaths)) { if (scenePaths.Length > 0) { LoadScene(scenePaths[0]); } } }
/// <summary> /// Triggered when the user clicks on the browse button. Opens a browse dialog that allows the user to select /// a project folder anywhere on the file system. /// </summary> void BrowseClicked() { string projectPath = projectInputBox.Value; if (!Directory.Exists(projectPath)) { projectPath = Directory.GetCurrentDirectory(); } string selectedPath; if (BrowseDialog.OpenFolder(projectPath, out selectedPath)) { projectInputBox.Value = selectedPath; OpenProject(); } }
/// <summary> /// Opens a dialog to allows the user to select a location where to save the current scene. /// </summary> public static void SaveSceneAs(Action onSuccess = null, Action onFailure = null) { string scenePath = ""; if (BrowseDialog.SaveFile(ProjectLibrary.ResourceFolder, "*.prefab", out scenePath)) { if (!PathEx.IsPartOf(scenePath, ProjectLibrary.ResourceFolder)) { DialogBox.Open("Error", "The location must be inside the Resources folder of the project.", DialogBox.Type.OK, x => { if (onFailure != null) { onFailure(); } }); } else { // TODO - If path points to an existing non-scene asset or folder I should delete it otherwise // Internal_SaveScene will silently fail. scenePath = Path.ChangeExtension(scenePath, ".prefab"); SaveScene(scenePath); } } else { // User canceled, so technically a success if (onSuccess != null) { onSuccess(); } } }