【打包】根据Channels更改设置

main
zhangaotian 2024-07-31 14:20:52 +08:00
parent 2f67012da7
commit 3efb62bfbf
15 changed files with 68 additions and 14 deletions

View File

@ -189,24 +189,48 @@ internal class BatchBuild
private static bool _hasYooAsset;
private const string DefineListKey = "Define_list:";
private const string PackageNameKey = "PackageName:";
private const string NewPlayerSettingsPath = "/../PlayerSettings.txt";
//[MenuItem("Tools/Modify Settings from Text File")]
private static void _InitScriptDefines()
{
var hasYooAsset = false;
// 判断本地是否有define_list.txt文件
var defineListPath = Application.dataPath + "/../define_list.txt";
var filePath = Application.dataPath + NewPlayerSettingsPath;
var appendDefineList = new List<string>();
if (File.Exists(defineListPath))
string newPackageName = "";
if (File.Exists(filePath))
{
var defineList = System.IO.File.ReadAllLines(defineListPath);
foreach (var define in defineList)
var fileContents = System.IO.File.ReadAllText(filePath);
string[] lines = fileContents.Split('\n');
foreach (var line in lines)
{
if (string.IsNullOrEmpty(define))
continue;
appendDefineList.Add(define);
Debug.Log("追加宏定义:" + define);
if (define == "USE_YOO")
if (line.StartsWith(DefineListKey))
{
hasYooAsset = true;
// 解析宏定义
var prefixLength = DefineListKey.Length;
string definePart = line.Substring(prefixLength).Trim(); // 去掉 "definde:" 后的部分
string[] defines = definePart.Split(',');
foreach (var define in defines)
{
string cleanDefine = define.Trim(new char[] { '"', ' ', '\r', '\n' });
if (!string.IsNullOrEmpty(cleanDefine))
{
appendDefineList.Add(cleanDefine);
Debug.Log("追加宏定义:" + cleanDefine);
}
}
}
else if (line.StartsWith(PackageNameKey))
{
// 解析包名
var prefixLength = PackageNameKey.Length;
newPackageName = line.Substring(prefixLength).Trim();
Debug.Log("设置新包名:" + newPackageName);
}
}
}
@ -236,6 +260,12 @@ internal class BatchBuild
newDefineList.AddRange(appendDefineList);
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTargetGroup, string.Join(";", newDefineList));
}
//只有安卓平台下修改
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android && !string.IsNullOrEmpty(newPackageName))
{
PlayerSettings.applicationIdentifier = newPackageName;
//PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, newPackageName);
}
// 现已修改为使用YooAsset
_hasYooAsset = hasYooAsset;

View File

@ -0,0 +1,4 @@
Define_list:"CHANNEL_AUDIO_TEST"
PackageName:

View File

@ -1 +0,0 @@
CHANNEL_AUDIO_TEST

View File

@ -0,0 +1,4 @@
Define_list:
PackageName:"com.phxh.banshu.nld"

View File

@ -0,0 +1,4 @@
Define_list:
PackageName:"com.phxh.dev.nld"

View File

@ -0,0 +1,4 @@
Define_list:"USE_YOO"
PackageName:"com.phxh.devyoo.nld"

View File

@ -1 +0,0 @@
USE_YOO

View File

@ -0,0 +1,4 @@
Define_list:
PackageName:"com.phxh.stabledev.nld"

View File

@ -0,0 +1,4 @@
Define_list:"SDK_TAPTAP","SDK_CRASHSIGHT"
PackageName:"com.phxh.taptap.nld"

View File

@ -1,2 +0,0 @@
SDK_TAPTAP
SDK_CRASHSIGHT

View File

@ -0,0 +1,4 @@
Define_list:
PackageName:"com.phxh.wanmei.nld"