Stride Forums Archive

How do I add a script component at runtime?

3 posts, 1205 views, 2019-06-07 to 2019-06-13

Sasinosoft 2019-06-07 #1

Hello,
I am new to Xenko, and I was wondering how can I attach a ScriptComponent to an entity in code (at runtime). I am porting a Unity library (DragonBone runtimes) to Xenko.
I am using the latest stable release of Xenko (3.0.0.9).
Thanks in advance.

tonfilm 2019-06-08 #2

hi @Sasinosoft,

you just have to call something like:
var script = new MyScript()
myEntitiy.Add(script);

Thank you very much.
All I had found on the net was code from older versions of Xenko in which it was done in a completely different way.