using asap.core; using game; using GameCore; using IngameDebugConsole; using System; using System.Linq; // using UI.HookWheel; using UniRx; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.SceneManagement; public class DebugFunc { public static void Init() { var config = GContext.container.Resolve(); if (config != null && (config.Get("DEBUG", "0") == "1" || config.Get("GM", "0") == "1")) { DebugLogConsole.AddCommand("Go.show", "Shows a GameObject", ShowGO); DebugLogConsole.AddCommand("Go.hide", "Shows a GameObject", HideGO); DebugLogConsole.AddCommand("Render.quality", "change quality", SetQuality); DebugLogConsole.AddCommand("Render.scale", "Set render scale [0.1-2]", SetRendererScale); DebugLogConsole.AddCommand("Render.aa", "anti aliasing", SetAntiAliasing); DebugLogConsole.AddCommand("Render.ShadowToggle", "Toggle Shadow", ToggleShadow); DebugLogConsole.AddCommand("Render.Pipline", "light num", SetRenderPipline); DebugLogConsole.AddCommand("info.GPU", "GPU Info", GpuInfo); DebugLogConsole.AddCommand("info.CPU", "CPU Info", CpuInfo); DebugLogConsole.AddCommand("info.Support", "Device Support", SupportInfo); DebugLogConsole.AddCommand("FPS", "Toggle FPS", Fps); DebugLogConsole.AddCommand("LTPL", "开关 Leviathan Timeline 性能日志(不影响 FPS 浮层)", ToggleLeviathanTimelinePerf); DebugLogConsole.AddCommand("LTCW", "设置 CatchUp 消费等待(ms) 1~50", SetLeviathanCatchUpWaitMs); DebugLogConsole.AddCommand("LTCW?", "查询 CatchUp 消费等待(ms)", GetLeviathanCatchUpWaitMs); DebugLogConsole.AddCommand("Render.antiAliasing", "change antiAliasing", SetRTAntiAliasing); DebugLogConsole.AddCommand("T.hotupdate", "hot update test", HotUpdateTest); DebugLogConsole.AddCommand("UI.hide", "Hide UI", ToggleUI); DebugLogConsole.AddCommand("Misc.tg", "Hide misc", ToggleMisc); DebugLogConsole.AddCommand("aihelp", "open aihelp", OpenAIHelp); DebugLogConsole.AddCommand("review", "open review", OpenReview); DebugLogConsole.AddCommand("Pay.sku", "sku list", GetSKUs); DebugLogConsole.AddCommand("ad.debug", "Active Ad Debug", ActiveAdDebug); DebugLogConsole.AddCommand("ad.media", "Active Ad Media Debug", ActiveAdMedia); DebugLogConsole.AddCommand("notify.send", "Local Notify Test", NotifyTest); DebugLogConsole.AddCommand("notify.setting", " Notify set", NotifySettingTest); DebugLogConsole.AddCommand("notify.status", " Notify Status", NotificationStatus); DebugLogConsole.AddCommand("notify.time", "Notify at certain time", NotifyAtTime); DebugLogConsole.AddCommand("mail.status", "Print cache mail", PrintMail); DebugLogConsole.AddCommand("mail.fetch", "fetch mail to cache", FetchMail); DebugLogConsole.AddCommand("rt.test", "test realtime", RtTest); DebugLogConsole.AddCommand("event.start", "Start event game by code (12=bottle)", EventStart); DebugLogConsole.AddCommand("account.loginTime", "login time - 1day", LoginTime); DebugLogConsole.AddCommand("account.info", "account info", AccoutInfo); // [REMOVED] CustomServerMgr deleted: AuthorTest DebugLogConsole.AddCommand("open.washing", "Open Washing Activity", OpenWashingActivity); DebugLogConsole.AddCommand("deeplink.test", "Test if deeplink connects. If so, returns pid and uid.", TestDeepLink); DebugLogConsole.AddCommand("srp.fswave", "toggle fullscreen wave", ToggleFSWave); DebugLogConsole.AddCommand("srp.fsblur", "toggle fullscreen blur", ToggleFSBlur); DebugLogConsole.AddCommand("guide.clear", "clear guide data", ClearGuide); DebugLogConsole.AddCommand("lastpayment.clear", "Clear Last Payment Time", ClearLastPaymentTime); } } private static void TestDeepLink() { Debug.Log("TestDeepLink: AppsFlyer removed in demo build"); } private static void NotifyAtTime(string time) { var now = ZZTimeHelper.UtcNow(); var fireTime = DateTime.SpecifyKind(DateTime.Parse(time), DateTimeKind.Utc); fireTime = fireTime.AddDays(now <= fireTime ? 0 : 1); var service = GContext.container.Resolve(); service.ScheduleOneTimeNotification(434200, fireTime.ToLocalTime(), "Test Note at Time", $"Test Notification @ {fireTime}."); } private static void NotifyTest() { ILocalNotificationService service = GContext.container.Resolve(); service.ScheduleOneTimeNotification(434200, DateTime.Now + TimeSpan.FromSeconds(3), "Notification", "Test Notification "); } private static void NotifySettingTest() { ILocalNotificationService service = GContext.container.Resolve(); service.OpenSettings(); } private static string NotificationStatus() { #if UNITY_ANDROID return Unity.Notifications.Android.AndroidNotificationCenter.UserPermissionToPost.ToString(); #else return Unity.Notifications.iOS.iOSNotificationCenter.GetNotificationSettings().AuthorizationStatus.ToString(); #endif } private static string HotUpdateTest() { return "hot update test Ver 0.6 - 2024-03-26:1434"; } private static string ToggleUI(string path) { GameObject homePanelGo = UIManager.Instance.gameObject.transform.Find("HomePanel").gameObject; if (homePanelGo == null) { return "UI not found."; } GameObject go = homePanelGo.transform.Find(path).gameObject; if (go == null) { return "path not found"; } go.SetActive(!go.activeSelf); return $"UI {go} toggled to {go.activeSelf}."; } private static string ToggleMisc(int idx) { GameObject go = GetGOFromPath("Env_101(Clone)/Misc"); int childCount = go.transform.childCount; if (idx >= childCount) return $"index {idx} exceeds children count{childCount}"; var child = go.transform.GetChild(idx).gameObject; if (child == null) return $"child {idx} not found"; child.SetActive(!child.activeSelf); return $"{child} toggled to {child.activeSelf}."; } private static void OpenAIHelp() { // AIHelp.AIHelpSupport.Show("E001"); } private static void OpenReview() { var config = GContext.container.Resolve(); // tysdk.AppRequestReview.RequestReview(config.Get(GConstant.K_APP_Store_URL, string.Empty)); } private static string ShowGO(string path) { GameObject go = GetGOFromPath(path); if (go != null) { go.SetActive(true); } return $"GameObject not found"; } private static string HideGO(string path) { GameObject go = GetGOFromPath(path); if (go != null) { go.SetActive(false); return $"{go.name} has been hidden"; } return $"GameObject not found"; } private static string SetQuality(int level) { QualityManager.ChangeQuality(level); zzwater.URPHelper.RendererFeatureSetActive(false, "FSBlur"); zzwater.URPHelper.RendererFeatureSetActive(false, "FSWave"); return $"quality set to {QualitySettings.names[QualitySettings.GetQualityLevel()]}"; } private static void SetRTAntiAliasing(int level) { var rt = new RenderTexture((int)125, (int)125, 24, RenderTextureFormat.ARGB32); rt.antiAliasing = level; } private static string SetRendererScale(float ratio) { if (ratio == 0) { return $"Render scale {CurrentRenderPipeline.renderScale}"; } ratio = Mathf.Clamp(ratio, 0.1f, 2f); var uprAsset = CurrentRenderPipeline; if (uprAsset == null) return "No UniversalRenderPipelineAsset"; var preValue = uprAsset.renderScale; uprAsset.renderScale = ratio; return $"Render scale {preValue} set to {ratio}"; } private static string SetAntiAliasing(int count) { var uprAsset = CurrentRenderPipeline; if (uprAsset == null) return "No UniversalRenderPipelineAsset"; var preValue = uprAsset.msaaSampleCount; uprAsset.msaaSampleCount = count; return $"Render scale {preValue} set to {count}"; } private static string SetRenderPipline(string name) { var currentPiplineName = GraphicsSettings.currentRenderPipeline.name; if (name == "?") { return $"Pipline set to {currentPiplineName}"; } else if (name == "-") { QualitySettings.renderPipeline = null; } else { var pipelineAsset = Addressables.LoadAssetAsync(name).WaitForCompletion(); QualitySettings.renderPipeline = pipelineAsset; } var newPipelineName = GraphicsSettings.currentRenderPipeline.name; return $"{currentPiplineName} set to {newPipelineName}"; } private static string ToggleShadow() { var cam = Camera.main; if (cam != null) { var comp = cam.GetComponent(); var preValue = comp.renderShadows; comp.renderShadows = !preValue; return $"Shadow {preValue} set to {comp.renderShadows}"; } return "Camera not found"; } private static string CpuInfo() { var props = typeof(SystemInfo).GetProperties() .Where(x => x.Name.StartsWith("processor")); var sb = new System.Text.StringBuilder(); sb.AppendLine(); foreach (var prop in props) { sb.AppendLine($"{prop.Name}: {prop.GetValue(null)}"); } return sb.ToString(); } private static string GpuInfo() { var props = typeof(SystemInfo).GetProperties() .Where(x => x.Name.StartsWith("graphics")); var sb = new System.Text.StringBuilder(); sb.AppendLine(); foreach (var prop in props) { sb.AppendLine($"{prop.Name}: {prop.GetValue(null)}"); } return sb.ToString(); } private static string SupportInfo() { var props = typeof(SystemInfo).GetProperties() .Where(x => x.Name.StartsWith("support")); var sb = new System.Text.StringBuilder(); sb.AppendLine(); foreach (var prop in props) { sb.AppendLine($"{prop.Name}: {prop.GetValue(null)}"); } return sb.ToString(); } private static void Fps() { game.RootCtx.showFPS = !game.RootCtx.showFPS; } private static void ToggleLeviathanTimelinePerf() { // var on = !LeviathanLogConfig.EnableTimelineVideoPerfLog; // LeviathanLogConfig.EnableTimelineVideoPerfLog = on; // PlayerPrefs.SetInt("LeviathanTimelinePerf", on ? 1 : 0); // PlayerPrefs.Save(); // UnityEngine.Debug.Log($"[Debug] Leviathan Timeline 性能日志 = {on}(Logcat 搜 LeviathanTimelineVideoPerf)"); } private static void SetLeviathanCatchUpWaitMs(int ms) { // var decoders = UnityEngine.Object.FindObjectsOfType(true); // if (decoders == null || decoders.Length == 0) // { // UnityEngine.Debug.Log("[Debug] LTCW: 未找到活跃的 UnityEngine.MonoBehaviour // UnityEngine.MonoBehaviour // LeviathanVideoDecoderBase 实例"); // return; // } // foreach (var d in decoders) // { // d.CatchUpConsumePerFrameWaitMs = ms; // } // UnityEngine.Debug.Log($"[Debug] LTCW: 已将 {decoders.Length} 个解码器 CatchUpConsumePerFrameWaitMs 设为 {ms}ms"); } private static void GetLeviathanCatchUpWaitMs() { // var decoders = UnityEngine.Object.FindObjectsOfType(); // if (decoders == null || decoders.Length == 0) // { // UnityEngine.Debug.Log("[Debug] LTCW?: 未找到活跃的 UnityEngine.MonoBehaviour // UnityEngine.MonoBehaviour // LeviathanVideoDecoderBase 实例"); // return; // } // foreach (var d in decoders) // { // UnityEngine.Debug.Log($"[Debug] LTCW? {d.name}: CatchUpConsumePerFrameWaitMs={d.CatchUpConsumePerFrameWaitMs}ms"); // } } private static UniversalRenderPipelineAsset CurrentRenderPipeline { get { return GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset; //return (UniversalRenderPipelineAsset) QualitySettings.renderPipeline; } } private static async void GetSKUs() { var iapService = GContext.container.Resolve(); if (iapService == null) { UnityEngine.Debug.Log("iapService is null"); ; return; } var sb = new System.Text.StringBuilder(); sb.AppendLine(); var skus = await iapService.GetSKUs(); foreach (var sku in skus) { sb.AppendLine(); sb.Append($" {sku.price} code {sku.price_currency_code} "); sb.AppendLine(); } UnityEngine.Debug.Log(sb.ToString()); } private static void ActiveAdDebug() { // removed: MaxSdk deleted } private static void ActiveAdMedia() { // removed: MaxSdk deleted } private static GameObject GetGOFromPath(string path) { var root = SceneManager.GetActiveScene().GetRootGameObjects(); var splitPath = path.Split('/'); var rootName = splitPath[0]; var rootGo = root.FirstOrDefault(x => x.name == rootName); if (rootGo == null) return null; if (splitPath.Length == 1) return rootGo; var childPath = string.Join("/", splitPath.Skip(1)); return rootGo.transform.Find(childPath)?.gameObject; } private static void PrintMail() { var mailService = GContext.container.Resolve() as InGameMailService; mailService.PrintCacheMail(); } private static void FetchMail() { GContext.container.Resolve().FetchMail(); } private static void RtTest() { var rtService = GContext.container.Resolve() as SignalRService; rtService.Test(); } private static async void EventStart(int code) { var panel = await UIManager.Instance.GetUIAsync(UITypes.EventGamePlayPanel); panel.GetComponent().StartGame(code); } private static void LoginTime(int hours) { var userService = GContext.container.Resolve() as game.PlayFabUserService; if (userService == null) return; var loginTime = userService.LoginTime; var newLoginTime = loginTime.AddHours(hours); var prop = userService.GetType().GetProperty("LoginTime"); prop.SetValue(userService, newLoginTime); Debug.Log($"loginTime: {loginTime} newLoginTime: {newLoginTime} prop: {userService.LoginTime}"); } private static void AccoutInfo() { var userService = GContext.container.Resolve() as game.PlayFabUserService; if (userService == null) return; Debug.Log($"pfid: {userService.UserId} tyid: {userService.CustomId} lastLogin: {userService.LoginTime}"); if (PlayerPrefs.HasKey("KEY_ACCOUNT_INFO")) { Debug.Log("Saved account info: " + PlayerPrefs.GetString("KEY_ACCOUNT_INFO")); } else { Debug.Log("No saved account info"); } } // [REMOVED] CustomServerMgr deleted // private static async void AuthorTest() // { // var svr = GContext.container.Resolve(); // var result = await svr.GetStringAsync("account/authortest"); // Debug.Log($"AuthorTest {result}"); // } private static void AIHelpTest() { RedPointManager.Instance.SetRedPointState(RedPointName.AIHelp_Msg, true, 1); } private static void OpenWashingActivity() { ToggleUI("safearea/RightPanel/layout/btn_washing"); } private static void EventPartnerDebugActivate() { // var d = GContext.container.Resolve(); // if (d is null) // { // Debug.Log( $"[EventPartner] No data found, cannot activate."); // return; // } // _ = d.LoadDataDebug(); Debug.Log($"[EventPartner] This function is obsoleted for now."); } private static void ToggleFSWave() { var feature = zzwater.URPHelper.FindAndCacheRendererFeature("FSWave"); if (feature == null) Debug.LogError($"Feature FSWave not found"); else feature.SetActive(!feature.isActive); } private static void ToggleFSBlur() { var feature = zzwater.URPHelper.FindAndCacheRendererFeature("FSBlur"); if (feature == null) Debug.LogError($"Feature FSWave not found"); else feature.SetActive(!feature.isActive); } static void ClearGuide() { GContext.container.Resolve().GMClearGuide(); UIManager.Instance.DestroyUI(UITypes.GuidancePanel); } static void ClearLastPaymentTime() { PlayFabMgr.Instance.UpdateUserDataValue("LastPaymentTime", ""); } }