// Use this for initialization
void Start () {
for (int i = 0; i < 10; i++)//十行
{
for (int j = 0; j < 10; j++)
{
if (i % 2 == 0)
{
if (j % 2 == 0)
{
GameObject go = GameObject.Instantiate(Resources.Load(“P”), transform, false);
go.transform.position = new Vector3(i5,0,j5 );
}
else
{
GameObject go = GameObject.Instantiate(Resources.Load(“H”), transform, false);
go.transform.position = new Vector3(i * 5, 0, j * 5);
}
}
else
{
if (j % 2 == 1)
{
GameObject go = GameObject.Instantiate(Resources.Load(“P”), transform, false);
go.transform.position = new Vector3(i * 5, 0, j * 5);
}
else
{
GameObject go = GameObject.Instantiate(Resources.Load(“H”), transform, false);
go.transform.position = new Vector3(i * 5, 0, j * 5);
}
}
}在这里插入代码片
生成黑白相间的国际象棋棋盘
最新推荐文章于 2023-07-10 19:06:32 发布