//This method recieves a delegate to callback when the file is already selected public void getFilePathWithFormat(string fileFormat, FileBrowserCallback callback) { lazyInitComponents(); openFileDialog.Filter = fileFormat; DialogResult dialogResult = openFileDialog.ShowDialog(); //Invoke the delegate switch (dialogResult) { case DialogResult.OK: string path = openFileDialog.FileName; Debug.WriteLine(path); callback.Invoke(path); break; case DialogResult.No: path = ""; callback.Invoke(path); break; case DialogResult.Cancel: path = ""; callback.Invoke(path); break; } }
void Start() { instance = this; projectPath = Directory.GetCurrentDirectory(); projectPathInfo = new DirectoryInfo(projectPath); mainCam = Camera.main; MenuController.addBtn("Change project path", () => { fileBrowserStatus = FileBrowserStatus.ProjectPath; }); btnCancel.onClick.AddListener(() => { fileBrowserStatus = FileBrowserStatus.Closed; }); btnConfirm.onClick.AddListener(() => { if (fileBrowserStatus == FileBrowserStatus.ProjectPath) { projectPath = resultPath.text; } else if (fileBrowserCallback != null) { fileBrowserCallback(resultPath.text); fileBrowserCallback = null; } fileBrowserStatus = FileBrowserStatus.Closed; }); fileBrowserStatus = FileBrowserStatus.ProjectPath; }
public void show(FileBrowserCallback callback, string[] filters = null) { _callback = callback; _file.set_filters(filters); }