using UnityEngine;

using System.Collections;


public class TestGrid : MonoBehaviour {

public int Cellwidth = 2;

[ContextMenu("Arrange")]

public void Arrage(){

for(int i = 1; i < transform.childCount; i++){

GameObject child = transform.GetChild(i).gameObject;

child.transform.position += new Vector3(Cellwidth * i, 0, 0);

}

}

}


선생님꺼.

using UnityEngine;

using System.Collections;


public class TestGrid : MonoBehaviour {

public float CellWidth = 2;

public float CellHeight = 2;

public int CellCount = 5;


[ContextMenu ("Arrange")]

public void Arrange () {

Vector3 pos = transform.position;

for (int i = 0; i < transform.childCount; i++) {

Transform child = transform.GetChild(i);

pos.x += (i % CellCount) * CellWidth;

pos.y += (i / CellCount) * CellHeight;

child.position = pos;

}

}

}


'Computer Language > 유니티' 카테고리의 다른 글

GUI 씬 전환  (0) 2014.06.23
[System.Serializable] [Range(0, 100)] [HideInInspector] [SerializeField] Script Editor  (0) 2014.06.23
진행중 gamecontroller  (0) 2014.06.10
바둑 주석  (0) 2014.05.29
값과 주소.  (0) 2014.05.26

+ Recent posts