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(); GUILayout.FlexibleSpace(); 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(); } } }
public void Init(string directory, List <string> preSelectedFiles, FileSelector.DoneCallback onFinishSelecting) { this.m_Directory = directory; this.m_FileScrollPos = new Vector2(); this.m_FileSelectedScrollPos = new Vector2(); this.m_OnFinishSelecting = onFinishSelecting; string str = string.Concat(Application.dataPath, this.m_Directory); this.m_RootDir = new FileSelector.FileNode(new DirectoryInfo(str), 0); preSelectedFiles.Sort(); this.SelectFiles(preSelectedFiles); }
public void Init(string directory, List <string> preSelectedFiles, FileSelector.DoneCallback onFinishSelecting) { this.m_Directory = directory; this.m_FileScrollPos = default(Vector2); this.m_FileSelectedScrollPos = default(Vector2); this.m_OnFinishSelecting = onFinishSelecting; string path = Application.dataPath + this.m_Directory; DirectoryInfo fileInfo = new DirectoryInfo(path); this.m_RootDir = new FileSelector.FileNode(fileInfo, 0); preSelectedFiles.Sort(); this.SelectFiles(preSelectedFiles); }
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(); FileSystemInfo[] array = fileSystemInfos; for (int i = 0; i < array.Length; i++) { FileSystemInfo fileSystemInfo = array[i]; 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; } }