using LitJson; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ListInformation : MonoBehaviour { public List contents; [SerializeField] GameObject prefab; //预制体 [SerializeField] GameObject parent; //父物体(content) // Start is called before the first frame update void Start() { TextAsset jsonFile = Resources.Load("testfile"); string jsonString = jsonFile.text; Root data = JsonMapper.ToObject(jsonString); GameObject item = Instantiate(prefab, parent.transform); contents.Add(item); contents[0].transform.GetChild(0).GetChild(0).GetComponent().text = data.Name; } }