Missing referenced script in game object loaded from asset bundle

I have a very simple Unity project containing one prefab. This prefab just contains a sphere with a custom monobehaviour attached to it.

I want to put this prefab in an asset bundle which I build using the following code:

Object sphere = AssetDatabase.LoadMainAssetAtPath("Assets\Bundle2\Sphere.prefab"); BuildPipeline.BuildAssetBundle(sphere , null, "Assets\bundle2.unity3d", BuildAssetBundleOptions.CompleteAssets);

Note that I don't use `BuildAssetBundleOptions.CollectDependencies` because I don't want all the dependencies to be pulled in my asset bundle.

When I then load the asset bundle I get the following error message:

The referenced script on this Behaviour is missing! UnityEngine.AssetBundle:LoadAll(Type)

If I rebuild the asset bundle with the CollecDependencies option everything works fine.

I don't understand why CollectDependencies is required to make my script work. From what I understand script components are just references to classes defined in the main assembly.

Am I misunderstanding how asset bundles work?

Thanks,

Clem

same problem here, any solution found?

same question, CollecDependencies include too many asset, just want script.

You don't put scripts in Asset Bundles , they need to be in the main build.

is it not possible to load assembly from bytes? well i know it is not possible in iOS but other platforms it should be working. I havent tried though!! so not sure!

2 Answers

2

assetbundle miss script

Doesn’t this mean there is an empty script on one of your assets ??
I don’t know if this applies for this problem though.