I’ve created a number of UI element prefabs (Texts with a selected font, measurement, Radio button teams, and so on.) and I am making an attempt to learn a JSON file that has UI information that I might then wish to append to the canvas based mostly on the format required.
//sectionPreabs is a listing that comprises totally different UI parts I've made GameObject prefab = Instantiate(sectionPrefabs); //sectionContainer is a panel within the canvas prefab.rework.SetParent(sectionContainer.rework); //set the information to the prefab's textual content element prefab.GetComponent<TextMeshProUGUI>().textual content = part.text_content;
For instance, if the JSON says “sort: heading”, I might append a heading textual content prefab I’ve created. I’ve already written the script that appends these parts to my canvas. Nevertheless, when appending a number of prefabs under one another, the parts are instantiated in bizarre positions on the display. Is there a method to stack them in a listing?