- Home /
Build Asset Bundles and then build the player
I'm trying to make a asset bundle build before making the player one with the idea of excluding the assets inside the assetbundle on the player build.
To make it possible I'm doing the following approach in my CustomBuild.cs file:
BuildPipeline.PushAssetDependencies();
BuildPipeline.BuildAssetBundle(...):
BuildPipeline.PushAssetDependencies()
BuildPipeline.BuildPlayer(...);
BuildPipeline.PopAssetDependencies();
BuildPipeline.PopAssetDependencies();
Checking the logs of the player everything looks good and the files included in the asset bundle aren't included in the player build. Then when I execute the game, if the asset bundle isn't downloaded the files referenced by it doesn't appear correctly and after downloading it they work as expected.
The only problem is that using this approach the generated project binary has exactly the same size that the original one without removing the asset bundle.
Making a deep search inside the generated project (in Xcode), I discovered a copy of my bundle inside the "Data" folder of the generated project (with exactly the same size and a name equals to my asset bundle name but adding the prefix "CAB-")
If I delete this file and compile the project everything works fine and the build size is now the correct one. Also generated asset bundle download works perfectly after deleting the file so basically everything work as expected after deleting this "CAB-" file in the generated project.
I made also the same tests in Android and the problem is the same, with the addition that in android I need to create the project (not the apk file) for deleting this file too.
So my questions are:
why is this happening? Is there a way to avoid the creation of this "CAB-" file inside the project? Is there another way of remove the bundle contents from the project without needing to edit every referenced asset to them? Is there a better solution to build the bundles first and then the player to not have references of the files of the bundle in the project?
Thanks!