Files
QuizzinMk5.1/Assets/Quiz/Scripts/UC/UCController.cs
2025-12-07 23:15:32 +00:00

59 lines
1.7 KiB
C#

using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class UCController : UdonSharpBehaviour
{
public UCQuestion[] questions;
public GameObject questionList;
public GameObject questionListItemPrefab;
public TMPro.TextMeshProUGUI mainQuestionText;
public TMPro.TextMeshProUGUI bonusQuestionInfoText;
public TMPro.TextMeshProUGUI bonusQuestion1Text;
public TMPro.TextMeshProUGUI bonusQuestion2Text;
public TMPro.TextMeshProUGUI bonusQuestion3Text;
public void Start()
{
for (int i = 0; i < questions.Length; i++)
{
UCQuestion question = questions[i];
GameObject listItemObj = Instantiate(questionListItemPrefab, questionList.transform);
UCQuestionListItem listItem = listItemObj.GetComponent<UCQuestionListItem>();
if (listItem != null)
{
listItem.Initialize(question, i);
listItem.controller = this;
}
}
}
public void ChangeQuestionPanel(UCQuestion question)
{
if (mainQuestionText != null)
{
mainQuestionText.text = question.mainQuestion;
}
if (bonusQuestionInfoText != null)
{
bonusQuestionInfoText.text = question.bonusQuestionInfo;
}
if (bonusQuestion1Text != null)
{
bonusQuestion1Text.text = question.bonusQuestion1;
}
if (bonusQuestion2Text != null)
{
bonusQuestion2Text.text = question.bonusQuestion2;
}
if (bonusQuestion3Text != null)
{
bonusQuestion3Text.text = question.bonusQuestion3;
}
}
}