您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
26 行
501 B
26 行
501 B
using UnityEngine;
|
|
|
|
public class GridSpawner : MonoBehaviour
|
|
{
|
|
public GameObject spawnedObject;
|
|
public float xStep = 3f;
|
|
public float yStep = 8f;
|
|
public int columns = 3;
|
|
public int rows = 3;
|
|
|
|
private void Start()
|
|
{
|
|
if (spawnedObject == null)
|
|
return;
|
|
|
|
for (int x = 0; x < columns; x++)
|
|
{
|
|
for (int y = 0; y < rows; y++)
|
|
{
|
|
var t = transform;
|
|
var pos = t.position + new Vector3(xStep * x, 0f, yStep * -y);
|
|
Instantiate(spawnedObject, pos, t.rotation, t);
|
|
}
|
|
}
|
|
}
|
|
}
|