作用:添加组件,如:刚体组件、C#脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class shoot : MonoBehaviour
{
public GameObject B;
// Start is called before the first frame update
void Start()
{
GameObject a = GameObject.Instantiate(B);
GameObject b = GameObject.Instantiate(B,transform.position,transform.rotation);
b.AddComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class shoot : MonoBehaviour
{
public GameObject B;
// Start is called before the first frame update
void Start()
{
GameObject a = GameObject.Instantiate(B);
GameObject b = GameObject.Instantiate(B,transform.position,transform.rotation);
b.AddComponent<Rigidbody>();//添加刚体组件
}
// Update is called once per frame
void Update()
{
}
}
1。注意名称,这里是shoot