Integrate minigame and courses
This commit is contained in:
39
Assets/Common/Scripts/CourseListManager.cs
Normal file
39
Assets/Common/Scripts/CourseListManager.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user