I want to change the global webgl texture compression setting that is available in the editor in the BuildSettings window, but I can’t seem to find the option in EditorBuildSetting to do it programatically. My goal is to set it to a different compression types on one of my UnityCloudBuild configs. I am talking about this option here:
Thank you for this!
I’ve tried locally and it works fine. In UnityCloudBuild if I just switch to the EditorUserBuildSettings.webGLBuildSubtarget = WebGLTextureSubtarget.ASTC; at Pre-build, that build doesn’t seem to be affected by this setting. I’m a bit reluctant to try and run BuildPipeline.BuildPlayer() at Pre-build in Cloud build as this seems to be a method for something else; Plus the paths in cloud are a bit obscured and it will also double the build time as it will do the normal build and the “pre-build” that I try to sneak in.
So, any ideas on how to setup a Unity Cloud Build config to use ASTC and another that uses DXT. They both use the same unique git repo.
You can use a Pre-Export Method that will run before the build in order to change the player settings you need (I’ve attached a screenshot), so you could have a method like this:
public static void ChangeTextureCompression ()
{
EditorUserBuildSettings.webGLBuildSubtarget = WebGLTextureSubtarget.DXT;
}
and put its name in that field.
EDIT: the value in the field will look something like:
Namespace.Class.StaticMethod
Since you want to have use both compression formats, you could have two build targets, each one with a Pre-Build Method like the one above.
For me it worked to define the webGLBuildSubtarget with ASTC in the build options, I think this should work for you as well
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
// This is the important line
buildPlayerOptions.subtarget = (int)WebGLTextureSubtarget.ASTC;
EditorUserBuildSettings.webGLBuildSubtarget = WebGLTextureSubtarget.ASTC;
buildPlayerOptions.scenes = scenes;
buildPlayerOptions.target = buildTarget;
buildPlayerOptions.locationPathName = filePath;
BuildPipeline.BuildPlayer(buildPlayerOptions);