Merge remote-tracking branch 'origin/main_ZYT'

# Conflicts:
#	ProjectSettings/ProjectSettings.asset
This commit is contained in:
bzx
2025-10-14 18:19:40 +08:00
2 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
using System.IO;
using System.Text.RegularExpressions;
public class BuildPostProcessor : IPreprocessBuildWithReport
{
public int callbackOrder => 0;
public void OnPreprocessBuild(BuildReport report)
{
if (report.summary.platform == BuildTarget.Android)
{
UpdateAndroidManifest();
}
}
private void UpdateAndroidManifest()
{
string manifestPath = Path.Combine(Application.dataPath, "Plugins/Android/AndroidManifest.xml");
if (File.Exists(manifestPath))
{
string manifestContent = File.ReadAllText(manifestPath);
string packageName = PlayerSettings.applicationIdentifier;
// 使用正则表达式匹配并替换 android:path 的值
string updatedContent = Regex.Replace(manifestContent,
@"android:path=""[^""]*""",
$"android:path=\"/{packageName}\"");
File.WriteAllText(manifestPath, updatedContent);
Debug.Log($"Updated AndroidManifest.xml with package name: {packageName}");
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3b29ebf83515d49458a1a6d40986df59
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: