Difference in script compilation in BuildStreamedSceneAssetBundle vs BuildAssetBundles
I am trying to port some code from the Unity4 AssetBundle build system to the new one. My goal is to build some scenes into their own bundles. This worked well using
BuildPipeline.BuildStreamedSceneAssetBundle(levels, outputPath, BuildTarget.StandaloneWindows);
Now, I tried to do the same with the new system, i.e. I added respective scene to a bundle and tried to build it using
BuildPipeline.BuildAssetBundles("Assets/AssetBundleOutput");
The problem is that I get the following error:
Error building Player because scripts had compiler errors
The compiler error is:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
My project uses some (native and managed) DLLs that work fine in a normal x86 build.
What can generally cause this kind of build error? The strangest thing seems to be that the old-style build works fine, but the new bundle system doesn't.
Answer by anderas · Sep 07, 2015 at 10:40 AM
After reading up on the new build command, I noticed that I was missing the build target:
BuildPipeline.BuildAssetBundles("Assets/AssetBundleOutput",BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
In case anybody from Unity reads this, please see it as a suggestion to improve your compiler errors! (E.g. mention what assembly is actually the problem, there are some in my project that won't work in the web player, which would have been a nice hint...)
Your answer
Follow this Question
Related Questions
Loading scene from bundle in Unity5 appears empty 0 Answers
Is Assetbundle.LoadAsset & LoadAllAsset thread safe in Unity5.2.4? 0 Answers
www class download local file (Windows Universal Platform - Hololens) 1 Answer
Error FMOD::Sound instance - no sound is being played from AssetBundle 0 Answers
AssetBundles miss static property 0 Answers