| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using DCL.Components; |
| | 4 | | using DCL.Controllers; |
| | 5 | | using DCL.Helpers; |
| | 6 | | using DCL.Interface; |
| | 7 | | using Newtonsoft.Json; |
| | 8 | | using UnityEngine; |
| | 9 | |
|
| | 10 | | namespace DCL |
| | 11 | | { |
| | 12 | | public class DebugBridge : MonoBehaviour |
| | 13 | | { |
| 246 | 14 | | private ILogger debugLogger = new Logger(Debug.unityLogger.logHandler); |
| | 15 | |
|
| | 16 | | // Beware this SetDebug() may be called before Awake() somehow... |
| | 17 | | [ContextMenu("Set Debug mode")] |
| 0 | 18 | | public void SetDebug() { Environment.i.platform.debugController.SetDebug(); } |
| | 19 | |
|
| 0 | 20 | | public void HideFPSPanel() { Environment.i.platform.debugController.HideFPSPanel(); } |
| | 21 | |
|
| 0 | 22 | | public void ShowFPSPanel() { Environment.i.platform.debugController.ShowFPSPanel(); } |
| | 23 | |
|
| 0 | 24 | | public void SetSceneDebugPanel() { Environment.i.platform.debugController.SetSceneDebugPanel(); } |
| | 25 | |
|
| 0 | 26 | | public void SetEngineDebugPanel() { Environment.i.platform.debugController.SetEngineDebugPanel(); } |
| | 27 | |
|
| | 28 | | [ContextMenu("Dump Scenes Load Info")] |
| | 29 | | public void DumpScenesLoadInfo() |
| | 30 | | { |
| 0 | 31 | | foreach (var kvp in DCL.Environment.i.world.state.loadedScenes) |
| | 32 | | { |
| 0 | 33 | | ParcelScene scene = kvp.Value as ParcelScene; |
| 0 | 34 | | debugLogger.Log("Dumping state for scene: " + kvp.Value.sceneData.id); |
| 0 | 35 | | scene.GetWaitingComponentsDebugInfo(); |
| | 36 | | } |
| 0 | 37 | | } |
| | 38 | |
|
| 0 | 39 | | public void SetDisableAssetBundles() { RendereableAssetLoadHelper.loadingType = RendereableAssetLoadHelper.Loadi |
| | 40 | |
|
| | 41 | | [ContextMenu("Dump Renderers Lockers Info")] |
| | 42 | | public void DumpRendererLockersInfo() |
| | 43 | | { |
| 0 | 44 | | RenderingController renderingController = FindObjectOfType<RenderingController>(); |
| 0 | 45 | | if (renderingController == null) |
| | 46 | | { |
| 0 | 47 | | debugLogger.Log("RenderingController not found. Aborting."); |
| 0 | 48 | | return; |
| | 49 | | } |
| | 50 | |
|
| 0 | 51 | | debugLogger.Log($"Renderer is locked? {!renderingController.renderingActivatedAckLock.isUnlocked}"); |
| 0 | 52 | | debugLogger.Log($"Renderer is active? {CommonScriptableObjects.rendererState.Get()}"); |
| | 53 | |
|
| 0 | 54 | | System.Collections.Generic.HashSet<object> lockIds = |
| | 55 | | renderingController.renderingActivatedAckLock.GetLockIdsCopy(); |
| | 56 | |
|
| 0 | 57 | | foreach (var lockId in lockIds) |
| | 58 | | { |
| 0 | 59 | | debugLogger.Log($"Renderer is locked by id: {lockId} of type {lockId.GetType()}"); |
| | 60 | | } |
| 0 | 61 | | } |
| | 62 | |
|
| | 63 | | public void CrashPayloadRequest() |
| | 64 | | { |
| 0 | 65 | | var crashPayload = CrashPayloadUtils.ComputePayload |
| | 66 | | ( |
| | 67 | | DCL.Environment.i.world.state.loadedScenes, |
| | 68 | | Environment.i.platform.debugController.GetTrackedMovements(), |
| | 69 | | Environment.i.platform.debugController.GetTrackedTeleportPositions() |
| | 70 | | ); |
| | 71 | |
|
| 0 | 72 | | CrashPayloadResponse(crashPayload); |
| 0 | 73 | | } |
| | 74 | |
|
| | 75 | | public void CrashPayloadResponse(CrashPayload payload) |
| | 76 | | { |
| 0 | 77 | | string json = JsonConvert.SerializeObject(payload); |
| 0 | 78 | | WebInterface.MessageFromEngine("CrashPayloadResponse", json); |
| 0 | 79 | | } |
| | 80 | |
|
| | 81 | | [ContextMenu("Dump Crash Payload")] |
| | 82 | | public void DumpCrashPayload() |
| | 83 | | { |
| 0 | 84 | | var payload = CrashPayloadUtils.ComputePayload |
| | 85 | | ( |
| | 86 | | DCL.Environment.i.world.state.loadedScenes, |
| | 87 | | Environment.i.platform.debugController.GetTrackedMovements(), |
| | 88 | | Environment.i.platform.debugController.GetTrackedTeleportPositions() |
| | 89 | | ); |
| | 90 | |
|
| 0 | 91 | | foreach ( var field in payload.fields) |
| | 92 | | { |
| 0 | 93 | | string dump = JsonConvert.SerializeObject(field.Value); |
| 0 | 94 | | debugLogger.Log($"Crash payload ({field.Key}): {dump}"); |
| | 95 | | } |
| | 96 | |
|
| 0 | 97 | | string fullDump = JsonConvert.SerializeObject(payload); |
| 0 | 98 | | debugLogger.Log($"Full crash payload size: {fullDump.Length}"); |
| 0 | 99 | | } |
| | 100 | |
|
| 0 | 101 | | public void RunPerformanceMeterTool(float durationInSeconds) { Environment.i.platform.debugController.RunPerform |
| | 102 | |
|
| 0 | 103 | | public void InstantiateBotsAtWorldPos(string configJson) { Environment.i.platform.debugController.InstantiateBot |
| | 104 | |
|
| 0 | 105 | | public void InstantiateBotsAtCoords(string configJson) { Environment.i.platform.debugController.InstantiateBotsA |
| 0 | 106 | | public void StartBotsRandomizedMovement(string configJson) { Environment.i.platform.debugController.StartBotsRan |
| 0 | 107 | | public void StopBotsMovement() { Environment.i.platform.debugController.StopBotsMovement(); } |
| 0 | 108 | | public void RemoveBot(string targetEntityId) { Environment.i.platform.debugController.RemoveBot(targetEntityId); |
| 0 | 109 | | public void ClearBots() { Environment.i.platform.debugController.ClearBots(); } |
| | 110 | |
|
| | 111 | | #if UNITY_EDITOR |
| | 112 | | [ContextMenu("Run Performance Meter Tool for 30 seconds")] |
| 0 | 113 | | public void DebugPerformanceMeter() { RunPerformanceMeterTool(30); } |
| | 114 | |
|
| | 115 | | [ContextMenu("Instantiate 3 bots at player coordinates")] |
| | 116 | | public void DebugBotsInstantiation() |
| | 117 | | { |
| 0 | 118 | | InstantiateBotsAtCoords("{ " + |
| | 119 | | "\"amount\":3, " + |
| | 120 | | "\"areaWidth\":15, " + |
| | 121 | | "\"areaDepth\":15 " + |
| | 122 | | "}"); |
| 0 | 123 | | } |
| | 124 | | #endif |
| | 125 | | } |
| | 126 | | } |