<pre name="code" class="csharp">using UnityEngine;
using System.Collections;
public class loops : MonoBehaviour {
//设定要复制的物体
public GameObject obj;
// Use this for initialization
void Start () {
//被复制物体的位置坐标
Vector3 pos;
pos.x = 0;
pos.y = 0;
pos.z = 0;
int x;
int z;
int y;
x = 1;
while (x<=5){
z =1;
pos.z = 0;
while (z<=5){
y=1;
pos.y = 0;
while(y<=5){
Instantiate(obj, pos, GameObject.Find("Star").transform.rotation);
pos.y++;
y++;
}
// Instantiate(obj, pos, GameObject.Find("Star").transform.rotation);
pos.z++;
z++;
}
// Instantiate(obj, pos, GameObject.Find("Star").transform.rotation);
pos.x ++;
x++;
}
}
// Update is called once per frame
void Update () {
}
}
while循环。。。
最新推荐文章于 2023-05-26 12:58:45 发布