Init(args)
Scripting Reference
Loading...
Searching...
No Matches

◆ Instantiate< TObject, TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument >() [2/3]

static TObject Sisus.Init.InstantiateExtensions.Instantiate< TObject, TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument > ( [DisallowNull] TObject original,
TFirstArgument firstArgument,
TSecondArgument secondArgument,
TThirdArgument thirdArgument,
TFourthArgument fourthArgument,
TFifthArgument fifthArgument,
[AllowNull] Transform parent,
bool instantiateInWorldSpace = false )
static

Clones the original TObject , theinitializes it with the given arguments and then returns the clone.

Arguments should either be received by the created Object during its initialization (such as during the Awake event) or if the Object class implements the IInitializable<TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument> interface the arguments can be provided using the Init function immediately after initialization has finished (before the Start event function).

For classes deriving from MonoBehaviour<TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument> the latter method will be used in cases where the original object is a Component in an inactive GameObject, while if the gameObject is inactive the arguments will be received during the Awake event function.

See also
Object.Instantiate
Template Parameters
TObjectType of the Object that is being cloned.
TFirstArgumentType of the first argument used during initialization of the clone.
TSecondArgumentType of the second argument used during initialization of the clone.
TThirdArgumentType of the third argument used during initialization of the clone.
TFourthArgumentType of the fourth argument used during initialization of the clone.
TFifthArgumentType of the fifth argument used during initialization of the clone.
Parameters
originalOriginal TObject to clone.
firstArgumentThe first argument used during initialization of the clone.
secondArgumentThe second argument used during initialization of the clone.
thirdArgumentThe third argument used during initialization of the clone.
fourthArgumentThe fourth argument used during initialization of the clone.
fifthArgumentThe fifth argument used during initialization of the clone.
parentParent that will be assigned to the new object.
instantiateInWorldSpaceWhen you assign a parent Object, pass true to position the new object directly in world space. Pass false to set the object’s position relative to its new parent.
Returns
The cloned TObject .
Exceptions
ArgumentNullExceptionThrown if original is null.
InitArgumentsNotReceivedExceptionThrown if TObject class does not implement IInitializable<TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument> and did not manually handle receiving the provided arguments during its initialization.
Type Constraints
TObject :Object 
TObject :IArgs 
TObject :TFirstArgument 
TObject :TSecondArgument 
TObject :TThirdArgument 
TObject :TFourthArgument 
TObject :TFifthArgument