Unity生成矩形点位

public class Tools
{
    public static List<Vector3> CreatePoint(float height, float width, float spacing)
    {
        List<Vector3> _positionList = new List<Vector3>();
        for (float z = ((float)height - 1) / 2; z >= -((float)height - 1) / 2; z--)
        {
            for (float x = -((float)width - 1) / 2; x <= ((float)width - 1) / 2; x++)
            {
                _positionList.Add(new Vector3(x * spacing, 0, z * spacing));
            }
        }
        return _positionList;
    }
}

 

posted @ 2022-03-04 16:21  法小鱿  阅读(177)  评论(0编辑  收藏  举报