예제 #1
0
        void Awake()
        {
            m_instance = this;

            itemHeight = ((RectTransform)itemPrefab.transform).sizeDelta.y;

            nullPointerEventData = new UnityEngine.EventSystems.PointerEventData(null);

            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);
        }
예제 #2
0
 public void SetFileBrowser(FileBrowser fileBrowser)
 {
     this.fileBrowser = fileBrowser;
     background.color = fileBrowser.normalFileColor;
 }
예제 #3
0
 public void SetFileBrowser(FileBrowser fileBrowser)
 {
     this.fileBrowser = fileBrowser;
 }
 public void Initialize(FileBrowser fileBrowser)
 {
     this.fileBrowser = fileBrowser;
     canvasTR         = fileBrowser.GetComponent <RectTransform>();
 }
        public static FileSystemEntry[] GetEntriesInDirectory(string path, bool extractOnlyLastSuffixFromExtensions)
        {
#if !UNITY_EDITOR && UNITY_ANDROID
            if (ShouldUseSAFForPath(path))
            {
                string resultRaw      = AJC.CallStatic <string>("OpenSAFFolder", Context, path);
                int    separatorIndex = resultRaw.IndexOf("<>");
                if (separatorIndex <= 0)
                {
                    Debug.LogError("Entry count does not exist");
                    return(null);
                }

                int entryCount = 0;
                for (int i = 0; i < separatorIndex; i++)
                {
                    char ch = resultRaw[i];
                    if (ch < '0' && ch > '9')
                    {
                        Debug.LogError("Couldn't parse entry count");
                        return(null);
                    }

                    entryCount = entryCount * 10 + (ch - '0');
                }

                if (entryCount <= 0)
                {
                    return(null);
                }

                FileSystemEntry[] result = new FileSystemEntry[entryCount];
                for (int i = 0; i < entryCount; i++)
                {
                    separatorIndex += 2;
                    if (separatorIndex >= resultRaw.Length)
                    {
                        Debug.LogError("Couldn't fetch directory attribute");
                        return(null);
                    }

                    bool isDirectory = resultRaw[separatorIndex] == 'd';

                    separatorIndex++;
                    int nextSeparatorIndex = resultRaw.IndexOf("<>", separatorIndex);
                    if (nextSeparatorIndex <= 0)
                    {
                        Debug.LogError("Entry name is empty");
                        return(null);
                    }

                    string entryName = resultRaw.Substring(separatorIndex, nextSeparatorIndex - separatorIndex);

                    separatorIndex     = nextSeparatorIndex + 2;
                    nextSeparatorIndex = resultRaw.IndexOf("<>", separatorIndex);
                    if (nextSeparatorIndex <= 0)
                    {
                        Debug.LogError("Entry rawUri is empty");
                        return(null);
                    }

                    string rawUri = resultRaw.Substring(separatorIndex, nextSeparatorIndex - separatorIndex);

                    separatorIndex = nextSeparatorIndex;

                    result[i] = new FileSystemEntry(rawUri, entryName, isDirectory ? null : FileBrowser.GetExtensionFromFilename(entryName, extractOnlyLastSuffixFromExtensions), isDirectory);
                }

                return(result);
            }
#endif

            try
            {
                FileSystemInfo[]  items  = new DirectoryInfo(path).GetFileSystemInfos();
                FileSystemEntry[] result = new FileSystemEntry[items.Length];
                int index = 0;
                for (int i = 0; i < items.Length; i++)
                {
                    try
                    {
                        result[index] = new FileSystemEntry(items[i], FileBrowser.GetExtensionFromFilename(items[i].Name, extractOnlyLastSuffixFromExtensions));
                        index++;
                    }
                    catch (System.Exception e)
                    {
                        Debug.LogException(e);
                    }
                }

                if (result.Length != index)
                {
                    System.Array.Resize(ref result, index);
                }

                return(result);
            }
            catch (System.Exception e)
            {
                Debug.LogException(e);
                return(null);
            }
        }
예제 #6
0
 public void SetFileBrowser(FileBrowser fileBrowser, UISkin skin)
 {
     this.fileBrowser = fileBrowser;
     OnSkinRefreshed(skin, false);
 }