Resolve WES-49 "Courses list"
This commit is contained in:
43
Assets/Common/Scripts/ListScreenManager.cs
Normal file
43
Assets/Common/Scripts/ListScreenManager.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class ListScreenManager : MonoBehaviour
|
||||
{
|
||||
[Header("List Screen Components")]
|
||||
public Transform item_container;
|
||||
|
||||
[Header("Prefabs")]
|
||||
public GameObject item_prefab;
|
||||
|
||||
// TODO: change to ScriptableObject;
|
||||
[Header("ScriptableObjects")]
|
||||
public int numberOfItems;
|
||||
public string[] itemTitle;
|
||||
public float[] itemProgress;
|
||||
public Sprite[] itemThumbnail;
|
||||
public string[] itemScene;
|
||||
|
||||
void Start()
|
||||
{
|
||||
for (int i = 0; i < numberOfItems; i++)
|
||||
{
|
||||
// Create instance of prefab
|
||||
GameObject instance = GameObject.Instantiate(item_prefab, item_container);
|
||||
|
||||
// Dynamically load appearance
|
||||
CourseItem item = instance.GetComponent<CourseItem>();
|
||||
item.courseTitle = itemTitle[i];
|
||||
item.courseThumbnail = itemThumbnail[i];
|
||||
item.courseProgress = itemProgress[i];
|
||||
item.courseScene = itemScene[i];
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadScene(string sceneName)
|
||||
{
|
||||
SceneManager.LoadScene(sceneName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user