Files
unity-application/Assets/SpellingBee/Scripts/ThemeItem.cs
2023-03-06 12:14:25 +00:00

45 lines
1.1 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ThemeItem : MonoBehaviour
{
// TODO: change to ScriptableObject Theme;
[Header("ScriptableObject Theme")]
public string themeTitle;
public string themeDescription;
public UnityAction startGameCallback;
[Header("UI references")]
// Reference to thumbnail object
public TMP_Text title;
// Reference to description object
public TMP_Text description;
// Refetence to object so correct callback can be trigger on click
public Button button;
void Start()
{
// Use public function so that this component can get Instantiated
GenerateContent();
}
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);
}
}