Asset Bundles and Scripts

I have a question about scripts as they pertain to asset bundles. Obviously I can’t just put a script in the asset bundle and load it since it wouldn’t be compiled (can make a dll but that doesn’t help in this case). However, what if I just put the script as a component on a prefab in my asset bundle, but left the script in the project to be compiled?

Would that prefab work when I load it in from the asset bundle? Would the values I set in editor for the prefab be preserved? The goal here is to be able to customize the script values of the prefabs we’re loading from asset bundles, without doing “AddComponent” and manually setting the properties for each and every object loaded in from the bundle at runtime.

Yes that is possible and the intended use. As you said all your scripts are actually compiled into a single assembly (well actually a few but that’s just for different compilation groups and not relevant here). Actual assets are nothing but serialized data. This includes pure data assets like meshes, textures, audioclips, … but also any serialized class instances. A serialized gameobject hierarchy can be stored in two different ways. Either as part of a scene file, or as standalone prefab. In both cases the actual data will be stored inside the scene / prefab file.

Of course to load a serialized gameobject all classes of all components has to exist in the current AppDomain, otherwise Unity can’t deserialize the objects. It usually is possible to manually download a seperate external assembly file and use reflection to load that assembly into the current AppDomain. Once that has been done there should be no problem loading AssetBundles which contain gameobjects with components defined inside that assembly.

See this question for reference