37 lines
956 B
C#
37 lines
956 B
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class CourseListManager : MonoBehaviour
|
|
{
|
|
[Header("Course list UI components")]
|
|
// Reference to course-list holder object
|
|
public Transform courseContainer;
|
|
|
|
[Header("Prefabs")]
|
|
// Prefab of item
|
|
public GameObject courseItemPrefab;
|
|
|
|
[Header("Courses")]
|
|
// Reference to the list of all courses
|
|
public CourseList courseList;
|
|
|
|
void Start()
|
|
{
|
|
foreach (Course course in courseList.courses)
|
|
{
|
|
// Create instance of prefab
|
|
GameObject instance = GameObject.Instantiate(courseItemPrefab, courseContainer);
|
|
|
|
// Dynamically load appearance
|
|
CourseItem item = instance.GetComponent<CourseItem>();
|
|
item.course = course;
|
|
}
|
|
}
|
|
|
|
// Method used as callback for on click events
|
|
public void LoadScene(string sceneName)
|
|
{
|
|
SceneManager.LoadScene(sceneName);
|
|
}
|
|
}
|