first commit
This commit is contained in:
27
Assets/Scripts/GridGroup.cs
Normal file
27
Assets/Scripts/GridGroup.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user