AssetBundles-Browser icon indicating copy to clipboard operation
AssetBundles-Browser copied to clipboard

Allow building specific asset bundles

Open liortal53 opened this issue 5 years ago • 9 comments

currently it's only possible to build ALL asset bundles in the project. In case there are a lot of them, it might be a very time consuming operation.

There should be a way to select which asset bundle(s) to build, and have only those built.

liortal53 avatar Mar 20 '19 23:03 liortal53

yes, that would be a helpful feature. We are adding that to the addressables system, but will not be adding it here. The reason is that outside of addressables, it is not very realistic for us to provide a build script that can be used consistently in a real-life production environment. The build script in this tool is intended as a sample for people to use as a basis when they create the build script they actually need.

alffanclub avatar Mar 21 '19 13:03 alffanclub

I understand it is only given as a sample, but a few people on some forum threads have asked for that feature which may be a useful thing to use "as is" or base more complex build operations on.

In any case, why did you close this? i was going to implement this and send a PR for it.

liortal53 avatar Mar 22 '19 08:03 liortal53

If you've got plans to PR it, then I'm happy to keep it open. I had not realized that was your intent. I always welcome PR's

alffanclub avatar Mar 22 '19 14:03 alffanclub

Why was this feature reverted ? (https://github.com/Unity-Technologies/AssetBundles-Browser/commit/af1549c592a37fb0a4df708cbb2f28c099858523)

jxxxxst avatar Mar 02 '20 15:03 jxxxxst

bump.

This is a very useful feature, in our particular case more useful than Addressables. Just a method which accepts a filter (a string of names) of which ABs to build would be great.

ivoras avatar Dec 31 '20 09:12 ivoras

@ivoras isnt this possible with my suggested fix here?

Would you like ne to create a simple static method just like u described? Would that help in any way?

tallior avatar Jan 08 '21 11:01 tallior

@ivoras isnt this possible with my suggested fix here?

I do not see any posts with your username here. Could you tell me where can I find the suggested fix?

Would you like ne to create a simple static method just like u described? Would that help in any way?

Yes it would - but where? Doesn't this feature need to be in Unity's code?

We are currently using BuildPipeline.BuildAssetBundles() and with the increasing size of asset bundles (and in our case it's constantly growing), having to rebuild everything often is a big PITA.

ivoras avatar Jan 08 '21 12:01 ivoras

@ivoras here is a rough sketch of such a method:

public static void BuildAssetBundlesByName(params string[] assetBundleNames)
{
	// Argument validation
	if (assetBundleNames == null || assetBundleNames.Length == 0)
	{
		return;
	}

	// Remove duplicates from the input set of asset bundle names to build.
	assetBundleNames = assetBundleNames.Distinct().ToArray();

	List<AssetBundleBuild> builds = new List<AssetBundleBuild>();

	foreach (var assetBundle in assetBundleNames)
	{
		var assetPaths = AssetDatabase.GetAssetPathsFromAssetBundle(assetBundle);

		AssetBundleBuild build = new AssetBundleBuild();
		build.assetBundleName = assetBundle;
		build.assetNames = assetPaths;

		builds.Add(build);
	}

	// TODO: set the desired BuildAssetBundleOptions
	BuildPipeline.BuildAssetBundles(@"outputPath", builds.ToArray(), BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
}

You would need to tweak it a bit (output path, build options) but it should work.

tallior avatar Jan 17 '21 20:01 tallior

try it https://github.com/michael811125/AssetBundles-Browser-Plus

michael811125 avatar Jun 07 '22 16:06 michael811125