- Home /
Setting Android Build Setting Compression Method via SCRIPT
Under build settings of android, we have an option called, compression method
accepting default
, LZ4HC
and LZ4
.
I need to set value of this field via SCRIPT.
I know something such as BuildOptions.CompressWithLz4
exists, but I can't understand how to use it...
searched a lot but not finding my answer.
Answer by Bunny23Rabbit · Apr 15 at 05:48 PM
@JAAMY Before you starting build process with BuildPipeline.BuildPlayer(buildPlayerOptions) you need to modify this options. You can do something like this:
private static void BuildPlayer()
{
var buildPlayerOptions = CreateBuildPlayerOptions(BuildTarget.Android, IS_DEVELOPMENT_BUILD, "OUTPUT_PATH_FOR_BUILD");
var outputDir = Path.GetDirectoryName(buildPlayerOptions.locationPathName);
if (!string.IsNullOrEmpty(outputDir))
Directory.CreateDirectory(outputDir);
BuildPipeline.BuildPlayer(buildPlayerOptions);
}
private static BuildPlayerOptions CreateBuildPlayerOptions(BuildTarget buildTarget, bool isDevelopmentBuild, string outputPath)
{
var buildOptions = BuildOptions.None;
if (isDevelopmentBuild)
buildOptions |= BuildOptions.Development;
if (buildTarget == BuildTarget.Android)
buildOptions |= !isDevelopmentBuild
? BuildOptions.CompressWithLz4
: BuildOptions.CompressWithLz4HC;
return new BuildPlayerOptions
{
target = buildTarget,
subtarget = (int) StandaloneBuildSubtarget.Player,
targetGroup = BuildPipeline.GetBuildTargetGroup(BuildTarget.Android),
options = buildOptions,
locationPathName = outputPath,
// Put here all you scenes or use method that will construct that array
scenes = new[] { "Assets/Scenes/Scene1.unity", "Assets/Scenes/Scene2.unity" }
};
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613035030im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do i define BuildPlayerOptions.assetBundleManifestPath without a custom script? 0 Answers
Editor. Ignore selection some gameObjects 1 Answer
Is there a tool to create managed dll wrapper? 0 Answers
xr plugin managment arkit required script 0 Answers
MethodInfo listing functions and parameters of a public variable 2 Answers