/// <summary> /// Renders the file browser. Native filebrowser class derived from Crosstales plugin. /// </summary> public override void OnGUI() { if (fileBrowser == null) { // Standalone plugin adaptions from: https://github.com/gkngkc/UnityStandaloneFileBrowser filePath = SFB.StandaloneFileBrowser.OpenFolderPanel(prefsKey, directory, false); if (!string.IsNullOrEmpty(filePath)) { fileBrowser = new SynthesisFileBrowser("Choose Directory", filePath, true); filePath = fileBrowser.directoryLocation; fileBrowser.OnComplete += OnBrowserComplete; fileBrowser.CompleteDirectorySelection(); pathLabel.text = filePath; } else { UserMessageManager.Dispatch("Selection canceled", 5); StateMachine.PopState(); } } }
/// <summary> /// Renders the file browser. Native filebrowser class derived from Crosstales plugin. /// </summary> public override void OnGUI() { if (fileBrowser == null) { // Standalone plugin adaptions from: https://github.com/gkngkc/UnityStandaloneFileBrowser filePath = SFB.StandaloneFileBrowser.OpenFolderPanel(prefsKey, directory, false); //check for empty string(if native file browser is closed without selection) and default to Fields directory if (string.IsNullOrEmpty(filePath)) { filePath = PlayerPrefs.GetString(prefsKey, directory); } if (filePath.Length != 0) { fileBrowser = new GUI.SynthesisFileBrowser("Choose Directory", filePath, true); filePath = fileBrowser.directoryLocation; fileBrowser.OnComplete += OnBrowserComplete; fileBrowser.CompleteDirectorySelection(); pathLabel.text = filePath; } } }