28 lines
634 B
C#
28 lines
634 B
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
[ExecuteInEditMode]
|
||
|
|
public class ResetPosition : MonoBehaviour
|
||
|
|
{
|
||
|
|
public float m_x, m_z;
|
||
|
|
public int m_col;
|
||
|
|
|
||
|
|
private void OnEnable()
|
||
|
|
{
|
||
|
|
int i = 0, row = 0, col = 0;
|
||
|
|
while (i < transform.childCount)
|
||
|
|
{
|
||
|
|
var child = transform.GetChild(i++);
|
||
|
|
float x = row++ * m_x;
|
||
|
|
float z = col * m_z;
|
||
|
|
child.localPosition = new Vector3(x, child.localPosition.y, z);
|
||
|
|
|
||
|
|
if (row == m_col)
|
||
|
|
{
|
||
|
|
row = 0;
|
||
|
|
++col;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|