67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// Handles the display of themes in the ThemeSelectionController scene
|
|
/// </summary>
|
|
public class ThemeItem : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// Reference to the theme object
|
|
/// </summary>
|
|
public Theme theme;
|
|
|
|
/// <summary>
|
|
/// Reference to the minigame list
|
|
/// </summary>
|
|
public MinigameList minigameList;
|
|
|
|
/// <summary>
|
|
/// UI reference to the gameobject for displaying the theme title
|
|
/// </summary>
|
|
public TMP_Text title;
|
|
|
|
/// <summary>
|
|
/// UI reference to the gameobject for displaying the description
|
|
/// </summary>
|
|
public TMP_Text description;
|
|
|
|
/// <summary>
|
|
/// UI reference to the button so the correct callback can be trigger on click
|
|
/// </summary>
|
|
public Button button;
|
|
|
|
|
|
/// <summary>
|
|
/// Start is called before the first frame update
|
|
/// </summary>
|
|
void Start()
|
|
{
|
|
// Use public function so that this component can get Instantiated
|
|
GenerateContent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// (Re)generate the ThemeItem object and update its appearance
|
|
/// </summary>
|
|
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);
|
|
});
|
|
}
|
|
}
|