unity3d中克隆的物体包含的属性或组件消失,怎么解决?
我想要克隆几个飞机,但是克隆出来的飞机没有包含原有的属性
原本是有一个爆炸的,但是克隆之后就成了这样
它自己消失了不知道为啥,这是显示的错误:
public class EnemySpawn : MonoBehaviour
{
public Transform m_enemyPrefab;
public Transform m_explosionFX;
public float m_life = 1;
// Start is called before the first frame update
void Start()
{
StartCoroutine(SpawnEnemy());
}
IEnumerator SpawnEnemy()
{
while (true)
{
yield return new WaitForSeconds(Random.Range(5, 15));
Instantiate(m_enemyPrefab, transform.position, Quaternion.identity);
}
}
}