using SK.Framework; using System.Collections; using System.Collections.Generic; using UnityEngine; public class QuestionExample : MonoBehaviour { public QuestionsProfile questionsProfile; public QuestionsHandler questionsHandler; private QuestionBase currectQuestion; // Start is called before the first frame update void Start() { questionsHandler = new QuestionsHandler(questionsProfile); //获取选择内容 currectQuestion = questionsHandler.Switch(1); //获取问题 Debug.Log(currectQuestion.Question); GetQuestion(); List mySingles = questionsProfile.SingleChoices; } /// /// 具体操作 /// void GetQuestion() { //第一种获取方式,通过题型和题号获取指定题目 ///获取当前题号 int id = questionsHandler.GetCurrentSequence(); ///获取当前题型 QuestionType questionType = currectQuestion.Type; switch (questionType) { case QuestionType.SINGLE_CHOICE: //单选 //获取选项内容 Debug.Log(questionsHandler.Get(id).Choices[1].text); //传入当前选项判定对错 Debug.Log(questionsHandler.Get(id).IsCorrect(0)); break; } //第二种获取方式。通过整个list获取,自行管理 List mySingles = questionsProfile.SingleChoices; SingleChoiceQuestion single = mySingles[0]; //获取问题,同理获取题解,选项,是否正确 string que = single.Question; int index= single.Answer; bool isRight = single.IsCorrect(0); } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.A)) { currectQuestion = questionsHandler.Last(); Debug.Log(currectQuestion.Question); } if (Input.GetKeyDown(KeyCode.D)) { currectQuestion = questionsHandler.Next(); Debug.Log(currectQuestion.Question); } if (Input.GetKeyDown(KeyCode.S)) { currectQuestion = questionsHandler.Switch(5); Debug.Log(currectQuestion.Question); } } }