2024-07-03 05:06:29
描述不够清楚啊,是克隆一个矩阵出来还是克隆物体组成矩阵?
public class Zhongd : MonoBehaviour {
public GameObject prefab;// 你所需要克隆的物体
private Vector3 aa=Vector3.zero;//第一个的位置(此处默认为0点)
void Start () {
ClonePrefabs(prefab, aa);
}
private void ClonePrefabs(GameObject obj,Vector3 vect)
{
for (int i = 0; i < 16; i++)
{
Vector3 tes;
//确定每一行的个数(改变i的范围可以改变列数)
tes.x = vect.x + 1 * (i%4);
tes.z = vect.z + 1 * (i/4);
tes.y = vect.y;
GameObject go = Instantiate(obj,transform);
go.transform.position = tes;
go.name = string.Format("emy[{0}]", i);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Zhongdian : MonoBehaviour {
public GameObject prefab;// 你所需要克隆的物体
private Vector3 aa=Vector3.zero;//第一个的位置(此处默认为0点)
void Start () {
ClonePrefabs(prefab, aa);
}
private void ClonePrefabs(GameObject obj,Vector3 vect)
{
for (int i = 0; i < 16; i++)
{
Vector3 tes;
//确定每一行的个数(改变i的范围可以改变列数)
tes.x = vect.x + 1 * (i%4);
tes.z = vect.z + 1 * (i/4);
tes.y = vect.y;
GameObject go = Instantiate(obj,transform);
go.transform.position = tes;
go.name = string.Format("emy[{0}]", i);
}
}
}