AssetBundles and ScriptableObjects cross project

My goal was to split our project into two. One project would contain game code. The other project would contain assets for download (in the thousands). This was working until I tried to load a bundle containing a scriptableObject.

I have an Identical ScriptableObject class in both projects:

public class LevelObject : ScriptableObject{
public Texture bg;
public TextAsset levelData;
public GameObject mesh;
}

I wanted to bundle this scriptable object so that I could easily load everything out of the bundle. So I create a .asset file:

LevelObject asset = ScriptableObject.CreateInstance();
AssetDatabase.CreateAsset(asset,fullName);
AssetDatabase.SaveAssets();

When I bundle this, it looks to be the right size. But when I try to load the asset out of the bundle, it is always null.

Is this because I have duplicated the LevelObject script in both projects? I know that new code cannot be in an assetbundle. If this were a component on a prefab, instead of a scriptableObject, would it work? With our split projects, does that mean no components ever? Or am I just doing something wrong. This process has worked fine so far for textures/meshes/prefabs, but this is the first non-unity class.

Should we just not divide the project? I worry about having thousands of large textures on all dev machines. I would prefect a build machine to have the assets.

Thank you for reading,
Dave

It’s becasue each project has it’s own ‘LevelObject’ in its assembly that is built.

They technically aren’t the same class, they’re classes that are shaped similarly. But if you were to print out the type information, including assembly and all, they would not be the same.

An option you have is to create a Visual Studio (or MonoDevelop) project independent of the unity projects. Build a class library that includes this ‘LevelObject’ type. And drop the dll built from that project into the unity projects.

And of course the other option is to NOT divide the projects. I’m not sure what benefits this is really giving you… so what if each dev machine has a bunch of textures, they’re not that huge in the grand scheme of thing.

I’m going to assume you use some type of version control (if you’re not… do so NOW). Just restrict modification of those assets so that devs who shouldn’t be changing them can’t change them on commit to the version control.

But heck, with out all those assets on their dev machines… how else are they to test the game?

I solved this issue by exporting a .unitypackage from the application project and importing it in the asset bundles project.