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