11月1号
例1:用代码的方式形成一堵6*6的墙(立方体组成)
效果展示:
代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class createwall : MonoBehaviour
{
void Start()
{
GameObject mom = GameObject.CreatePrimitive(PrimitiveType.Cube);//母体
for (int i=0;i<=5 ;i++ ) {
for (int j = 0; j<=5; j++)
{
GameObject.Instantiate(mom, new Vector3(i, j, 0), Quaternion.identity);//对应位置复制
}
}
}
}
解释:
GameObject:Unity 的 GameObject 类用于表示任何可以存在于场景中的事物。GameO