void Awake() { m_instance = this; InitRerences(); itemPrefab = CreateFbItem(); quickLinkPrefab = CreateQuickLink(); itemHeight = ((RectTransform)itemPrefab.transform).sizeDelta.y; itemPrefab.gameObject.SetActive(false); quickLinkPrefab.gameObject.SetActive(false); nullPointerEventData = new UnityEngine.EventSystems.PointerEventData(null); #if !UNITY_EDITOR && UNITY_IOS DEFAULT_PATH = Application.persistentDataPath; #else DEFAULT_PATH = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); #endif InitializeFiletypeIcons(); filetypeIcons = null; SetExcludedExtensions(excludeExtensions); excludeExtensions = null; filenameInputField.onValidateInput += OnValidateFilenameInput; InitializeQuickLinks(); quickLinks = null; allFilesFilter = new Filter(ALL_FILES_FILTER_TEXT); filters.Add(allFilesFilter); listView.SetAdapter(this); }
public void OnQuickLinkSelected(FileBrowserQuickLink quickLink) { if (quickLink != null) { CurrentPath = quickLink.TargetPath; } }
private bool AddQuickLink(Sprite icon, string name, string path, ref Vector2 anchoredPos) { if (path == null || path.Length == 0) { return(false); } try { path = GetPathWithoutTrailingDirectorySeparator(path); } catch (ArgumentException) { return(false); } catch (PathTooLongException) { return(false); } if (!Directory.Exists(path)) { return(false); } // Don't add quick link if it already exists if (addedQuickLinksSet.Contains(path)) { return(false); } FileBrowserQuickLink quickLink = Instantiate(quickLinkPrefab, quickLinksContainer, false); quickLink.SetFileBrowser(this); if (icon != null) { quickLink.SetQuickLink(icon, name, path); } else { quickLink.SetQuickLink(folderIcon, name, path); } quickLink.transformComponent.anchoredPosition = anchoredPos; anchoredPos.y -= itemHeight; addedQuickLinksSet.Add(path); return(true); }
private bool AddQuickLink(Sprite icon, string name, string path, ref Vector2 anchoredPos) { if (string.IsNullOrEmpty(path)) { return(false); } if (!Directory.Exists(path)) { return(false); } // Don't add quick link if it already exists if (addedQuickLinksSet.Contains(path)) { return(false); } FileBrowserQuickLink quickLink = (FileBrowserQuickLink)Instantiate(quickLinkPrefab, quickLinksContainer, false); quickLink.gameObject.SetActive(true); quickLink.SetFileBrowser(this); if (icon != null) { quickLink.SetQuickLink(icon, name, path); } else { quickLink.SetQuickLink(folderIcon, name, path); } quickLink.TransformComponent.anchoredPosition = anchoredPos; anchoredPos.y -= itemHeight; addedQuickLinksSet.Add(path); return(true); }