2026-04-24 16:57:44 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Kill.Managers;
|
|
|
|
|
using Kill.UI.Components;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class SafetylearningAnswer : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Text correctAnswerText;
|
|
|
|
|
public GameObject answerPrefab;
|
|
|
|
|
public VideoCtrl video;
|
2026-06-10 15:04:14 +08:00
|
|
|
public void Init(QuestionInfo questionInfo)
|
2026-04-24 16:57:44 +08:00
|
|
|
{
|
|
|
|
|
bool isChinese = LanguageManager.Instance.languageType == LanguageManager.LanguageType.Chinese;
|
|
|
|
|
answerPrefab.SetActive(false);
|
|
|
|
|
string correctAnswer="";
|
2026-06-10 15:04:14 +08:00
|
|
|
var options=questionInfo.options;
|
|
|
|
|
string videoUrl=isChinese?questionInfo.videoUrl:questionInfo.videoUrlEn;
|
2026-04-24 16:57:44 +08:00
|
|
|
|
|
|
|
|
for(int i = 0; i <options.Count; i++) {
|
|
|
|
|
string explanation=isChinese?options[i].explanation:options[i].explanationEn;
|
|
|
|
|
if(options[i].isCorrect==true)
|
|
|
|
|
{
|
|
|
|
|
if(correctAnswer!="")
|
|
|
|
|
correctAnswer+=" ";
|
|
|
|
|
correctAnswer+=options[i].optionLabel;
|
|
|
|
|
}
|
|
|
|
|
if(!string.IsNullOrEmpty(explanation))
|
|
|
|
|
{
|
|
|
|
|
var a=Instantiate(answerPrefab,answerPrefab.transform.parent);
|
2026-06-10 15:04:14 +08:00
|
|
|
a.GetComponent<Text>().text=$"{explanation}";
|
2026-04-24 16:57:44 +08:00
|
|
|
a.SetActive(true);
|
|
|
|
|
a.transform.SetAsLastSibling();
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-18 08:42:33 +08:00
|
|
|
correctAnswerText.text=LanguageManager.Instance.GetLanguage("100055").Replace("{0}",correctAnswer);
|
|
|
|
|
Debug.Log(correctAnswer);
|
2026-04-24 16:57:44 +08:00
|
|
|
if(videoUrl!="")
|
|
|
|
|
{
|
|
|
|
|
video.gameObject.SetActive(true);
|
|
|
|
|
video.transform.SetAsLastSibling();
|
|
|
|
|
video.SetVideo(videoUrl);
|
2026-05-18 08:42:33 +08:00
|
|
|
video.gameObject.transform.parent.SetAsLastSibling();
|
2026-04-24 16:57:44 +08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
video.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-18 08:42:33 +08:00
|
|
|
|
2026-04-24 16:57:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LateSetCorrectAnswerText(string correctAnswer)
|
|
|
|
|
{
|
|
|
|
|
correctAnswerText.text.Replace("{0}",correctAnswer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|