Exclude Android release metadata and record emulator audio

This commit is contained in:
NINI
2026-10-05 03:22:04 +09:00
parent 0b43d45865
commit d656efe0dc
10 changed files with 191 additions and 14 deletions
@@ -0,0 +1,38 @@
using System.IO;
using System.Linq;
using System.Xml;
using UnityEditor;
using UnityEditor.Android;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
namespace MagnetismHeroes.Editor
{
public sealed class AndroidBuildSanitizer : IPreprocessBuildWithReport, IPostGenerateGradleAndroidProject
{
public int callbackOrder => int.MaxValue;
public void OnPreprocessBuild(BuildReport report)
{
if (report.summary.platform != BuildTarget.Android || (report.summary.options & BuildOptions.IncludeTestAssemblies) != 0) return;
foreach (string path in new[] { "Assets/Resources/PerformanceTestRunInfo.json", "Assets/Resources/PerformanceTestRunSettings.json" })
if (File.Exists(path)) AssetDatabase.DeleteAsset(path);
if (Directory.Exists("Assets/Resources") && !Directory.EnumerateFileSystemEntries("Assets/Resources").Any())
AssetDatabase.DeleteAsset("Assets/Resources");
Debug.Log("[AndroidBuild] Generated performance-test metadata excluded from release assets.");
}
public void OnPostGenerateGradleAndroidProject(string path)
{
string manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");
var manifest = new XmlDocument(); manifest.Load(manifestPath);
var namespaces = new XmlNamespaceManager(manifest.NameTable);
namespaces.AddNamespace("android", "http://schemas.android.com/apk/res/android");
foreach (XmlNode permission in manifest.SelectNodes("/manifest/uses-permission[@android:name='android.permission.INTERNET']", namespaces))
permission.ParentNode.RemoveChild(permission);
manifest.Save(manifestPath);
Debug.Log("[AndroidBuild] Offline manifest: generated INTERNET permission removed.");
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5c950257c624bf444a68a989a14c7118
@@ -90,8 +90,11 @@ namespace MagnetismHeroes.Editor
});
Debug.Log($"[AndroidBuild] {report.summary.result}: {report.summary.totalSize} bytes, {report.summary.totalErrors} errors.");
if (report.summary.result != BuildResult.Succeeded) throw new InvalidOperationException("Android build did not succeed.");
File.WriteAllLines(apkPath + ".packed-assets.txt", report.packedAssets
.SelectMany(asset => asset.contents).Select(asset => asset.sourceAssetPath).Distinct().OrderBy(path => path));
var packedPaths = report.packedAssets.SelectMany(asset => asset.contents)
.Select(asset => asset.sourceAssetPath).Distinct().OrderBy(path => path).ToArray();
File.WriteAllLines(apkPath + ".packed-assets.txt", packedPaths);
if (packedPaths.Any(path => path.Contains("PerformanceTestRun")))
throw new InvalidOperationException("Generated performance-test metadata entered the release APK.");
}
}
}
@@ -379,6 +379,9 @@ MonoBehaviour:
highQualityFiltering:
m_OverrideState: 1
m_Value: 0
filter:
m_OverrideState: 1
m_Value: 0
downscale:
m_OverrideState: 1
m_Value: 0
+14 -10
View File
@@ -84,6 +84,7 @@ MonoBehaviour:
m_SupportScreenSpaceLensFlare: 1
m_GPUResidentDrawerMode: 0
m_SmallMeshScreenPercentage: 0
m_ShadowSmallMeshScreenPercentages: {x: 0, y: 0, z: 0, w: 0}
m_GPUResidentDrawerEnableOcclusionCullingInCameras: 0
m_ShadowType: 1
m_LocalShadowsSupported: 0
@@ -100,26 +101,26 @@ MonoBehaviour:
m_Keys: []
m_Values:
m_PrefilteringModeMainLightShadows: 3
m_PrefilteringModeAdditionalLight: 4
m_PrefilteringModeAdditionalLight: 3
m_PrefilteringModeAdditionalLightShadows: 0
m_PrefilterXRKeywords: 1
m_PrefilteringModeForwardPlus: 1
m_PrefilteringModeForwardPlus: 0
m_PrefilteringModeDeferredRendering: 0
m_PrefilteringModeScreenSpaceOcclusion: 0
m_PrefilteringModeScreenSpaceReflection: 1
m_PrefilteringModeScreenSpaceReflection: 0
m_PrefilterWriteSmoothness: 1
m_PrefilterDebugKeywords: 1
m_PrefilterWriteRenderingLayers: 1
m_PrefilterHDROutput: 1
m_PrefilterAlphaOutput: 0
m_PrefilterAlphaOutput: 1
m_PrefilterSSAODepthNormals: 1
m_PrefilterSSAOSourceDepthLow: 1
m_PrefilterSSAOSourceDepthMedium: 0
m_PrefilterSSAOSourceDepthMedium: 1
m_PrefilterSSAOSourceDepthHigh: 1
m_PrefilterSSAOInterleaved: 0
m_PrefilterSSAOInterleaved: 1
m_PrefilterSSAOBlueNoise: 1
m_PrefilterSSAOSampleCountLow: 1
m_PrefilterSSAOSampleCountMedium: 0
m_PrefilterSSAOSampleCountMedium: 1
m_PrefilterSSAOSampleCountHigh: 1
m_PrefilterDBufferMRT1: 1
m_PrefilterDBufferMRT2: 1
@@ -129,14 +130,17 @@ MonoBehaviour:
m_PrefilterSoftShadowsQualityHigh: 1
m_PrefilterSoftShadows: 0
m_PrefilterScreenCoord: 1
m_PrefilterScreenSpaceIrradiance: 0
m_PrefilterScreenSpaceIrradiance: 1
m_PrefilterNativeRenderPass: 1
m_PrefilterUseLegacyLightmaps: 0
m_PrefilterBicubicLightmapSampling: 0
m_PrefilterBicubicLightmapSampling: 1
m_PrefilterReflectionProbeRotation: 0
m_PrefilterReflectionProbeBlending: 0
m_PrefilterReflectionProbeBoxProjection: 0
m_PrefilterReflectionProbeAtlas: 0
m_PrefilterReflectionProbeAtlas: 1
m_PrefilterPointSamplingUpsampling: 1
m_Light2DPrefilteringMode: 0
m_Light2DKeptVariantCombos: []
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 0
m_Textures:
@@ -72,7 +72,21 @@ MonoBehaviour:
- rid: 6588237625532874761
- rid: 6588237625532874762
m_RuntimeSettings:
m_List: []
m_List:
- rid: 6852985685364965378
- rid: 6852985685364965380
- rid: 6852985685364965381
- rid: 6852985685364965384
- rid: 6852985685364965392
- rid: 6852985685364965394
- rid: 8712630790384254976
- rid: 4284062438471237637
- rid: 5747374308340793348
- rid: 6588237625532874753
- rid: 6588237625532874756
- rid: 6588237625532874757
- rid: 6588237625532874759
- rid: 6588237625532874761
m_AssetVersion: 11
m_ObsoleteDefaultVolumeProfile: {fileID: 0}
m_RenderingLayerNames: