Files
unity-application/Assets/Accounts/Scripts/CourseProgressCard.cs
2023-05-04 09:09:49 +00:00

59 lines
1.5 KiB
C#

using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
/// <summary>
/// Class to handle course progress card display
/// </summary>
public class CourseProgressCard : MonoBehaviour
{
/// <summary>
/// Callback to the UpdateSelection
/// </summary>
public UnityAction selectActivity;
/// <summary>
/// Button to place to callback on
/// </summary>
public Button button;
/// <summary>
/// Reference to the progress so we can display a progress bar
/// </summary>
public PersistentDataController.SavedCourseProgress courseProgress;
/// <summary>
/// Reference to the list of minigameCards so we can query the correct course
/// </summary>
public CourseList courseList;
/// <summary>
/// UI reference to the thumbnail of the course
/// </summary>
public Image thumbnail;
/// <summary>
/// UI refeerence to the title of the course
/// </summary>
public TMP_Text title;
/// <summary>
/// Reference to the progress bar for the course
/// </summary>
public Slider progressBar;
/// <summary>
/// Start is called before the first frame update
/// </summary>
void Start()
{
Course course = courseList.GetCourseByIndex(courseProgress.courseIndex);
thumbnail.sprite = course.thumbnail;
title.text = course.title;
progressBar.value = courseProgress.progress;
button.onClick.AddListener(selectActivity);
}
}