build(kv): 完善构建宏处理和本地测试服切换

This commit is contained in:
Liubing\LB
2026-10-13 20:39:03 +08:00
parent edb8a056c7
commit 1a81c331e3
3 changed files with 100 additions and 10 deletions

View File

@@ -631,9 +631,24 @@ public class BuildTool
{ {
var buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; var buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup, out string[] symbols); PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup, out string[] symbols);
if (symbols.Contains(dfs)) return;
var newDefines = new List<string>(symbols); var newDefines = new List<string>(symbols);
newDefines.Add(dfs); var changed = false;
foreach (var symbol in dfs.Split(';'))
{
if (string.IsNullOrEmpty(symbol))
{
continue;
}
if (!newDefines.Contains(symbol))
{
newDefines.Add(symbol);
changed = true;
}
}
if (!changed)
{
return;
}
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Join(";", newDefines.ToArray())); PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Join(";", newDefines.ToArray()));
} }
@@ -641,9 +656,24 @@ public class BuildTool
{ {
var buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; var buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup, out string[] symbols); PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup, out string[] symbols);
if (!symbols.Contains(dfs)) return;
var newDefines = new List<string>(symbols); var newDefines = new List<string>(symbols);
newDefines.Remove(dfs); var changed = false;
foreach (var symbol in dfs.Split(';'))
{
if (string.IsNullOrEmpty(symbol))
{
continue;
}
if (newDefines.Contains(symbol))
{
newDefines.Remove(symbol);
changed = true;
}
}
if (!changed)
{
return;
}
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Join(";", newDefines.ToArray())); PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Join(";", newDefines.ToArray()));
} }

View File

@@ -25,6 +25,7 @@ public class DebugConfig
private const string s101StaicResUrl = "http://s101.local:8080/{0}"; private const string s101StaicResUrl = "http://s101.local:8080/{0}";
private const string s101AddrUrl = "http://s101.local:8080/{0}/{1}"; private const string s101AddrUrl = "http://s101.local:8080/{0}/{1}";
private const string s101EventAPIUrl = "http://s101.local:18080/"; private const string s101EventAPIUrl = "http://s101.local:18080/";
private const string localTestEventAPIUrl = "http://172.16.69.228:8080/";
private const string s101RTMPid = "80000560"; private const string s101RTMPid = "80000560";
private const string s101RTMServerEndpoint = "rtm-nx-front.ilivedata.com:13321"; private const string s101RTMServerEndpoint = "rtm-nx-front.ilivedata.com:13321";
private const string s101RTMHmacSecret = "7a1ba6bb85a4473d96fa4bf45b01f1dd"; private const string s101RTMHmacSecret = "7a1ba6bb85a4473d96fa4bf45b01f1dd";
@@ -97,10 +98,15 @@ public class DebugConfig
public static bool MustaphSvrValidation() public static bool MustaphSvrValidation()
{ {
var config = Config; var config = Config;
if (config != null && config.StaticResURL == string.Format(mustaphaStaicResUrl, VersionTool.PackVer)) if (config != null && config.StaticResURL == string.Format(mustaphaStaicResUrl, VersionTool.PackVer) &&
config.EventApiURL == mustaphaEventAPIUrl)
{
Menu.SetChecked("Tools/Debug/Mustaph Svr", true); Menu.SetChecked("Tools/Debug/Mustaph Svr", true);
}
else else
{
Menu.SetChecked("Tools/Debug/Mustaph Svr", false); Menu.SetChecked("Tools/Debug/Mustaph Svr", false);
}
return true; return true;
} }
@@ -125,10 +131,15 @@ public class DebugConfig
public static bool LiubingSvrValidation() public static bool LiubingSvrValidation()
{ {
var config = Config; var config = Config;
if (config != null && config.StaticResURL == string.Format(liubingStaicResUrl, VersionTool.PackVer)) if (config != null && config.StaticResURL == string.Format(liubingStaicResUrl, VersionTool.PackVer) &&
config.EventApiURL == liubingEventAPIUrl)
{
Menu.SetChecked("Tools/Debug/Liubing Svr", true); Menu.SetChecked("Tools/Debug/Liubing Svr", true);
}
else else
{
Menu.SetChecked("Tools/Debug/Liubing Svr", false); Menu.SetChecked("Tools/Debug/Liubing Svr", false);
}
return true; return true;
} }
@@ -156,10 +167,49 @@ public class DebugConfig
public static bool Svr101Validation() public static bool Svr101Validation()
{ {
var config = Config; var config = Config;
if (config != null && config.StaticResURL == string.Format(s101StaicResUrl, VersionTool.PackVer)) if (config != null && config.StaticResURL == string.Format(s101StaicResUrl, VersionTool.PackVer) &&
config.EventApiURL == s101EventAPIUrl)
{
Menu.SetChecked("Tools/Debug/Svr 101", true); Menu.SetChecked("Tools/Debug/Svr 101", true);
}
else else
{
Menu.SetChecked("Tools/Debug/Svr 101", false); Menu.SetChecked("Tools/Debug/Svr 101", false);
}
return true;
}
[MenuItem("Tools/Debug/Svr Local 172.16.69.228")]
public static void SvrLocal()
{
Newtonsoft.Json.Linq.JObject config;
if (File.Exists(DebugConfigPath))
{
config = Newtonsoft.Json.Linq.JObject.Parse(File.ReadAllText(DebugConfigPath));
}
else
{
config = Newtonsoft.Json.Linq.JObject.FromObject(new TmpClas
{
EventApiURL = s101EventAPIUrl,
StaticResURL = string.Format(s101StaicResUrl, VersionTool.PackVer),
Custom_Addressable_URL = string.Format(s101AddrUrl, VersionTool.PackVer, EditorUserBuildSettings.activeBuildTarget),
RTMPid = s101RTMPid,
RTMServerEndpoint = s101RTMServerEndpoint,
RTMHmacSecret = s101RTMHmacSecret,
FuncUrl = s101FuncUrl,
FuncKey = s101FuncKey
});
}
config["EventApiURL"] = localTestEventAPIUrl;
File.WriteAllText(DebugConfigPath, config.ToString(Formatting.Indented));
}
[MenuItem("Tools/Debug/Svr Local 172.16.69.228", true)]
public static bool SvrLocalValidation()
{
var config = Config;
Menu.SetChecked("Tools/Debug/Svr Local 172.16.69.228", config != null && config.EventApiURL == localTestEventAPIUrl);
return true; return true;
} }
@@ -208,10 +258,15 @@ public class DebugConfig
public static bool SvrDevValidation() public static bool SvrDevValidation()
{ {
var config = Config; var config = Config;
if (config != null && config.StaticResURL == string.Format(devStaicResUrl, VersionTool.PackVer)) if (config != null && config.StaticResURL == string.Format(devStaicResUrl, VersionTool.PackVer) &&
config.EventApiURL == devEventAPIUrl)
{
Menu.SetChecked("Tools/Debug/Svr Dev", true); Menu.SetChecked("Tools/Debug/Svr Dev", true);
}
else else
{
Menu.SetChecked("Tools/Debug/Svr Dev", false); Menu.SetChecked("Tools/Debug/Svr Dev", false);
}
return true; return true;
} }
@@ -243,10 +298,15 @@ public class DebugConfig
public static bool SvrTimeshiftValidation() public static bool SvrTimeshiftValidation()
{ {
var config = Config; var config = Config;
if (config != null && config.StaticResURL == string.Format(timeShiftStaicResUrl, VersionTool.PackVer)) if (config != null && config.StaticResURL == string.Format(timeShiftStaicResUrl, VersionTool.PackVer) &&
config.EventApiURL == timeShiftEventAPIUrl)
{
Menu.SetChecked("Tools/Debug/Svr timeshift", true); Menu.SetChecked("Tools/Debug/Svr timeshift", true);
}
else else
{
Menu.SetChecked("Tools/Debug/Svr timeshift", false); Menu.SetChecked("Tools/Debug/Svr timeshift", false);
}
return true; return true;
} }

View File

@@ -881,7 +881,7 @@ PlayerSettings:
webGLMemoryGeometricGrowthCap: 96 webGLMemoryGeometricGrowthCap: 96
webGLPowerPreference: 2 webGLPowerPreference: 2
scriptingDefineSymbols: scriptingDefineSymbols:
Android: UNITY_POST_PROCESSING_STACK_V2;CREST_OCEAN;RTM_BUILD_NO_AUDIO;ACTK_WALLHACK_LINK_XML Android: UNITY_POST_PROCESSING_STACK_V2;CREST_OCEAN;RTM_BUILD_NO_AUDIO;ACTK_WALLHACK_LINK_XML;USE_KV
Bratwurst: UNITY_POST_PROCESSING_STACK_V2 Bratwurst: UNITY_POST_PROCESSING_STACK_V2
EmbeddedLinux: UNITY_POST_PROCESSING_STACK_V2;ACTK_WALLHACK_LINK_XML EmbeddedLinux: UNITY_POST_PROCESSING_STACK_V2;ACTK_WALLHACK_LINK_XML
GameCoreScarlett: ACTK_WALLHACK_LINK_XML GameCoreScarlett: ACTK_WALLHACK_LINK_XML