55 public void Draw(Rect rect, SerializedProperty property) {
56 var existingValue =
property.stringValue;
58 existingValue = pipeSyntaxPath.
path;
60 string currentDir =
null;
61 if (!
string.IsNullOrEmpty(existingValue)) {
62 currentDir = Path.GetDirectoryName(existingValue);
65 string chosenFile =
null;
66 if (GUI.Button(rect,
"...")) {
68 chosenFile = EditorUtility.OpenFolderPanel(
"Choose Folder", currentDir,
null);
69 if (!
string.IsNullOrEmpty(chosenFile)) {
70 chosenFile += Path.DirectorySeparatorChar;
72 var existingName = Path.GetFileName(existingValue);
73 chosenFile = Path.Combine(chosenFile, existingName);
78 chosenFile = EditorUtility.OpenFilePanel(
"Choose File", currentDir,
82 chosenFile = EditorUtility.SaveFilePanel(
"Output File", currentDir,
87 if (!
string.IsNullOrEmpty(chosenFile)) {
88 property.stringValue = pipeSyntaxPath.ChangePath(chosenFile).ToString();
FileChooserAttribute(FileDialogType dialogType, bool preserveExistingFileName=false, string extension=null)
string extension
Expected file extension .
FileDialogType dialogType
bool preserveExistingFileName
FolderChooserAttribute(bool preserveExistingFileName=false, string extension=null)
ReadFileChooserAttribute(bool preserveExistingFileName=false, string extension=null)
WriteFileChooserAttribute(bool preserveExistingFileName=false, string extension=null)
string path
The file path, cleaned of any pipe syntax.
static PipeFileSyntax Parse(string pathMaybeWithPipes)