public void OpenLoadFileBrowser() { Confirm.Open("Loading a map will delete any currently unsaved progress.\nConfirm?", () => { FileBrowser.Create(Path.Combine(Content.CustomContentPath, "Maps"), ".json", LoadFile); }); }
public void Load() { Confirm.Open("Loading an assembly will trash unsaved progress on current assembly.\nConfirm?", () => { FileBrowser.Create(Path.Combine(Content.CustomContentPath, "Assemblies"), ".json", LoadFile); }); }
/* * virtual RectTransform CreatePath() * { * } * * virtual RectTransform CreateBreadcrumb() * { * } * * virtual RectTransform CreateFileBrowseRegion() * { * } */ public FileBrowser CreateFileBrowser(RectTransform parent, string extensions, bool saving) { GameObject go = new GameObject("FileBrowser"); go.transform.SetParent(parent); go.transform.localScale = Vector3.one; go.transform.localRotation = Quaternion.identity; FileBrowser browser = go.AddComponent <FileBrowser>(); browser.Create(this, this.properties, "", extensions, saving); return(browser); }
/// <summary> /// Display a inputs to select file. /// </summary> /// <param name="path">The path.</param> /// <param name="fEditor">if set to <c>true</c> [f editor].</param> /// <param name="verticalSpacing">The vertical spacing.</param> /// <returns></returns> public string InputFile(string path, bool fEditor = false, int verticalSpacing = 7) { if (verticalSpacing > 0) { GUILayout.Space(verticalSpacing); } GUILayout.BeginHorizontal(GUI.skin.box); GUILayout.Label(path ?? "Select a file...", GlobalStyles.CenteredLabelStyle); if (GUILayout.Button("Browse...", GUILayout.MaxWidth(100))) { if (fEditor) { #if UNITY_EDITOR var p = EditorUtility.OpenFilePanelWithFilters("Select a file", path, new[] { "Image files", "png,jpg,jpeg,bmp,gif,tif" }); path = string.IsNullOrEmpty(p) ? null : p; #endif } else { if (MyFileBrowser == null) { MyFileBrowser = FileBrowser.Create(); } path = MyFileBrowser.Open(); } } GUILayout.EndHorizontal(); if (!fEditor && MyFileBrowser != null && MyFileBrowser.IsReady()) { path = MyFileBrowser.CurrentPath; } return(path); }