From aeffbb3d0f4dfea25e56434d2169aa0acd83ed38 Mon Sep 17 00:00:00 2001 From: wuwenbo Date: Fri, 5 Jun 2026 11:56:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0steamid=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TH1_Logic/CrashSight/CrashSightManager.cs | 19 +++++++++++++++++++ .../TH1_Logic/Steam/SteamLobbyManager.cs | 1 + 2 files changed, 20 insertions(+) diff --git a/Unity/Assets/Scripts/TH1_Logic/CrashSight/CrashSightManager.cs b/Unity/Assets/Scripts/TH1_Logic/CrashSight/CrashSightManager.cs index 03c239576..6b9314a86 100644 --- a/Unity/Assets/Scripts/TH1_Logic/CrashSight/CrashSightManager.cs +++ b/Unity/Assets/Scripts/TH1_Logic/CrashSight/CrashSightManager.cs @@ -17,6 +17,7 @@ namespace Logic.CrashSight public static CrashSightManager Instance => new CrashSightManager(); private const string CrashSightDeviceIdFallbackKey = "TH1_CrashSightDeviceId"; private static string _runtimeFallbackDeviceId; + private static ulong _reportedSteamUserId; private CrashSightManager() { } public void Initialize() @@ -31,6 +32,24 @@ namespace Logic.CrashSight CrashSightAgent.SetUserValue("DeviceId", deviceId); } + public static void UpdateSteamUserId(ulong steamUserId) + { + if (steamUserId == 0 || !CrashSightAgent.IsInitialized || _reportedSteamUserId == steamUserId) return; + + try + { + var value = steamUserId.ToString(); + CrashSightAgent.SetUserId(value); + CrashSightAgent.SetUserValue("SteamId", value); + CrashSightAgent.SetUserValue("MemberId", value); + _reportedSteamUserId = steamUserId; + } + catch (System.Exception e) + { + Debug.LogWarning($"CrashSight SetSteamUserId failed: {e.Message}"); + } + } + public static string GetCrashSightDeviceId() { try diff --git a/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs b/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs index dbcf5cf69..22d7fbac9 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Steam/SteamLobbyManager.cs @@ -371,6 +371,7 @@ namespace TH1_Logic.Steam { if (!TrySteamApi("RefreshLoginStatus.GetSteamID", SteamUser.GetSteamID, out _selfID)) return; if (!TrySteamApi("RefreshLoginStatus.GetPersonaName", SteamFriends.GetPersonaName, out _selfName)) return; + CrashSightManager.UpdateSteamUserId(_selfID.m_SteamID); LogSystem.LogInfo($"Steam用户已登录: {_selfName} ({_selfID})"); } else