问题描述
我正在尝试创建一个文本框,其中一个名为“ Dugo”的字符会告诉播放器某些内容,但是它不起作用。该脚本应该根据int值更改文本的内容。所有按钮和文本均已正确连接到脚本,我将其更改为double,但仍然无法正常工作。有人可以帮忙吗?
代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DugoText1 : MonoBehavIoUr
{
public double text = 0;
public GameObject DugoBox;
public GameObject DugoText;
public void ClickTheButton()
{
text += 1;
}
void Update()
{
if (text == 1) {
DugoText.GetComponent<Text>().text = "text1";
}
if (text == 2)
{
DugoText.GetComponent<Text>().text = "text2";
}
if (text == 3)
{
DugoText.GetComponent<Text>().text = "text3";
}
if (text == 4)
{
DugoText.GetComponent<Text>().text = "text4";
}
if (text == 5)
{
DugoText.GetComponent<Text>().text = "text5";
}
if (text == 6)
{
DugoText.GetComponent<Text>().text = "text6";
}
}
}