public GameObject sp_20;
void Update () { if (Input.GetMouseButtonDown(0)) { OnArrange(20); } } /* 100--0.3 100放大了的本地坐标 0.3世界坐标 200--0.6 300--0.8 400--1.1 500--1.4 600--1.7 700--1.9 800--2.2 900--2.5 1000--2.8 1050--2.9 1080--3.0 */ public void OnArrange(int num) { for (int i = 0; i < num; i++) { /* GameObject go = GameObject.Instantiate(sp_20, new Vector3(0, 10, 0), Quaternion.identity) as GameObject; go.transform.SetParent(transform); go.transform.localScale = Vector3.one; go.transform.localPosition = new Vector3(300, 0, 0); Debug.Log(go.transform.position);//世界坐标 Debug.Log(go);*/ if (i <15) { GameObject goes = GameObject.Instantiate(sp_20, new Vector3(0, 55, 0), Quaternion.identity) as GameObject; goes.transform.SetParent(transform); goes.transform.localScale = Vector3.one; goes.transform.localPosition = new Vector3(490-35 * i, 55, 0); } else { GameObject goes = GameObject.Instantiate(sp_20, new Vector3(0, 55, 0), Quaternion.identity) as GameObject; goes.transform.SetParent(transform); goes.transform.localScale = Vector3.one; goes.transform.localPosition = new Vector3(490-35 * 15, 55, 0); goes.transform.localPosition = new Vector3(490-35 * (i - 15), 20, 0); } } }