Resolve WES-76 "87 themeselection"
This commit is contained in:
65
Assets/Common/Scripts/ThemeItem.cs
Normal file
65
Assets/Common/Scripts/ThemeItem.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
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>
|
||||
/// The theme title
|
||||
/// </summary>
|
||||
public string themeTitle;
|
||||
|
||||
/// <summary>
|
||||
/// A short description of the theme
|
||||
/// </summary>
|
||||
public string themeDescription;
|
||||
|
||||
/// <summary>
|
||||
/// The callback function to start the game with the correct theme loaded
|
||||
/// </summary>
|
||||
public UnityAction startGameCallback;
|
||||
|
||||
/// <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 = themeTitle;
|
||||
|
||||
// TODO: make description only visible when hovering
|
||||
description.text = themeDescription;
|
||||
|
||||
// Add click functionality
|
||||
button.onClick.AddListener(startGameCallback);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user