How to resolve script references in scene bundles from dynamically loaded assemblies?

I’ve read the forum posts and manual regarding the inclusion of precompiled scripts in asset bundles. However, all the examples I seen involve creating/attaching a new component from an asset bundle assembly. Is there a way to detect/resolve script references from a scene that was loaded through an asset bundle with an assembly that was loaded from another bundle (or, loaded directly through a .dll file).

I’m creating a Unity based visualization application. It does little more than allow users to navigate through a virtual scene and provide some basic interaction functionality. I’d like users to be able to generate their own content in the Unity Editor (a separate project) and then export that content (scenes) in a way that the visualization application can ingest and display. AssetBundles seem like the way to do that. I can do that now, and it works fine. The problem is that if an object has a script attached to it (maybe to make it move or perform some behavior), the script reference can’t be resolved in the visualization application. I’ve tried loading an assembly with the precompiled script code, but I need more information on how script references are resolved when scene bundles are deserialized to see if it’s possible to resolve them from an alternate assembly.

Please see the following forum entry for more detail.
http://forum.unity3d.com/threads/exporting-resolving-script-references-in-assetbundles.331110/

Thank you.

Unfortunately, no answers here or on the forum.

The closest I’ve come to making script references resolve is by using plugins. U5 makes it pretty easy to code a script in an external (VS or Mono) project and load the assembly in the editor as a managed plugin. As such, all scripts contained within the plugin can be instantiated and edited in the editor as if they had been compiled by the editor.

If a scene bundle uses a script within the plugin, all the bundle loader (in a different project) need do is load the plugin (Assembly) dynamically first, and references in the scene bundle seem to resolve.

I need to test more, but this seems the closest way possible towards letting content developers use the Unity editor to export assets and scripts as a complete package.

It’s unfortunate that setting up and editing the plugin project is a bit cumbersome for a non-programmer. It would be nice if the editor could be told to compile and export scripts as a managed plugin (rather than putting them in Assembly-CSharp) with a name of my choosing (similar to the way asset bundles are created). I’ve requested the feature on the feedback forum. Others have suggested the same, though for differing reasons.

http://feedback.unity3d.com/suggestions/export-compiled-scripts-for-asset-bundles-as-plugin-custom-assembly

If anyone can figure out an editor script to do it, please provide.

Thanks.

@mikewarren just found this question of yours and it’s the exact same problem I’m trying to solve at the moment. Could I ask you some questions?

  • Have you found a better way to solve this problem in the meantime?
  • I understand every step in your description except this one:

If a scene bundle uses a script within the plugin, all the bundle loader (in a different project) need do is load the plugin (Assembly) dynamically first, and references in the scene bundle seem to resolve.

I’m not sure how to load the plugin dynamically. What exactly do you mean by that? And does this also mean, that it isn’t enough to just have the plugin in the project folder of the the project that loads the asset bundle?

Thank you very much!