using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
public class TestCreateText : MonoBehaviour {
public GameObject prefabText;
public string loadPath;
public int i;
// Use this for initialization
void Start () {
DirectoryInfo folder = new DirectoryInfo(loadPath);
foreach (FileInfo file in folder.GetFiles())
{
GameObject te = Instantiate(prefabText);
i += 1;
te.name = file.Name;
te.transform.parent = this.gameObject.transform;
te.transform.localScale = new Vector3(1, 1, 1);
te.GetComponent<Text>().text = file.Name;
}
gameObject.GetComponent<RectTransform>().offsetMin = new Vector2(GetComponent<RectTransform>().offsetMin.x, -i * 30 + 180);
}
}
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
public class TestCreateText : MonoBehaviour {
public GameObject prefabText;
public string loadPath;
public int i;
// Use this for initialization
void Start () {
DirectoryInfo folder = new DirectoryInfo(loadPath);
foreach (FileInfo file in folder.GetFiles())
{
GameObject te = Instantiate(prefabText);
i += 1;
te.name = file.Name;
te.transform.parent = this.gameObject.transform;
te.transform.localScale = new Vector3(1, 1, 1);
te.GetComponent<Text>().text = file.Name;
}
gameObject.GetComponent<RectTransform>().offsetMin = new Vector2(GetComponent<RectTransform>().offsetMin.x, -i * 30 + 180);
}
}