unity3d第十五天

来源:互联网 发布:剑灵捏脸数据天族女 编辑:程序博客网 时间:2024/05/29 07:16

任务4


using UnityEngine;using System.Collections;public class Get_test : MonoBehaviour {GameObject[] Objcopy = new GameObject[10]; // Use this for initializationvoid Start () {GameObject Objplane = GameObject.Find("Plane");Objplane.GetComponent<Renderer> ().material.color = Color.black;//从标签找到物体GameObject TagCube = GameObject.FindWithTag("MyTag");TagCube.GetComponent<Renderer> ().material.color = Color.black;}// Update is called once per framevoid Update () {if (Input.GetMouseButtonDown (0)) {for(int i=0;i<10;i++){Objcopy[i] = GameObject.CreatePrimitive(PrimitiveType.Cube);Objcopy[i].AddComponent<Rigidbody>();Objcopy[i].name="Cube"+i;Objcopy[i].transform.position = new Vector3(-25.0f+i*5.0f,10.0f,0.0f);}for(int j=0;j<10;j++){Destroy(Objcopy[j],5);}}}}


0 0