【发布时间】:2019-02-12 15:20:21
【问题描述】:
我试图弄清楚如何将资源文件夹中的所有文件夹作为 iOS 中的按钮。 我用这段代码让它在 Windows 上工作:
string path = Application.dataPath + "/Resources/Prefabs/Models/";
foreach (string s in Directory.GetDirectories(path))
{
projects.Add(s.Remove(0, path.Length));
}
foreach (string result in projects)
{
buttonResult = Instantiate(buttonProjectPrefab).GetComponent<Button>();
buttonResult.transform.SetParent(GameObject.FindGameObjectWithTag("Level").transform);
buttonResult.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);
buttonResult.GetComponent<Button>().onClick.AddListener(delegate { CreateModelButtons(); });
buttonResult.name = result;
buttonResult.GetComponentInChildren<Text>().text = result;
}
所以现在我想弄清楚如何为 iOS 做到这一点。 我知道 Unity 对文件进行了编码,所以我使用的将是不可能的。
我应该怎么做才能让资源文件夹中的所有文件夹在 iOS 上创建为按钮?
【问题讨论】: