private void Awake() { //workspacePath = GameObject.Find("DataCache").GetComponent<DataCache>().Find("WorkspaceName"); var dataPath = FileAndDirectory.Instance.WorkspacePath; string workspacePath = "Demo"; //folderList = new List<GameObject>(); //fileList = new List<GameObject>(); FileAndDirectory.Instance.ProjectName = workspacePath; //UpdateDictionaryTree(FileAndDictionary.Instance.FolderPath, transform); dt = new DirectoryTree(FileAndDirectory.Instance.FolderPath, transform); dt.ScanFolder(folderObj, fileObj); dt.Extend(); }
public void ScanFolder(GameObject folderPrefab, GameObject filePrefab) { extended = false; var folders = FileAndDirectory.Instance.GetFoldersInFolder(curAbsPath); var files = FileAndDirectory.Instance.GetFilesInFolder(curAbsPath); for (int i = 0; i < folders.Length; i++) { var l = folders[i].Remove(0, curAbsPath.Length).Substring(1); if (l.Contains(".meta")) { continue; } if ((from item in folderList where item.name == l select item).Count() > 0) { continue; } var o = GameObject.Instantiate(folderPrefab); o.transform.parent = parentTrans; o.name = l; o.GetComponentInChildren <TextMesh>().text = l; o.SetActive(false); DirectoryTree ch = new DirectoryTree(System.IO.Path.Combine(curAbsPath, l), o.transform); ch.ScanFolder(folderPrefab, filePrefab); //ScanFolder(System.IO.Path.Combine(path, folders[i]), folderPrefab, filePrefab); children.Add(ch); folderList.Add(o); } for (int i = 0; i < files.Length; i++) { var l = files[i].Remove(0, curAbsPath.Length).Substring(1); if (l.Contains(".meta")) { continue; } if ((from item in fileList where item.name == l select item).Count() > 0) { continue; } var o = GameObject.Instantiate(filePrefab); o.name = l; o.GetComponentInChildren <TextMesh>().text = l; o.SetActive(false); fileList.Add(o); } folderList.Sort((GameObject a, GameObject b) => { return(a.name.CompareTo(b.name)); }); fileList.Sort((GameObject a, GameObject b) => { return(a.name.CompareTo(b.name)); }); children.Sort((DirectoryTree a, DirectoryTree b) => { return(a.relativePath.CompareTo(b.relativePath)); }); }
/* * private void GengerateDictionaryTree() * { * string path = FileAndDictionary.Instance.FolderPath; * var folders = FileAndDictionary.Instance.GetFoldersInFolder(path); * for (int i = 0; i < folders.Length; i++) * { * var l = folders[i].Remove(0, path.Length); * l = l.Substring(1); * if (l.Substring(l.Length - 5) == ".meta") continue; * var o = Instantiate(folderObj); * o.transform.parent = transform; * o.transform.localPosition = Vector3.down * folderCount; * o.transform.localRotation = Quaternion.identity; * o.transform.localScale = Vector3.one; * o.GetComponentInChildren<TextMesh>().text = l; * o.name = l; * * folderCount++; * folderList.Add(o); * } * var files = FileAndDictionary.Instance.GetFilesInFolder(path); * for (int i = 0; i < files.Length; i++) * { * var l = files[i].Remove(0, path.Length); * l = l.Substring(1); * if (l.Substring(l.Length - 5) == ".meta") continue; * //Debug.Log(i); * var o = Instantiate(fileObj); * o.name = l; * o.transform.parent = transform; * o.transform.localPosition = Vector3.down * (folderCount + fileCount); * o.transform.localRotation = Quaternion.identity; * o.transform.localScale = Vector3.one; * o.GetComponentInChildren<TextMesh>().text = l; * * fileCount++; * fileList.Add(o); * * if ((folderCount + fileCount) % 5 == 0) transform.position = transform.position + Vector3.up * 2; * } * } * * public void UpdateDictionaryTree(string path, Transform parent) * { * Debug.Log(path); * * var folders = FileAndDictionary.Instance.GetFoldersInFolder(path); * var files = FileAndDictionary.Instance.GetFilesInFolder(path); * * for (int i = 0; i < folders.Length; i++) * { * var l = folders[i].Remove(0, path.Length).Substring(1); * if (l.Contains(".meta")) continue; * * if ((from item in folderList * where item.name == l * select item).Count() > 0) continue; * * var o = Instantiate(folderObj); * o.transform.parent = transform; * //o.transform.localPosition = Vector3.down * folderCount; * o.transform.localRotation = Quaternion.identity; * o.transform.localScale = Vector3.one; * o.GetComponentInChildren<TextMesh>().text = l; * o.name = l; * * UpdateDictionaryTree(System.IO.Path.Combine(path, l), o.transform); * * folderCount++; * folderList.Add(o); * } * * for (int i = 0; i < files.Length; i++) * { * var l = files[i].Remove(0, path.Length).Substring(1); * if (l.Contains(".meta")) continue; * * if ((from item in fileList * where item.name == l * select item).Count() > 0) continue; * * var o = Instantiate(fileObj); * o.name = l; * o.transform.parent = transform; * //o.transform.localPosition = Vector3.down * (folderCount + fileCount); * o.transform.localRotation = Quaternion.identity; * o.transform.localScale = Vector3.one; * o.GetComponentInChildren<TextMesh>().text = l; * * fileCount++; * fileList.Add(o); * * //if ((folderCount + fileCount) % 5 == 0) transform.position = transform.position + Vector3.up * 2; * } * * folderList.Sort((GameObject a, GameObject b) => { return a.name.CompareTo(b.name); }); * fileList.Sort((GameObject a, GameObject b) => { return a.name.CompareTo(b.name); }); * * Vector3 par = parent.transform.localPosition; * par.y = 0; * par.z = 0; * par.x += 0.5f; * for (int i = 0; i < folderList.Count; i++) * { * folderList[i].transform.localPosition = Vector3.down * i + par; * } * for (int i = 0; i < fileList.Count; i++) * { * fileList[i].transform.localPosition = Vector3.down * (folderCount + i) + par; * } * } */ public void CreateFile() { //UpdateDictionaryTree(FileAndDictionary.Instance.FolderPath, transform); dt.ScanFolder(folderObj, fileObj); }