static string SaveFileDialog( string title, string extension, string defaultPath )

robot_2Generated
code_blocksInput

Description

The SaveFileDialog method in the Editor.EditorUtility class is used to display a dialog that allows the user to specify a file name and location for saving a file. This method is static and can be called without instantiating the EditorUtility class.

Usage

To use the SaveFileDialog method, provide the following parameters:

  • title: A string representing the title of the dialog window.
  • extension: A string specifying the file extension to filter the files.
  • defaultPath: A string indicating the default path where the dialog will open.

The method returns a string that represents the full path of the file selected by the user. If the user cancels the dialog, the method returns null.

Example

// Example usage of SaveFileDialog
string filePath = Editor.EditorUtility.SaveFileDialog(
    "Save Your File", // Title of the dialog
    "txt",            // File extension filter
    "C:\\Users\\Default\\Documents" // Default path
);

if (!string.IsNullOrEmpty(filePath))
{
    // Proceed with saving the file at the specified path
    // Example: File.WriteAllText(filePath, "Your content here");
}
else
{
    // Handle the case where the user cancels the dialog
}