using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
///
/// Handles the display of minigames in the ListMinigameScreen scene
///
public class MinigameItem : MonoBehaviour
{
///
/// Reference to the minigame object
///
public Minigame minigame;
///
/// UI Reference to the image for displaying the minigame thumbnail
///
public Image thumbnail;
///
/// UI Reference to the gameobject for displaying the minigame title
///
public TMP_Text title;
///
/// UI Reference to the button so the correct callback can be trigger on click
///
public Button button;
///
/// Start is called before the first frame update
///
void Start()
{
// Use public function so that this component can get Instantiated
GenerateContent();
}
///
/// (Re)generate the MinigameItem object and update its appearance
///
public void GenerateContent()
{
// Set appearance
thumbnail.sprite = minigame.thumbnail;
title.text = minigame.title;
// Add click functionality
button.onClick.AddListener(() => SceneManager.LoadScene("Common/Scenes/InfoMinigame"));
}
}