47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon;
|
|
|
|
public class UCQuestionListItem : UdonSharpBehaviour
|
|
{
|
|
public UCController controller;
|
|
public UCQuestion questionData;
|
|
public UnityEngine.UI.Image backgroundImage;
|
|
|
|
public TMPro.TextMeshProUGUI textComponent;
|
|
|
|
public void Initialize(UCQuestion question, int index)
|
|
{
|
|
questionData = question;
|
|
|
|
if (backgroundImage == null)
|
|
{
|
|
backgroundImage = GetComponent<UnityEngine.UI.Image>();
|
|
}
|
|
|
|
if (textComponent == null)
|
|
{
|
|
textComponent = GetComponentInChildren<TMPro.TextMeshProUGUI>();
|
|
}
|
|
|
|
if (textComponent != null && questionData != null)
|
|
{
|
|
textComponent.text = index.ToString() + ". " + questionData.mainQuestion;
|
|
}
|
|
}
|
|
|
|
public void OnItemClicked()
|
|
{
|
|
if (controller != null && questionData != null)
|
|
{
|
|
controller.ChangeQuestionPanel(questionData);
|
|
if (backgroundImage != null)
|
|
{
|
|
backgroundImage.color = Color.gray; // Example of changing background color on click
|
|
}
|
|
}
|
|
}
|
|
}
|