Object.Instantiatestatic function Instantiate (original : Object, position : Vector3, rotation : Quaternion) : ObjectDescriptionClones the object original and returns the clone. Clones the object original, places it at position and sets the rotation to rotation, then returns the cloned object.
This is essentially the same as using duplicate command (cmd-d) in Unity and then moving the
object to the given location.
If a game object, component or script instance is passed, Instantiate will clone the entire game object hierarchy, with all children cloned as well.
All game objects are activated.
JavaScript
// Instantiates 10 copies of prefab each 2 units apart from each other using UnityEngine; import UnityEngine
JavaScript
// Instantiate a rigidbody then set the velocity using UnityEngine; import UnityEngine
JavaScript
// Instantiate a prefab with an attached Missile script using UnityEngine; import UnityEngine static function Instantiate (original : Object) : ObjectDescriptionClones the object original and returns the clone. This function preserves the position and rotation of the cloned object.
This is essentially the same as using duplicate command (cmd-d) in Unity.
If the object is a Component or a GameObject then entire game object including all components
will be cloned.
If the game object has a transform all children are cloned as well. All game objects are activated after cloning them.
JavaScript
// Instantiates prefab when any rigid body enters the trigger. using UnityEngine; import UnityEngine static function Instantiate.<T> (original : T) : TDescriptionGeneric version. See the Generic Functions page for more details. |
