Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
public class TaskPanel : MonoBehaviour { [SerializeField] private GameObject taskPrefab; [SerializeField] private float indent; [SerializeField] private float spawnPos; [SerializeField] private GameObject tasksPanel; public List<TaskInfo> tasks; private byte _countCompleteTasks = 0; private void Start() { RectTransform panel = tasksPanel.GetComponent<RectTransform>(); panel.sizeDelta = new Vector2(0, indent * tasks.Count); for (int i = 0; i < tasks.Count; i++) { var task = Instantiate(taskPrefab,transform.position, Quaternion.identity,tasksPanel.transform); task.transform.localPosition = new Vector3(0,spawnPos,0); spawnPos -= indent; var taskComponent = task.GetComponent<Task>(); taskComponent.taskName = tasks[i].taskName; } }
[SerializeField] private GameObject taskPrefab; [SerializeField] private float indent; [SerializeField] private float spawnPos; [SerializeField] private GameObject tasksPanel; public List<TaskInfo> tasks; private byte _countCompleteTasks = 0; private void Start() { RectTransform panel = tasksPanel.GetComponent<RectTransform>(); panel.sizeDelta = new Vector2(0, indent * tasks.Count); for (int i = 0; i < tasks.Count; i++) { var task = Instantiate(taskPrefab,transform.position, Quaternion.identity,tasksPanel.transform); task.transform.localPosition = new Vector3(0,spawnPos,0); spawnPos -= indent; var taskComponent = task.GetComponent<Task>(); taskComponent.taskName = tasks[i].taskName; } } }
GameObject.Instantiate