I’m having issues doing something which I had hoped would be simple - adding a prefab to an asset bundle.
Everything works fine as long as the prefab has no custom scripts attached.
If it does have scripts attached, I get the following issues.
if I build the bundle with BuildAssetBundleOptions.CollectDependencies, then I can load and instantiate the bundle.
This is fine, but when I try and unload the bundle I get the error, “Trying to reload asset from disk that is not stored on disk”
So the only way to get this to work, is to keep the compressed bundle in memory at all times - severely increasing the application’s memory usage. Note that I am calling assetBundle.Unload( false ) after loading and storing reference to all assets in the bundle. As stated previously, this works fine unless there are scripts involved.
Otherwise If I build the bundle with BuildAssetBundleOptions.CompleteAssets, then the ‘…reload asset from disk…’ error goes away, but when I instantiate a prefab, all of the script references are missing.
So what’s the solution here? Don’t include prefabs in asset bundles? Or include prefabs in their own asset bundles - with no other assets - so that they can be loaded into memory at all times? Both of these are sub-par workarounds which I would like to avoid.