I have a GameObject instantiated in a test scene in project A. The GameObject contains a script component. That script component is a MonoBehaviour class from a DLL which is contained in project A’s “Assets/Plugins” folder.
I am creating the following separate assetbundles:
-
bundletest1.assemblies - contains the DLL, renamed with a “.bytes” extension (since “.dll” files apparently can’t be included in assetbundles, due to them being an unknown asset type)
-
bundletest1.scenes - contains the scene file
In project B, I have some logic that loads these two assetbundles.
First, I’m loading the assembly bundle, which loads correctly. I’ve tested that the class functions from the DLL are working fine if I instantiate a new GameObject from inside the loading script, and add the DLL’s contained class as a new dynamic component, as per http://docs.unity3d.com/Manual/scriptsinassetbundles.html.
After loading the assembly bundle, I load the scene bundle, which has a few simple items in it, and it loads correctly as well, with one important exception. The GameObject that contains the script component comes up with a missing reference, instead of pointing to the class that I’ve brought over in the assembly bundle.
Furthermore, while project B is running (after the bundles are loaded as above), I can’t assign any of my DLLs classes to objects in the scene, even though they were just loaded and should be resident in memory. I don’t understand why this is the case.
How can I preserve the reference/GUID of the script from project A to project B?
If I copy the DLL directly into project B’s “Assets/Plugins” folder, the reference is preserved and my classes can be accessed without any problems. But the whole point of what I’m trying to do is to bring the DLL’s classes into project B via an assetbundle, using Reflection.
I must be missing one critical piece of the puzzle, but I’ve been working on this for more than a week and haven’t been able to figure out what I’m doing wrong. Any ideas?