Using Asset Bundles in multiple projects

We are currently working on a few projects where we will be using the same assets across all of them. To us it makes sense to have a Assets project where we build the scene and then a code project where we load the scenes and run our application. It has all been pretty straight forward appart from a few things.

  • When loading scenes from another project Procedural Materials (Substance) can cause the editor to hang.
  • When loading scenes anything set to static in the original scene is no longer static when loaded (performance issues)
  • When using VR (Vive) we need to get every mesh renderer and reapply the same shader it has back onto itself or the eyes do not render correctly.

My understanding is that Asset Bundles are just a ‘zip’ package of sorts and are not bound to a project so we should be able to share assets across multiple projects.

Anyone found a solution to these issues?

1 Like

I think we’re experiencing similar problems, though it takes some time will the editor hangs up. But yes, something similar happens to us too.

That’s not happening to us. We have static game objects which are still static when unpacked. This is mandatory when using lightmap baking which we use. I can check if there is some code doing it, but I doubt that.

Depending on the platform, you’ll need to include referenced script files in both projects. That is also for security reasons (so nobody could inject harmful code via an assetbundle into your client).
Aynthing else should be working to be shared though, textures, shaders, … as long as you have the same Unity version and the assetbundles for the correct platform.

Did you ever solve this? I am running into the same problem.

Our current solution is still the same, while we have a loading screen up and after the scene has finished loading we iterate through all mesh renderers, get the material again using Shader.find and reapply the material on each renderer. Its annoying but it works…

It appears if your asset bundles are generated in another project the shader doesnt appear to transfer properly. e.g If i make a custom shader in another project, AB it and load it in another project its usually pink (no material). The only way i can get it to work is to copy the new shader to both projects.

Hi,

Any success in lightmap store in asset bundle?or any other method?

It appears that I was mistaken. We had an unrelated bug having to do with postprocessing on Daydream that made me think we had this problem. As it turns out, we do NOT have this problem. Loading scenes from asset bundles that originated in an external Unity project, including custom shaders that aren’t in the base project, seems to be working correctly without doing these extra steps, at least on Windows, Mac and Android so far. In our case, we are using 2017.3p1 for both the external project and the base game.

So it seems like this should work for you. Have you filed a bug report with Unity with your project attached so they can take a look?

We are loading scene asset bundles, and the baked lightmaps in those appears to be working fine. One thing that tripped us up was that the lighting settings are always based on the “active” scene - so if you are loading scenes additively, for example, be sure to set the one with lightmaps in it to be the “active” scene when you’re finished loading everything.

For example, do something like:

var scene = SceneManager.GetSceneByName(yourSceneLoadedFromAssetBundle);
SceneManager.SetActiveScene(scene);

Good shout, this also tripped us up for a little while as well! We ended up doing it slightly different though with same result. Our main scene is an empty runtime created scene just called “Logic”, before we bake we combine all lights into their own scene then bake all scenes together.

@Claytonious We are on Windows, currently on 2017.2.0 so will update first. We see this only when we run with a VR headset. Does yours work fine in VR? If so then I will send a bug report if ours doesnt fix on latest

Yes - so far I’ve tested on Google Daydream (Android) and Oculus Rift (Windows).

1 Like