Table.cs
C# script
тест
using UnityEngine;
public class Table:MonoBehaviour
{
private Trasform entryContainer;
private Transform entryTemplate;
private void Awake(){
entryContainer = transform.Find("entryContainer");
entryTemplate = entryContainer.Find("entryTemplate");
entryTemplate.gameobject.SetActive(false);
float templateHeight = 20f;
for (int i = 0; i < 10; i++) {
Transform entryTransform = Instantiate(entryTemplate, entryContainer);
RectTransform entryRectTransform = entryTransform.GetComponent<RectTransform>();
entryRectTransform.anchoredPosition = new Vector2(0, -templateHeight * i);
entryTransform.gameObject.SetActive(true);
int rank = i + 1;
string rankString;
switch (rank) {
default:
rankString = rank + "TH"; break;
case 1: rankString = "1ST"; break;
case 2: rankString = "2NF"; break;
case 3: rankString = "3RD"; break;
}
entryTransform.Find("Col1").GetComponent<Text>().text = rankString;
int score = Random.Range(0,10000);
entryTransform.Find("Col2").GetComponent<Text>().text = score.ToString();
string name = "AAA";
entryTransform.Find("Col3").GetComponent<Text>().text = name;
}
}