Version: 2022.3
LanguageEnglish
  • C#

Object.InstantiateAsync

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Declaration

public static AsyncInstantiateOperation<T> InstantiateAsync(T original);

Declaration

public static AsyncInstantiateOperation<T> InstantiateAsync(T original, Transform parent);

Declaration

public static AsyncInstantiateOperation<T> InstantiateAsync(T original, Vector3 position, Quaternion rotation);

Declaration

public static AsyncInstantiateOperation<T> InstantiateAsync(T original, Transform parent, Vector3 position, Quaternion rotation);

Declaration

public static AsyncInstantiateOperation<T> InstantiateAsync(T original, int count);

Declaration

public static AsyncInstantiateOperation<T> InstantiateAsync(T original, int count, Transform parent);

Declaration

public static AsyncInstantiateOperation<T> InstantiateAsync(T original, int count, Vector3 position, Quaternion rotation);

Declaration

public static AsyncInstantiateOperation<T> InstantiateAsync(T original, int count, ReadOnlySpan<Vector3> positions, ReadOnlySpan<Quaternion> rotations);

Declaration

public static AsyncInstantiateOperation<T> InstantiateAsync(T original, int count, Transform parent, Vector3 position, Quaternion rotation);

Declaration

public static AsyncInstantiateOperation<T> InstantiateAsync(T original, int count, Transform parent, ReadOnlySpan<Vector3> positions, ReadOnlySpan<Quaternion> rotations);

Parameters

original An existing object that you want to make a copy of.
count The number of new copies to create.
parent The parent that will be assigned to the new object or objects.
position The position for the new object or objects.
rotation The rotation for the new object or objects.
positions The read only span of positions for the new object or objects. The length of the array can be less than count, in which case Unity uses position[i % count].
rotations The read only span of rotations for the new object or objects. The length of the array can be less than count, in which case Unity uses rotation[i % count].

Returns

AsyncInstantiateOperation<T> An asynchronous operation that contains the resulting objects.

Description

Captures a snapshot of the original object (that must be related to some GameObject) and returns the AsyncInstantiateOperation.

The operation is mainly asynchronous, but the last stage involving integration and awake calls is executed on the main thread. The operation can be cancelled, or the integration stage can be delayed using allowSceneActivation. It is possible to yield a return operation or call its WaitForCompletion() method to finish the operation in a synchronized way.