You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.3 KiB
42 lines
1.3 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using System.IO; |
|
using UnityEngine.UI; |
|
|
|
public class ReplayList : MonoBehaviour { |
|
|
|
public GameObject replayItem; |
|
private Dictionary<string,string> historyFiles = new Dictionary<string, string>(); |
|
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>().text = (num++).ToString(); |
|
rpItem.transform.Find("Text_File").GetComponent<Text>().text = item.Key; |
|
|
|
rpItem.transform.Find("Button").GetComponent<ReplayButton>().fileFullPath = directory + "/" + item.Key; |
|
} |
|
} |
|
|
|
// Update is called once per frame |
|
void Update () { |
|
|
|
} |
|
}
|
|
|