- public GameObject newPrefabs;//预制物体
- void Update () {
- if(Input.GetMouseButtonDown(0)){
- GenerateNumber();
- }
- }
- public void GenerateNumber(){//生成数量
- GameObject go= Instantiate(newPrefabs,transform.position,transform.rotation)as GameObject;//类型转换成GameObject,这类型必须和newPrefabs类型一致
- go.transform.parent=transform;
- }
- }
复制代码 已经解决
|