Exemple #1
0
        private void RenderSelectedFileList()
        {
            LinkedListNode <FileSelector.FileNode> linkedListNode = this.m_SelectedFiles.First;

            while (linkedListNode != null)
            {
                FileSelector.FileNode value = linkedListNode.Value;
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                value.Selected = GUILayout.Toggle(value.Selected, GUIContent.none, new GUILayoutOption[0]);
                value.RenderIconText();
                if (MainAssetsUtil.CanPreview && GUILayout.Button("Preview", new GUILayoutOption[0]))
                {
                    MainAssetsUtil.Preview(value.Name);
                }
                if (!value.Selected)
                {
                    LinkedListNode <FileSelector.FileNode> node = linkedListNode;
                    linkedListNode = linkedListNode.Next;
                    this.m_SelectedFiles.Remove(node);
                }
                else
                {
                    linkedListNode = linkedListNode.Next;
                    GUILayout.EndHorizontal();
                }
            }
        }
Exemple #2
0
            public FileNode(FileSystemInfo fileInfo, int depth = 0)
            {
                string fullName = fileInfo.FullName;

                this.m_Name           = fileInfo.Name;
                this.m_Depth          = depth;
                this.m_RelativePath   = "Assets/" + fullName.Substring(Application.dataPath.Length + 1);
                this.m_RelativePath   = this.m_RelativePath.Replace("\\", "/");
                this.m_SubFiles       = new List <FileSelector.FileNode>();
                this.m_SubDirectories = new List <FileSelector.FileNode>();
                this.m_Children       = new List <FileSelector.FileNode>();
                if (fileInfo is DirectoryInfo)
                {
                    this.m_Icon = EditorGUIUtility.FindTexture("_Folder");
                    if (this.m_Icon == null)
                    {
                        this.m_Icon = EditorGUIUtility.FindTexture("Folder Icon");
                    }
                    this.m_isDir = true;
                    DirectoryInfo    directoryInfo   = fileInfo as DirectoryInfo;
                    FileSystemInfo[] fileSystemInfos = directoryInfo.GetFileSystemInfos();
                    foreach (FileSystemInfo fileSystemInfo in fileSystemInfos)
                    {
                        if (!fileSystemInfo.Name.EndsWith(".meta") && !fileSystemInfo.Name.StartsWith(".") && !fileSystemInfo.Name.EndsWith(".unity"))
                        {
                            FileSelector.FileNode item = new FileSelector.FileNode(fileSystemInfo, this.m_Depth + 1);
                            if (fileSystemInfo is DirectoryInfo)
                            {
                                this.m_SubDirectories.Add(item);
                            }
                            else
                            {
                                this.m_SubFiles.Add(item);
                            }
                            this.m_Children.Add(item);
                        }
                    }
                    this.m_Children.Sort(FileSelector.FileNode.alphabeticalComparer);
                    return;
                }
                this.m_Icon = (AssetDatabase.GetCachedIcon(this.m_RelativePath) as Texture2D);
                if (!this.m_Icon)
                {
                    this.m_Icon = EditorGUIUtility.ObjectContent(null, typeof(MonoBehaviour)).image;
                }
            }