选择要在Unity中加载哪个保存文件?

所以,我已经设法将程序设置为以任何文件名保存,并且我已经可以轻松地在foreach循环中选择它们了。 从那里,我如何使用这些保存文件填充Unity中的滚动视图列表? 比如,像这样:

在此处输入图像描述

每个保存文件在Scroll View中占用一行,可以选择一个,你可以点击’加载游戏’,它会加载。

这是一个简短的教程如何执行此操作:

DynamicScrollView.cs

using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.UI; using UnityEngine.Events; public class DynamicScrollView : MonoBehaviour { public GameObject Prefab; public Transform Container; public List files = new List(); void Start() { // files = // LOAD FILE NAMES HERE. for (int i = 0; i < files.Count; i++) { GameObject go = Instantiate(Prefab); go.GetComponentInChildren().text = files[i]; go.transform.SetParent(Container); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; int buttonIndex = i; go.GetComponent 

你可以有一个文件,其中包含有关所有文件的一些信息…例如,您的主文件可能包含 – 多少 – 名称 – 有关保存创建日期的一些数据?

然后加载该文件并从那里获取所有信息,并打开它并在进行新保存时添加相同的信息