我是一名教育研究员,为我的博士课程开发游戏。我正在通过教程和论坛随时随地学习。
我有这个带有测验面板的场景(即 4 个按钮 - 1 个正确答案和 3 个错误答案)
无论单击了哪个错误按钮,我都想知道如何按顺序提供反馈提示。
这些是面板的一些图片和我目前拥有的代码。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PPLQuizManager : MonoBehaviour
{
public GameObject HNSCanvas;
[Header("PPL Left Panel")]
public GameObject PPLLeftPanel;
public RectTransform PPLParentLeftPanel;
public GameObject PPLTextBox;
public GameObject PPLContinue;
public GameObject PPLReturn;
//Pictures that illustrate the tutor's reaction
public List<Sprite> questionimages;
public List<Sprite> HintImages;
public List<Sprite> CorrectImages;
public GameObject PPLStringImages;
[Header("PPL Right Panel")]
public GameObject PPLRightPanel;
public GameObject PPLChoice1;
public GameObject PPLChoice2;
public GameObject PPLChoice3;
public GameObject PPLChoice4;
public int PPLChoiceMade;
[Header("PPL Bottom Panel")]
public GameObject PPLBottomPanel;
public GameObject PPLHint1TextBox;
public GameObject PPLHint2TextBox;
public GameObject PPLHint3TextBox;
public GameObject PPLWinTextBox;
public GameObject PPLHintPic;
public GameObject PPLBadge;
public GameObject PPLMedalPic;
[Header("PPL Center Panel")]
public GameObject PPLCenterPanel;
public GameObject PPLHintPic1;
public GameObject PPLHintPic2;
public GameObject PPLHintPic3;
public GameObject PPLWinPic;
public void PPLChoiceOption1()
{
PPLChoice1.GetComponent<Button>().interactable = false;
PPLTextBox.GetComponent<Text>().text = "Read the hint. Try again.";
showRandomHintImage();
PPLChoiceMade = 1;
}
public void PPLChoiceOption2()
{
PPLChoice2.GetComponent<Button>().interactable = false;
PPLTextBox.GetComponent<Text>().text = "Congratulations!";
showRandomCorrectImage();
PPLChoiceMade = 2;
}
public void PPLChoiceOption3()
{
PPLChoice3.GetComponent<Button>().interactable = false;
PPLTextBox.GetComponent<Text>().text = "Here's a hint!";
showRandomHintImage();
PPLChoiceMade = 3;
}
public void PPLChoiceOption4()
{
PPLChoice4.GetComponent<Button>().interactable = false;
PPLTextBox.GetComponent<Text>().text = "Hint time. Go for it!";
showRandomHintImage();
PPLChoiceMade = 4;
}
public void showRandomQuestionImage()
{
int count = questionimages.Count;
int index = Random.Range(0, count);
Image image1 = PPLStringImages.GetComponent<Image>();
image1.sprite = questionimages[index];
}
public void showRandomCorrectImage()
{
int count = CorrectImages.Count;
int index = Random.Range(0, count);
Image image2 = PPLStringImages.GetComponent<Image>();
image2.sprite = CorrectImages[index];
}
public void showRandomHintImage()
{
int count = HintImages.Count;
int index = Random.Range(0, count);
Image image3 = PPLStringImages.GetComponent<Image>();
image3.sprite = HintImages[index];
}
private void Start()
{
showRandomQuestionImage();
}
// Update is called once per frame
void Update()
{
//check the rest of this post
}
}
我所做的就是将每个提示分配给某个错误的答案按钮。但是这种方法对我的研究来说不会很有趣,特别是因为第三个提示实际上是一个答案赠品。因此,如果学生点击了我手动分配的第三个提示的错误答案,他们将在银盘上得到答案,而我的数据很糟糕。= (
请记住:无论学生单击哪个错误按钮,我都需要按顺序显示提示 1、2 和 3。
EXTRA REQUEST = ) : 有没有办法以更经济有效的方式管理这些面板游戏对象?
// Update is called once per frame
void Update()
{
//PPL buttons and answer management
if (PPLChoiceMade == 1)
{
PPLCenterPanel.SetActive(true);
PPLHintPic1.SetActive(true);
PPLHintPic2.SetActive(false);
PPLHintPic3.SetActive(false);
PPLHint1TextBox.SetActive(true);
PPLHint2TextBox.SetActive(false);
PPLHint3TextBox.SetActive(false);
}
if (PPLChoiceMade == 2)
{
PPLCenterPanel.SetActive(true);
PPLHintPic1.SetActive(false);
PPLHintPic2.SetActive(false);
PPLHintPic3.SetActive(false);
PPLWinPic.SetActive(true);
PPLChoice1.SetActive(false);
PPLChoice2.SetActive(true);
PPLChoice3.SetActive(false);
PPLChoice4.SetActive(false);
PPLContinue.SetActive(true);
PPLReturn.SetActive(false);
PPLWinTextBox.SetActive(true);
PPLHint1TextBox.SetActive(false);
PPLHint2TextBox.SetActive(false);
PPLHint3TextBox.SetActive(false);
PPLBadge.SetActive(true);
PPLMedalPic.SetActive(true);
}
if (PPLChoiceMade == 3)
{
PPLCenterPanel.SetActive(true);
PPLHintPic1.SetActive(false);
PPLHintPic2.SetActive(true);
PPLHintPic3.SetActive(false);
PPLHint1TextBox.SetActive(false);
PPLHint2TextBox.SetActive(true);
PPLHint3TextBox.SetActive(false);
}
if (PPLChoiceMade == 4)
{
PPLCenterPanel.SetActive(true);
PPLHintPic1.SetActive(false);
PPLHintPic2.SetActive(false);
PPLHintPic3.SetActive(true);
PPLHint1TextBox.SetActive(false);
PPLHint2TextBox.SetActive(false);
PPLHint3TextBox.SetActive(true);
}
任何帮助将不胜感激!(特别是因为我已经烧毁了大量的神经元试图自己弄清楚......哈哈!)