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

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

static TObject Sisus.Init.InstantiateExtensions.Instantiate< TObject, TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument > ( [DisallowNull] TObject original,
TFirstArgument firstArgument,
TSecondArgument secondArgument,
TThirdArgument thirdArgument,
TFourthArgument fourthArgument,
Vector3 position,
Quaternion rotation,
[AllowNull] Transform parent = null )
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> 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> 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.
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.
positionThe position for the new instance.
rotationThe rotation for the new instance.
parentParent that will be assigned to the new object.
Returns
The cloned TObject .
Exceptions
ArgumentNullExceptionThrown if original is null.
InitArgumentsNotReceivedExceptionThrown if TObject class does not implement IInitializable<TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument> 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