private void UpdateDrivesList() { GameObject gameObject = this.drivesScrollRectContent; for (int i = 0; i < gameObject.transform.childCount; i++) { UnityEngine.Object.Destroy(gameObject.transform.GetChild(i).gameObject); } string[] logicalDrives = Directory.GetLogicalDrives(); for (int j = 0; j < (int)logicalDrives.Length; j++) { GameObject vector3 = UnityEngine.Object.Instantiate <GameObject>(this.drivesScrollRectElement, Vector3.zero, Quaternion.identity); vector3.transform.SetParent(gameObject.transform, true); vector3.transform.localScale = new Vector3(1f, 1f, 1f); FileListElement component = vector3.GetComponent <FileListElement>(); component.instance = this; component.data = logicalDrives[j]; component.elementName.text = logicalDrives[j]; component.isFile = false; } }
private void UpdateFilesList() { GameObject gameObject = this.filesScrollRectContent; for (int i = 0; i < gameObject.transform.childCount; i++) { UnityEngine.Object.Destroy(gameObject.transform.GetChild(i).gameObject); } DirectoryInfo directoryInfo = new DirectoryInfo(this.workingPath); try { DirectoryInfo[] directories = directoryInfo.GetDirectories(); for (int j = 0; j < (int)directories.Length; j++) { if (directories[j].Name[0] != '@' && directories[j].Name[0] != '.' && (directories[j].Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { GameObject vector3 = UnityEngine.Object.Instantiate <GameObject>(this.filesScrollRectElement, Vector3.zero, Quaternion.identity); vector3.transform.SetParent(gameObject.transform, true); vector3.transform.localScale = new Vector3(1f, 1f, 1f); FileListElement component = vector3.GetComponent <FileListElement>(); component.instance = this; component.data = string.Concat(directories[j].FullName, "/"); component.elementName.text = directories[j].Name; component.size.text = ""; component.icon.sprite = this.folderIcon; component.isFile = false; } } if (this.allowedExtensions == null) { FileInfo[] files = directoryInfo.GetFiles(); for (int k = 0; k < (int)files.Length; k++) { if (this.maxSize <= (long)0) { GameObject vector31 = UnityEngine.Object.Instantiate <GameObject>(this.filesScrollRectElement, Vector3.zero, Quaternion.identity); vector31.transform.SetParent(gameObject.transform, true); vector31.transform.localScale = new Vector3(1f, 1f, 1f); FileListElement fullName = vector31.GetComponent <FileListElement>(); fullName.instance = this; fullName.data = files[k].FullName; fullName.size.text = this.GetFileSizeText(files[k].Length); fullName.elementName.text = files[k].Name; fullName.icon.sprite = this.fileIcon; fullName.isFile = true; } else if (files[k].Length < this.maxSize) { GameObject gameObject1 = UnityEngine.Object.Instantiate <GameObject>(this.filesScrollRectElement, Vector3.zero, Quaternion.identity); gameObject1.transform.SetParent(gameObject.transform, true); gameObject1.transform.localScale = new Vector3(1f, 1f, 1f); FileListElement fileSizeText = gameObject1.GetComponent <FileListElement>(); fileSizeText.instance = this; fileSizeText.data = files[k].FullName; fileSizeText.size.text = this.GetFileSizeText(files[k].Length); fileSizeText.elementName.text = files[k].Name; fileSizeText.icon.sprite = this.fileIcon; fileSizeText.isFile = true; } } } else { FileInfo[] array = ( from f in directoryInfo.GetFiles() where this.allowedExtensions.Contains <string>(f.Extension.ToLower()) select f).ToArray <FileInfo>(); for (int l = 0; l < (int)array.Length; l++) { if (this.maxSize <= (long)0) { GameObject vector32 = UnityEngine.Object.Instantiate <GameObject>(this.filesScrollRectElement, Vector3.zero, Quaternion.identity); vector32.transform.SetParent(gameObject.transform, true); vector32.transform.localScale = new Vector3(1f, 1f, 1f); FileListElement name = vector32.GetComponent <FileListElement>(); name.instance = this; name.data = array[l].FullName; name.size.text = this.GetFileSizeText(array[l].Length); name.elementName.text = array[l].Name; name.icon.sprite = this.fileIcon; name.isFile = true; } else if (array[l].Length < this.maxSize) { GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(this.filesScrollRectElement, Vector3.zero, Quaternion.identity); gameObject2.transform.SetParent(gameObject.transform, true); gameObject2.transform.localScale = new Vector3(1f, 1f, 1f); FileListElement fileListElement = gameObject2.GetComponent <FileListElement>(); fileListElement.instance = this; fileListElement.data = array[l].FullName; fileListElement.size.text = this.GetFileSizeText(array[l].Length); fileListElement.elementName.text = array[l].Name; fileListElement.icon.sprite = this.fileIcon; fileListElement.isFile = true; } } } } catch (Exception exception) { } }