From 6d17f595b24c6732e3c4581e64484095710afbea Mon Sep 17 00:00:00 2001 From: huyufei Date: Fri, 22 Mar 2024 13:20:54 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=20Debugger=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3,=20=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.Callback.cs | 11 ++- Runtime/Code/SDK/GuruSDK.Debugger.cs | 87 +++++++++++++++++++++++ Runtime/Code/SDK/GuruSDK.Debugger.cs.meta | 3 + Runtime/Code/SDK/GuruSDK.Properties.cs | 8 ++- Runtime/Code/SDK/GuruSDK.cs | 13 +++- 5 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 Runtime/Code/SDK/GuruSDK.Debugger.cs create mode 100644 Runtime/Code/SDK/GuruSDK.Debugger.cs.meta diff --git a/Runtime/Code/SDK/GuruSDK.Callback.cs b/Runtime/Code/SDK/GuruSDK.Callback.cs index 1d2d5e6..73b2eec 100644 --- a/Runtime/Code/SDK/GuruSDK.Callback.cs +++ b/Runtime/Code/SDK/GuruSDK.Callback.cs @@ -188,8 +188,15 @@ namespace Guru add => _onGuruServiceReady += value; remove => _onGuruServiceReady -= value; } - - + + internal static Action _onDebuggerDisplayed; + public static event Action OnDisplayDebugger + { + add => _onDebuggerDisplayed += value; + remove => _onDebuggerDisplayed -= value; + } + + } } diff --git a/Runtime/Code/SDK/GuruSDK.Debugger.cs b/Runtime/Code/SDK/GuruSDK.Debugger.cs new file mode 100644 index 0000000..f6d33bf --- /dev/null +++ b/Runtime/Code/SDK/GuruSDK.Debugger.cs @@ -0,0 +1,87 @@ +namespace Guru +{ + using UnityEngine; + + public partial class GuruSDK + { + private static bool _isDebuggerInited = false; + + /// + /// 显示 Debugger + /// + /// + public static bool ShowDebugger() + { + if (IsServiceReady) + { + InitDebuggerLayout(); + + return true; + } + return false; + } + + private static void InitDebuggerLayout() + { + var settings = GuruSettings.Instance; + var v = GuruAppVersion.Load(); + var app_version = (v == null ? $"{Application.version} (unknown)" : $"{v.version} ({v.code})"); + var uid = (string.IsNullOrEmpty(UID) ? "NULL" : UID); + var device_id = (string.IsNullOrEmpty(DeviceId) ? "NULL" : DeviceId); + var push_token = (string.IsNullOrEmpty(PushToken) ? "NULL" : PushToken); + var auth_token = (string.IsNullOrEmpty(AuthToken) ? "NULL" : AuthToken); + var fid = (string.IsNullOrEmpty(FireabseId) ? "NULL" : FireabseId); + var adjust_id = (string.IsNullOrEmpty(AdjustId) ? "NULL" : AdjustId); + var idfa = (string.IsNullOrEmpty(IDFA) ? "NULL" : IDFA); + var gsid = (string.IsNullOrEmpty(GSADID) ? "NULL" : GSADID); + + // ------------ Info Page -------------------- + Debugger.Instance.AddOption("Info/Guru SDK", GuruSDK.Version); + Debugger.Instance.AddOption("Info/Unity Version", Application.unityVersion); + Debugger.Instance.AddOption("Info/Name", settings.ProductName); + Debugger.Instance.AddOption("Info/Bundle Id", settings.GameIdentifier); + Debugger.Instance.AddOption("Info/Version", app_version); + Debugger.Instance.AddOption("Info/Uid", uid).AddCopyButton(); + Debugger.Instance.AddOption("Info/Device ID", device_id).AddCopyButton(); + Debugger.Instance.AddOption("Info/Push Token", push_token).AddCopyButton(); + Debugger.Instance.AddOption("Info/Auth Token", auth_token).AddCopyButton(); + Debugger.Instance.AddOption("Info/Firebase Id", fid).AddCopyButton(); + Debugger.Instance.AddOption("Info/Adjust Id", adjust_id).AddCopyButton(); + Debugger.Instance.AddOption("Info/IDFA", idfa).AddCopyButton(); + Debugger.Instance.AddOption("Info/GSADID", gsid).AddCopyButton(); + Debugger.Instance.AddOption("Info/Debug Mode", GuruSDK.IsDebugMode? "true" : "false"); + Debugger.Instance.AddOption("Info/Screen size", $"{Screen.width} x {Screen.height}"); + + + // ------------ Ads Page -------------------- + Debugger.Instance.AddOption("Ads/Show Ads Debug Panel", "", ShowMaxDebugPanel); + + var badsId = settings.ADSetting.GetBannerID(); + var iadsId = settings.ADSetting.GetInterstitialID(); + var radsId = settings.ADSetting.GetRewardedVideoID(); + + Debugger.Instance.AddOption("Ads/Banner Id", badsId); + Debugger.Instance.AddOption("Ads/Interstitial Id", iadsId); + Debugger.Instance.AddOption("Ads/Rewarded Id", radsId); + + + Debugger.Show(); // 显示 Debugger 界面 + Debugger.OnClosed -= OnDebuggerClosed; + Debugger.OnClosed += OnDebuggerClosed; + Callbacks.SDK._onDebuggerDisplayed?.Invoke(true); + } + + + private static void OnDebuggerClosed() + { + Debugger.OnClosed -= OnDebuggerClosed; + Callbacks.SDK._onDebuggerDisplayed?.Invoke(false); + } + + + + + + + } +} \ No newline at end of file diff --git a/Runtime/Code/SDK/GuruSDK.Debugger.cs.meta b/Runtime/Code/SDK/GuruSDK.Debugger.cs.meta new file mode 100644 index 0000000..a03dbcf --- /dev/null +++ b/Runtime/Code/SDK/GuruSDK.Debugger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 002605b9e408487bb69d27d07dda016c +timeCreated: 1711078536 \ No newline at end of file diff --git a/Runtime/Code/SDK/GuruSDK.Properties.cs b/Runtime/Code/SDK/GuruSDK.Properties.cs index d053530..9d577e8 100644 --- a/Runtime/Code/SDK/GuruSDK.Properties.cs +++ b/Runtime/Code/SDK/GuruSDK.Properties.cs @@ -5,9 +5,8 @@ namespace Guru public static string UID => _model?.UserId ?? IPMConfig.IPM_UID; public static string DeviceId => IPMConfig.IPM_DEVICE_ID ?? ""; // TODO: change it to _model member later. - public static string PushToken => IPMConfig.IPM_PUSH_TOKEN ?? ""; // TODO: change it to _model member later. - + public static string AuthToken => IPMConfig.IPM_TOKEN ?? ""; // TODO: change it to _model member later. public static string SupportEmail => GuruSettings.SupportEmail ?? ""; public static string StoreUrl @@ -33,6 +32,11 @@ namespace Guru public static string AppVersionString => GuruAppVersion.ToString(); public static bool IsNewUser => IPMConfig.IPM_NEWUSER; + + public static string FireabseId => IPMConfig.FIREBASE_ID; + public static string IDFA => IPMConfig.ADJUST_IDFA; + public static string AdjustId => IPMConfig.ADJUST_ID; + public static string GSADID => IPMConfig.ADJUST_ADID; private static GuruAppVersion _appVersion; diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index 0da4e6b..5b4f7c4 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -67,9 +67,14 @@ namespace Guru /// 初始化成功标志位 /// public static bool IsInitialSuccess { get; private set; } = false; - - + /// + /// Firebase 就绪标志位 + /// public static bool IsFirebaseReady { get; private set; } = false; + /// + /// 服务就绪标志位 + /// + public static bool IsServiceReady { get; private set; } = false; #region 初始化 @@ -334,9 +339,13 @@ namespace Guru Debug.LogError($"--- ERROR on StartConsentFlow: {ex.Message}"); }); } + + IsServiceReady = true; // 中台服务初始化结束 Callbacks.SDK._onGuruServiceReady?.Invoke(); + + } ///