47 lines
1.1 KiB
C#
47 lines
1.1 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)
|
|
{
|
|
questionData = question;
|
|
|
|
if (backgroundImage == null)
|
|
{
|
|
backgroundImage = GetComponent<UnityEngine.UI.Image>();
|
|
}
|
|
|
|
if (textComponent == null)
|
|
{
|
|
textComponent = GetComponentInChildren<TMPro.TextMeshProUGUI>();
|
|
}
|
|
|
|
if (textComponent != null && questionData != null)
|
|
{
|
|
textComponent.text = 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
|
|
}
|
|
}
|
|
}
|
|
}
|