- Home /
How to correctly make AssetBundles for different build targets?
My current project uses AssetBundles to load content, however it is being built out for Android, thus resulting in Pink shaders in Editor. This is just one hiccup im having, however i do intend to also deploy on IOS. With this being the case, Using the AssetBundle Manager, Can I generate Asset Bundles for many build types in the same project window or do i need to open a separate, duplicate project for the IOS build and AssetBundles?
I am also copying and loading the bundles from StreamingAssets, which i suspect may complicate things as there will be multiple copies of each asset bundle per build target in that case.
Answer by carterdawson · Nov 28, 2018 at 05:00 PM
I know this is a little old, but for what it's worth, below is a class that I use for that. As far as I know, there's no way to use the AssetBundle Manager to do this same thing.
public class CreateAssetBundles
{
static private BuildTarget[] supportedTargets = new BuildTarget[]
{
BuildTarget.iOS,
BuildTarget.StandaloneWindows,
BuildTarget.Android,
};
static private void BuildAssetBundle(BuildTarget target)
{
Debug.LogWarning("Building AssetBundles for target: " + target);
string assetBundleDirectory = "z_Build/AssetBundles/"+target.ToString();
if (!Directory.Exists(assetBundleDirectory))
{
Directory.CreateDirectory(assetBundleDirectory);
}
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.None, target);
Debug.LogWarning("Assetbundles built to dir: " + assetBundleDirectory);
}
[MenuItem("Assets/Build AssetBundles/Windows")]
static void BuildAssetBundlesWindows()
{
BuildAssetBundle(BuildTarget.StandaloneWindows);
}
[MenuItem("Assets/Build AssetBundles/All")]
static void BuildAssetBundlesAll()
{
foreach (BuildTarget target in supportedTargets)
{
BuildAssetBundle(target);
}
}
}
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
AssetBundles - depend on asset already included in executable 0 Answers
Can AssetDatabase.LoadAllAssetsAtPath Load All Assets Recursively? 2 Answers
Filter assets added to sharedassets0 ? 0 Answers
Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle 0 Answers