//public MapUnit around; public void Start() { Button btn = gameObject.GetComponent <Button>(); hexVector.ChangeToVect(vector); btn.onClick.AddListener(Onclick); vector = transform.GetComponent <Transform>().position; Debug.Log("instalize mapunit."); }
// Use this for initialization void Start() { //测试用 for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { GameObject gameObject = new GameObject("test" + i.ToString() + j.ToString()); gameObject.transform.parent = GameObject.Find("Plane").transform; HexVector vector = new HexVector(); Button btn = gameObject.AddComponent <Button>(); MapUnit mapunit = gameObject.AddComponent <MapUnit>(); MeshFilter flit = gameObject.AddComponent <MeshFilter>(); MeshRenderer renderer = gameObject.AddComponent <MeshRenderer>(); gameObject.AddComponent <BoxCollider>(); flit.mesh = mesh; gameObject.transform.position = vector.ChangeToVect(new Vector3(i, 0, j)); // Debug.Log(gameObject.transform.position); } } // setaround(GameObject.Find("test00")); // Debug.Log("clicktest00"); }