28 lines
645 B
C#
28 lines
645 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class GridGroup : MonoBehaviour
|
|
{
|
|
[SerializeField] private int columns = 3;
|
|
[SerializeField] private float spacingX = 3f;
|
|
[SerializeField] private float spacingY = 3f;
|
|
|
|
void Start()
|
|
{
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
int row = i / columns;
|
|
int col = i % columns;
|
|
|
|
Transform child = transform.GetChild(i);
|
|
|
|
child.localPosition = new Vector3(
|
|
col * spacingX,
|
|
-row * spacingY,
|
|
0f
|
|
);
|
|
}
|
|
}
|
|
}
|