李健吾Instantiate duplicates an object. Including all attached scripts and the entire hierarchy. It keeps references in the way you expect it: References to objects outside the cloned hierarchy will be left untouched, References to objects in the cloned hierarchy will map to the cloned object.
实例化一个对象,将包含该对象已有的全部脚本和它的全部继承关系(比如子物体和组件).这可以保证你以期望的方式引用它:可以原封不动的将对象的继承关系复制到你的新对象中. 【狗刨学习网】
Instantiate is incredibly fast and very versatile. It is esntial to using Unity to its fullest.
实例化非常快捷,而且是多用途的.在使用Unity的过程中充分利用它是非常必要的.
For example here is a tiny script that when attached to a rigidbody with collider will destroy itlf and instead spawn an explosion object
例如这是一个小脚本,当碰撞体接触后销毁自身对象,并创建一个爆炸对象.
∙ C# 干锅鱿鱼须的做法
∙ JavaScript
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour学雷锋图片大全>三国演义名人名言 {
public Transform explosion;
void OnCollisionEnter() {
Destroy(gameObject);
Transform theClonedExplosion;
theClonedExplosion = Instantiate(explosion, transform.position, ation);
}
}
英雄联盟adcvar explosion : Transform ;
// When a collision happens destroy ourlves
唐诗春夜喜雨// and spawn an explosion prefab instead
// 当一个碰撞发生自毁
亲爱的不二// 和产生爆炸预制物代替
function OnCollisionEnter (){
Destroy (gameObject);
var theClonedExplosion : Transform ;
theClonedExplosion = Instantiate(explosion,transform.position, ation);
}
分离的英文Instantiate is usually ud in conjunction with Prefabs .
实例化常和 Prefabs 一起使用.