Resolve WES-43 "Minigame framework"
This commit is contained in:
44
Assets/SpellingBee/Scripts/ThemeItem.cs
Normal file
44
Assets/SpellingBee/Scripts/ThemeItem.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user