private void InitFile() { Util.DeleteChildren(parent); string path = ""; #if UNITY_EDITOR path = Application.streamingAssetsPath + "/Study"; #else path = Application.persistentDataPath + "/Study"; #endif path = Application.streamingAssetsPath + "/Study"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } DirectoryInfo direction = new DirectoryInfo(path); FileInfo[] files = direction.GetFiles(".", SearchOption.AllDirectories); index = 1; for (int i = 0; i < files.Length; i++) { if (files[i].Name.EndsWith(".txt") /* || files[i].Name.EndsWith(".pdf") || files[i].Name.EndsWith(".word")*/) { Debug.Log(files[i].Name); StudyInfo info = new StudyInfo(); info.name = files[i].Name; info.url = files[i].FullName; info.type = FileType.TXT; StudyItem item = Instantiate(itemPrefab); item.SetContent(info); item.transform.SetParent(parent, false); } } }