【发布时间】:2015-05-09 20:50:59
【问题描述】:
我有一个 UI 图像,我希望它在单击 UI 按钮时显示不同的图像。我知道如何遍历 UI 文本,但不知道 UI 图像。以下是我可以对文本执行的操作:
Text text;
string[] array = {"Hi!", "Ho!", "You clicked me!"};
int num = 0;
void Start() {
text = GetComponent<Text> ();
}
void Change() {
num++;
if(num == 3) {
num = 0;
}
text.text = array[num];
}
我怎样才能对图像做同样的事情?
【问题讨论】:
-
请为您的问题找到一个更好的标题!
-
@AndreasNiedermair 那怎么样?
-
好得多!但是:请参阅"Should questions include “tags” in their titles?",其中的共识是“不,他们不应该”!
-
@AndreasNiedermair 哦!我从来不知道。谢谢。
标签: c# arrays image user-interface unity3d