How to load script component of a prefab on an AssetBundle in Unity3D?

Viewed 436

So I have a gameObject(Let's call it XX) and I have created a Prefab of XX that contains a script (the XX prefab has a script component). When I build the AssetBundle and I load XX on a button click the gameObject of XX loads correctly but the script component doesn't come along. Is there a way to load XX with the script component? Thanks!

1 Answers

The Solution to my question is that you create the asset bundle from your model-object and then through code you AddComponent to this. Something like this: MyClass xx = anObject.AddComponent(typeof(MyClass)) as MyClass;

Related