37 lines
930 B
C#
37 lines
930 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class MinigameItem : MonoBehaviour
|
|
{
|
|
// TODO: change to ScriptableObject Minigame;
|
|
[Header("ScriptableObject Course")]
|
|
public Minigame minigame;
|
|
|
|
[Header("UI references")]
|
|
// Reference to thumbnail object
|
|
public Image thumbnail;
|
|
// Reference to title object
|
|
public TMP_Text title;
|
|
// 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
|
|
thumbnail.sprite = minigame.thumbnail;
|
|
title.text = minigame.title;
|
|
|
|
// Add click functionality
|
|
button.onClick.AddListener(() => SceneManager.LoadScene(minigame.minigameEntryPoint));
|
|
}
|
|
}
|