From 65983021aae0ba5e46888f584aa340bf92a048b6 Mon Sep 17 00:00:00 2001 From: Beast-ofcourse Date: Tue, 7 Jul 2026 13:06:05 +0530 Subject: [PATCH] fix(manage_build): stop forcing PVRTC texture compression on Android via subtarget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When manage_build builds for Android, BuildPlayerOptions.subtarget was always set to StandaloneBuildSubtarget.Player (0). On Android, subtarget maps to MobileTextureSubtarget (texture compression format). Building with subtarget=0 on Unity 6000+ triggers a confirmed Unity bug (IN-102413) that forces PVRTC texture compression — ignoring the project's Player Settings (ASTC/ETC2). Worse: setting subtarget persists the value in EditorUserBuildSettings, overwriting whatever the user configured in Build Settings. Fix: only set subtarget for Standalone platforms (Windows/OSX/Linux), where it distinguishes Server vs Player builds. For all other platforms (Android, iOS, tvOS, WebGL, etc.), leave subtarget at its default so Unity respects the project's Player Settings. Fixes #1212 --- MCPForUnity/Editor/Tools/Build/BuildRunner.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/MCPForUnity/Editor/Tools/Build/BuildRunner.cs b/MCPForUnity/Editor/Tools/Build/BuildRunner.cs index 2d4c75c6d..baed78da6 100644 --- a/MCPForUnity/Editor/Tools/Build/BuildRunner.cs +++ b/MCPForUnity/Editor/Tools/Build/BuildRunner.cs @@ -49,15 +49,30 @@ public static BuildPlayerOptions CreateBuildOptions( BuildOptions buildOptions, int subtarget) { - return new BuildPlayerOptions + var options = new BuildPlayerOptions { target = target, targetGroup = BuildTargetMapping.GetTargetGroup(target), locationPathName = outputPath, scenes = scenes ?? GetDefaultScenes(), options = buildOptions, - subtarget = subtarget }; + + // Subtarget is only meaningful for Standalone (Server vs Player). + // On Android/iOS it maps to MobileTextureSubtarget (texture compression format). + // Passing StandaloneBuildSubtarget.Player (0) for mobile platforms forces + // a specific texture format — confirmed Unity bug IN-102413 where value 0 + // on Unity 6000+ triggers PVRTC, ignoring Player Settings. + // Leave at platform default (0) so Unity respects Player Settings. + if (target == BuildTarget.StandaloneWindows + || target == BuildTarget.StandaloneWindows64 + || target == BuildTarget.StandaloneOSX + || target == BuildTarget.StandaloneLinux64) + { + options.subtarget = subtarget; + } + + return options; } public static BuildOptions ParseBuildOptions(string[] optionNames, bool development)