| 
									
										
										
										
											2024-04-15 05:36:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  | namespace Guru | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     using UnityEngine; | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |     using System; | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  |      | 
					
						
							|  |  |  |     public partial class GuruSDK | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2024-07-31 04:56:01 +00:00
										 |  |  |         private static readonly bool _useBaseOptions = true; | 
					
						
							| 
									
										
										
										
											2024-04-15 05:36:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |         private static GuruDebugger _debugger; | 
					
						
							| 
									
										
										
										
											2024-04-15 05:36:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |         public static GuruDebugger Debugger | 
					
						
							| 
									
										
										
										
											2024-04-15 05:36:14 +00:00
										 |  |  |         { | 
					
						
							|  |  |  |             get | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |                 if (_debugger == null) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     _debugger = GuruDebugger.Instance; | 
					
						
							| 
									
										
										
										
											2024-07-31 04:56:01 +00:00
										 |  |  |                     if (_useBaseOptions) | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |                     { | 
					
						
							|  |  |  |                         InitDebuggerLayout(); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-04-15 05:36:14 +00:00
										 |  |  |                 return _debugger; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |          | 
					
						
							|  |  |  |         /// <summary> | 
					
						
							|  |  |  |         /// 显示广告状态 | 
					
						
							|  |  |  |         /// </summary> | 
					
						
							|  |  |  |         public static bool ShowAdStatus() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (!IsServiceReady) return false; | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |             Debugger.ShowAdStatus(); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-07-31 04:56:01 +00:00
										 |  |  |          | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  |         /// <summary> | 
					
						
							|  |  |  |         /// 显示 Debugger | 
					
						
							|  |  |  |         /// </summary> | 
					
						
							|  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |         public static bool ShowDebugger() | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |             if (!IsServiceReady) return false; | 
					
						
							| 
									
										
										
										
											2024-04-10 07:59:59 +00:00
										 |  |  |              | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |             Debugger.ShowPage(); // 显示 Debugger 界面 | 
					
						
							| 
									
										
										
										
											2024-04-10 07:59:59 +00:00
										 |  |  |             return true; | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         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); | 
					
						
							| 
									
										
										
										
											2024-06-03 09:25:05 +00:00
										 |  |  |             var fid = (string.IsNullOrEmpty(FirebaseId) ? "NULL" : FirebaseId); | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  |             var adjust_id = (string.IsNullOrEmpty(AdjustId) ? "NULL" : AdjustId); | 
					
						
							|  |  |  |             var idfa = (string.IsNullOrEmpty(IDFA) ? "NULL" : IDFA); | 
					
						
							|  |  |  |             var gsid = (string.IsNullOrEmpty(GSADID) ? "NULL" : GSADID); | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |             // ------------ Info Page -------------------- | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |             Debugger.AddOption("Info/Guru SDK", GuruSDK.Version); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Unity Version", Application.unityVersion); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Name", settings.ProductName); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Bundle Id", settings.GameIdentifier); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Version", app_version); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Uid", uid).AddCopyButton(); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Device ID", device_id).AddCopyButton(); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Push Token", push_token).AddCopyButton(); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Auth Token", auth_token).AddCopyButton(); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Firebase Id", fid).AddCopyButton(); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Adjust Id", adjust_id).AddCopyButton(); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/IDFA", idfa).AddCopyButton(); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/GSADID", gsid).AddCopyButton(); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Debug Mode", GuruSDK.IsDebugMode? "true" : "false"); | 
					
						
							|  |  |  |             Debugger.AddOption("Info/Screen size", $"{Screen.width} x {Screen.height}"); | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  |              | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |             // ------------ Ads Page -------------------- | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |             Debugger.AddOption("Ads/Show Ads Debug Panel", "", ShowMaxDebugPanel); | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             var badsId = settings.ADSetting.GetBannerID(); | 
					
						
							|  |  |  |             var iadsId = settings.ADSetting.GetInterstitialID(); | 
					
						
							|  |  |  |             var radsId = settings.ADSetting.GetRewardedVideoID(); | 
					
						
							|  |  |  |              | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |             Debugger.AddOption("Ads/Banner Id", badsId); | 
					
						
							|  |  |  |             Debugger.AddOption("Ads/Interstitial Id", iadsId); | 
					
						
							|  |  |  |             Debugger.AddOption("Ads/Rewarded Id", radsId); | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  |              | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |             GuruDebugger.OnClosed -= OnDebuggerClosed; | 
					
						
							|  |  |  |             GuruDebugger.OnClosed += OnDebuggerClosed; | 
					
						
							| 
									
										
										
										
											2024-07-31 04:56:01 +00:00
										 |  |  |             Callbacks.SDK.InvokeOnDebuggerDisplayed(true); | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |          | 
					
						
							|  |  |  |         private static void OnDebuggerClosed() | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |             GuruDebugger.OnClosed -= OnDebuggerClosed; | 
					
						
							| 
									
										
										
										
											2024-07-31 04:56:01 +00:00
										 |  |  |             Callbacks.SDK.InvokeOnDebuggerDisplayed(false); | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-07-31 04:56:01 +00:00
										 |  |  |          | 
					
						
							| 
									
										
										
										
											2024-04-10 07:59:59 +00:00
										 |  |  |         /// <summary> | 
					
						
							|  |  |  |         /// 显示 Debugger | 
					
						
							|  |  |  |         /// </summary> | 
					
						
							|  |  |  |         /// <param name="debugger"></param> | 
					
						
							|  |  |  |         /// <returns></returns> | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |         public static bool ShowDebuggerWithData(out GuruDebugger debugger) | 
					
						
							| 
									
										
										
										
											2024-04-10 07:59:59 +00:00
										 |  |  |         { | 
					
						
							|  |  |  |             debugger = null; | 
					
						
							|  |  |  |             bool res = ShowDebugger(); | 
					
						
							|  |  |  |             if (res) | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |                 debugger = GuruDebugger.Instance; | 
					
						
							| 
									
										
										
										
											2024-04-10 07:59:59 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |             return res; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-07 12:37:57 +00:00
										 |  |  |         public static GuruDebugger.OptionLayout AddOption(string uri, string content = "", Action clickHandler = null) | 
					
						
							| 
									
										
										
										
											2024-04-15 05:36:14 +00:00
										 |  |  |         { | 
					
						
							|  |  |  |             return Debugger.AddOption(uri, content, clickHandler); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-10 07:59:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-22 05:20:54 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } |