// Use this for initialization void Start () { var cang = Resources.Load<GameObject>("QuadCang"); GameObject obj =new GameObject("cangs"); //摆一屏幕的苍老师 for(int i=0;i<300;i++) { float x = Random.Range(0, 10.0f) - 5; float y = Random.Range(0, 10.0f) - 5; var c = GameObject.Instantiate(cang) as GameObject; c.transform.parent = obj.transform; c.transform.position = new Vector3(x, y, 0); c.transform.localScale = new Vector3(0.2f, 0.2f); var m = c.GetComponent<MeshRenderer>().material; c.GetComponent<MeshRenderer>().material = new Material(m); arraycang.Add(c.GetComponent<MeshRenderer>()); } //摆一个红音老师 var hong = Resources.Load<GameObject>("QuadHong"); var objhong =GameObject.Instantiate(hong) as GameObject; //红音军团 for(int i=0;i<10;i++) { hongyinarmy army = new hongyinarmy(); army.obj = GameObject.Instantiate(hong) as GameObject; army.obj.transform.parent = objhong.transform; float x = Random.Range(0, 2.0f) - 1; float y = Random.Range(0, 2.0f) - 1; army.pos = new Vector3(x, y, -1); army.obj.transform.localScale = new Vector3(0.2f, 0.2f); arrayhong.Add(army); } }
// Use this for initialization void Start() { var cang = Resources.Load <GameObject>("QuadCang"); GameObject obj = new GameObject("cangs"); //摆一屏幕的苍老师 for (int i = 0; i < 300; i++) { float x = Random.Range(0, 10.0f) - 5; float y = Random.Range(0, 10.0f) - 5; var c = GameObject.Instantiate(cang) as GameObject; c.transform.parent = obj.transform; c.transform.position = new Vector3(x, y, 0); c.transform.localScale = new Vector3(0.2f, 0.2f); var m = c.GetComponent <MeshRenderer>().material; c.GetComponent <MeshRenderer>().material = new Material(m); arraycang.Add(c.GetComponent <MeshRenderer>()); } //摆一个红音老师 var hong = Resources.Load <GameObject>("QuadHong"); var objhong = GameObject.Instantiate(hong) as GameObject; //红音军团 for (int i = 0; i < 10; i++) { hongyinarmy army = new hongyinarmy(); army.obj = GameObject.Instantiate(hong) as GameObject; army.obj.transform.parent = objhong.transform; float x = Random.Range(0, 2.0f) - 1; float y = Random.Range(0, 2.0f) - 1; army.pos = new Vector3(x, y, -1); army.obj.transform.localScale = new Vector3(0.2f, 0.2f); arrayhong.Add(army); } }