using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; using UnityEngine.UI; public class ReplayList : MonoBehaviour { public GameObject replayItem; private Dictionary historyFiles = new Dictionary(); private int num = 1; // Use this for initialization void Start () { var directory = Application.dataPath + "/" + "HistoryData"; if (Directory.Exists(directory)) { DirectoryInfo dir = new DirectoryInfo(directory); FileInfo[] files = dir.GetFiles("*.replay", SearchOption.TopDirectoryOnly); foreach (FileInfo file in files) { historyFiles.Add(file.Name,file.FullName); } } foreach (var item in historyFiles) { GameObject rpItem = Instantiate(replayItem,gameObject.transform) as GameObject; rpItem.name = "ReplayItem"; rpItem.transform.Find("Text_ID").GetComponent().text = (num++).ToString(); rpItem.transform.Find("Text_File").GetComponent().text = item.Key; rpItem.transform.Find("Button").GetComponent().fileFullPath = directory + "/" + item.Key; } } // Update is called once per frame void Update () { } }