Entity.AddScript_TScript_(TScript).md

July 25, 2024 ยท View on GitHub

Friflo.Engine.ECS

Friflo.Engine.ECS.Entity

Entity.AddScript(TScript) Method

Add the given script to the entity.
If the entity contains a script of the same TScriptSystem.Type it is replaced.
See Example.

public TScript AddScript<TScript>(TScript script)
    where TScript : Friflo.Engine.ECS.Script, new();

Type parameters

TScript

Parameters

script TScript

Returns

TScript
The script with the passed TScriptSystem.Type previously added to the entity.
Return null if the entity had no script with the passed TScriptSystem.Type.

Remarks

Note: Use AddNewEntityScript(Entity, ScriptType) as non generic alternative.