- Home /
AssetBundle.Unload(true) removes DLL references
I have made an asset bundle with prefabs. These prefabs reference scripts contained in a DLL and use the default Unity models. After importing the DLL in another project and loading the bundle, I instance the prefabs. Also, the DLL is only referenced by the bundle. Everything goes as expected, and at some point later, I unload the bundle completely.
When unloading happens, the primitive models remain. This is expected behavior of course, since they are not part of the asset bundle. However, I've noticed that the DLL scripts referenced are removed, even though they are not a part of the bundle.
My questions are:
Why does Unity remove the DLL references when the DLL is obviously not part of the bundle?
Does this mean that the library unloads as well?
Hmm that sounds really strange, because it's not so easy to unload a dll in .NET / $$anonymous$$ono. The only way is to load the dll into a new AppDomain and kill the whole AppDomain. Usually when you just add a dll to a project it's loaded into the default AppDomain and therefore can't be unloaded. Are you sure that the dll is gone? Have you tried to use AddComponent after your AssetBundle unload?
See thats the thing - I dont know if the DLL is unloaded, but after unloading the bundle, the GameObjects that are left show $$anonymous$$onoBehaviour components with missing references where the DLLs scripts used to be. Is that normal behavior? Even more peculiar, if it is normal behavior, then why?
Answer by hoy_smallfry · Feb 06, 2013 at 06:31 PM
Partial answer:
I just called this bit of code after unloading the bundle:
string message = string.Empty;
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
message += assembly.FullName + "\n";
}
Debug.Log(message);
The assembly is still in the app domain, which answers my second question, but the first question is still a mystery.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
When do asset bundles unload? 0 Answers
Multiple Cars not working 1 Answer