Answer the question
In order to leave comments, you need to log in
How to create copies of an object under the desired object? Unity?
How to create copies of an object under the desired object? Unity?
I have a code and an object of type Text UI
Here is the code where you need to create:
foreach (var lesson in lessons)
{
_teachersText.text = $"{lesson.Teacher} д{lesson.Day} у{lesson.LessonNumber} каб.{lesson.ClassRoom}";
}
Answer the question
In order to leave comments, you need to log in
If you need a simple list, you can use the simple VerticalLayout UI component. You can already add text elements to it by instance, it will align all the elements in height and width. More or less like this:
public RectTransform layoutRoot;
public GameObject textPrefab;
foreach (var lesson in lessons)
{
var go = Instance(textPrefab);
var text = go.GetComponent<Text>();
text.text = $"{lesson.Teacher} д{lesson.Day} у{lesson.LessonNumber} каб.{lesson.ClassRoom}";
go.transform.SetParent(layoutRoot);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question