From 18cd3bc412b924e60390e96182a1f2046a48d5ed Mon Sep 17 00:00:00 2001 From: liutao <821580467@qq.com> Date: Wed, 18 Mar 2026 19:05:23 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8F=8D=E7=A0=B4=E8=A7=A3=E3=80=91cr?= =?UTF-8?q?ash=20sight=20=E5=92=8C=20BI=20Key=20=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Editor/Common/BuildLauncher.cs | 37 +++++++++++++++---- ProjectNLD/Assets/PhxhSDK | 2 +- .../CrashSight/CrashSightSdkHelper.cs | 17 ++------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/ProjectNLD/Assets/Editor/Common/BuildLauncher.cs b/ProjectNLD/Assets/Editor/Common/BuildLauncher.cs index 78c663d219f..7dca197be96 100644 --- a/ProjectNLD/Assets/Editor/Common/BuildLauncher.cs +++ b/ProjectNLD/Assets/Editor/Common/BuildLauncher.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using Obfuz.Settings; using UnityEditor; using UnityEngine; @@ -58,6 +59,31 @@ internal class BatchBuild /// Release上传地址 /// private const string Release_PostUrl = "http://openapi.kedrgame.com/api/v1/"; + + private static void WriteEncryptedJsonResource(string resourceFileNameWithoutExtension, string json) + { + var resourcesPath = "Assets/Resources"; + var jsonPath = Path.Combine(resourcesPath, resourceFileNameWithoutExtension + ".json"); + var bytesPath = Path.Combine(resourcesPath, resourceFileNameWithoutExtension + ".bytes"); + + if (!Directory.Exists(resourcesPath)) + { + Directory.CreateDirectory(resourcesPath); + } + + if (File.Exists(jsonPath)) + { + File.Delete(jsonPath); + var metaPath = jsonPath + ".meta"; + if (File.Exists(metaPath)) + { + File.Delete(metaPath); + } + } + + var encryptedBytes = LocalInfoEncrypt.Encrypt(Encoding.UTF8.GetBytes(json)); + File.WriteAllBytes(bytesPath, encryptedBytes); + } public static void _RevertScriptDefines() { @@ -690,9 +716,8 @@ internal class BatchBuild key = config.CrashSight_Android.Key }; - var crashSightPath = "Assets/Resources/CrashSightData.json"; var json = JsonUtility.ToJson(crashSightData); - File.WriteAllText(crashSightPath, json); + WriteEncryptedJsonResource("CrashSightData", json); Debug.Log("CrashSight配置已保存:" + crashSightData.id + "|" + crashSightData.key); } @@ -706,9 +731,8 @@ internal class BatchBuild key = config.CrashSight_iOS.Key }; - var crashSightPath = "Assets/Resources/CrashSightData.json"; var json = JsonUtility.ToJson(crashSightData); - File.WriteAllText(crashSightPath, json); + WriteEncryptedJsonResource("CrashSightData", json); Debug.Log("CrashSight配置已保存:" + crashSightData.id + "|" + crashSightData.key); } @@ -720,9 +744,8 @@ internal class BatchBuild channel = config.TalkingData.channel }; - var talkingDataPath = "Assets/Resources/TalkingDataInitConfig.json"; var json = JsonUtility.ToJson(talkingDataInitTool); - File.WriteAllText(talkingDataPath, json); + WriteEncryptedJsonResource("TalkingDataInitConfig", json); Debug.Log("TalkingData配置已保存:" + talkingDataInitTool.appID + "|" + talkingDataInitTool.channel); } @@ -765,4 +788,4 @@ internal class BatchBuild Debug.LogError($"找不到渠道配置文件: {yamlPath}"); } } -} \ No newline at end of file +} diff --git a/ProjectNLD/Assets/PhxhSDK b/ProjectNLD/Assets/PhxhSDK index 32e6eecf4e5..5c492f8af5f 160000 --- a/ProjectNLD/Assets/PhxhSDK +++ b/ProjectNLD/Assets/PhxhSDK @@ -1 +1 @@ -Subproject commit 32e6eecf4e56684a4775c87c0e30a9c51ec403a2 +Subproject commit 5c492f8af5fa39a51a1ad8c21bc31c42755d286d diff --git a/Tool/sdk_packages/CrashSight/0.0.1/Assets/PhxhSDK/Phxh/SDKHelper/CrashSight/CrashSightSdkHelper.cs b/Tool/sdk_packages/CrashSight/0.0.1/Assets/PhxhSDK/Phxh/SDKHelper/CrashSight/CrashSightSdkHelper.cs index 498c375d110..2eb2ef713dc 100644 --- a/Tool/sdk_packages/CrashSight/0.0.1/Assets/PhxhSDK/Phxh/SDKHelper/CrashSight/CrashSightSdkHelper.cs +++ b/Tool/sdk_packages/CrashSight/0.0.1/Assets/PhxhSDK/Phxh/SDKHelper/CrashSight/CrashSightSdkHelper.cs @@ -44,21 +44,12 @@ namespace PhxhSDK } var appId = ""; - var loadJson = Resources.Load("CrashSightData"); - if (loadJson == null) + if (!EncryptedResourceLoader.TryLoadJson("CrashSightData", out var data)) { - DebugUtil.LogError("CrashSightSdkHelper", "CrashSightData.json not found"); - return; - } - try - { - var data = JsonUtility.FromJson(loadJson.text); - appId = data.id; - } catch (Exception e) - { - DebugUtil.LogError("CrashSightSdkHelper" + "CrashSightData.json parse error: " + e.Message); + DebugUtil.LogError("CrashSightSdkHelper", "CrashSightData resource load failed"); return; } + appId = data.id; if (!string.IsNullOrEmpty(appId)) { CrashSightAgent.InitWithAppId(appId); @@ -115,4 +106,4 @@ namespace PhxhSDK } } } -#endif \ No newline at end of file +#endif