using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
///
/// Handles the display of themes in the ThemeSelectionController scene
///
public class ThemeItem : MonoBehaviour
{
///
/// Reference to the theme object
///
public Theme theme;
///
/// Reference to the minigame list
///
public MinigameList minigameList;
///
/// UI reference to the gameobject for displaying the theme title
///
public TMP_Text title;
///
/// UI reference to the gameobject for displaying the description
///
public TMP_Text description;
///
/// 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 ThemeItem object and update its appearance
///
public void GenerateContent()
{
// Set appearance
title.text = theme.title;
// TODO: make description only visible when hovering
description.text = theme.description;
// Add click functionality
button.onClick.AddListener(() =>
{
//PlayerPrefs.SetString("gamePath", minigame.minigameEntryPoint);
Minigame minigame = minigameList.minigames[minigameList.currentMinigameIndex];
minigame.themeList.SetCurrentTheme(theme.themeIndex);
SystemController.GetInstance().SwapScene(minigame.minigameEntryPoint);
});
}
}