c#GUI使用for循环创建多个button,如何知道点击的button的id,如何使得每次点击button后都切换成另一张图
publicTexture2DBlack;publicTexture2DWhite;voidOnGUI(){intwidth=30;intheight=30;intx=0...
public Texture2D Black;
public Texture2D White;
void OnGUI() {
int width = 30;
int height = 30;
int x = 0,i = 0;
int y = 0;
//bool panDuan = false;
for (y = 0; y <= (height * 6); y += height,i++)
{
for (x = 0; x <= (width * 11); x += width * 2)
{
if (i % 2 == 0)
{
GUI.Button(new Rect(x, y, height, width), Black);
GUI.Button(new Rect(x + width, y, height, width), White);
}
else {
GUI.Button(new Rect(x, y, height, width), White);
GUI.Button(new Rect(x + width, y, height, width), Black);
}
}
} 展开
public Texture2D White;
void OnGUI() {
int width = 30;
int height = 30;
int x = 0,i = 0;
int y = 0;
//bool panDuan = false;
for (y = 0; y <= (height * 6); y += height,i++)
{
for (x = 0; x <= (width * 11); x += width * 2)
{
if (i % 2 == 0)
{
GUI.Button(new Rect(x, y, height, width), Black);
GUI.Button(new Rect(x + width, y, height, width), White);
}
else {
GUI.Button(new Rect(x, y, height, width), White);
GUI.Button(new Rect(x + width, y, height, width), Black);
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询