Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow building specific asset bundles #119

Open
liortal53 opened this issue Mar 20, 2019 · 9 comments
Open

Allow building specific asset bundles #119

liortal53 opened this issue Mar 20, 2019 · 9 comments

Comments

@liortal53
Copy link
Contributor

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.

@alffanclub
Copy link
Contributor

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.

@liortal53
Copy link
Contributor Author

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.

@alffanclub
Copy link
Contributor

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 alffanclub reopened this Mar 22, 2019
@jxxxxst
Copy link

jxxxxst commented Mar 2, 2020

Why was this feature reverted ? (af1549c)

@ivoras
Copy link

ivoras commented Dec 31, 2020

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.

@tallior
Copy link

tallior commented Jan 8, 2021

@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?

@ivoras
Copy link

ivoras commented Jan 8, 2021

@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.

@tallior
Copy link

tallior commented Jan 17, 2021

@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.

@michael811125
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants