从资源文件夹iOS Unity中的文件夹中创建按钮



我试图弄清楚如何将所有文件夹作为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上的按钮创建它们?

代码仅在编辑器中起作用。因此,我创建了一个工作。我在资源文件夹中创建了一个空的游戏对象。因此,我没有使用文件夹获取按钮,而是使用GameObject来创建按钮。

我以与我的问题相同的方式使用了代码,但是这次它在编辑器之外工作

最新更新