59 lines
1.5 KiB
C#
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 Progress courseProgress;
|
|
|
|
/// <summary>
|
|
/// Reference to the list of courses 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.Get<CourseIndex>("courseIndex"));
|
|
|
|
thumbnail.sprite = course.thumbnail;
|
|
title.text = course.title;
|
|
progressBar.value = courseProgress.Get<float>("courseProgress");
|
|
button.onClick.AddListener(selectActivity);
|
|
}
|
|
}
|