gizmo 생성해서 뿌리는 코드.
using System.Collections;
using UnityEngine;
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class GridTest : MonoBehaviour
{
public int xSize, ySize;
private Vector3[] vertices;
private void Awake() {
StartCoroutine(Generated());
}
IEnumerator Generated() {
yield return new WaitForSeconds(0.5f);
vertices = new Vector3[(xSize + 1) * (ySize + 1)];
for(int i=0, y=0; y <= ySize; y++) {
for(int x =0; x<=xSize; x++, i++) {
vertices[i] = new Vector3(x, y);
yield return new WaitForSeconds(0.1f);
}
}
yield return null;
}
private void OnDrawGizmos() {
if (vertices == null) {
return;
}
Gizmos.color = Color.black;
for(int i=0; i < vertices.Length; i++) {
Gizmos.DrawSphere(vertices[i], 0.1f);
}
}
}
반응형