< Summary

Class:DCL.DebugConfigComponent
Assembly:DebugParameters
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/Debugging/DebugParameters/DebugConfigComponent.cs
Covered lines:0
Uncovered lines:63
Coverable lines:63
Total lines:196
Line coverage:0% (0 of 63)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DebugConfigComponent()0%2100%
Awake()0%2100%
Start()0%12300%
OnCommunicationReadyChangedValue(...)0%12300%
InitConfig()0%12300%
OpenWebBrowser()0%2721600%
OnDestroy()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/Debugging/DebugParameters/DebugConfigComponent.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using DCL.Components;
 4using UnityEditor;
 5using UnityEngine;
 6
 7namespace DCL
 8{
 9    public class DebugConfigComponent : MonoBehaviour
 10    {
 11        public DebugConfig debugConfig;
 12        public enum DebugPanel
 13        {
 14            Off,
 15            Scene,
 16            Engine
 17        }
 18
 19        public enum BaseUrl
 20        {
 21            LOCAL_HOST,
 22            CUSTOM,
 23        }
 24
 25        public enum Environment
 26        {
 27            USE_DEFAULT_FROM_URL,
 28            LOCAL,
 29            ZONE,
 30            TODAY,
 31            ORG
 32        }
 33
 34        private const string ENGINE_DEBUG_PANEL = "ENGINE_DEBUG_PANEL";
 35        private const string SCENE_DEBUG_PANEL = "SCENE_DEBUG_PANEL";
 36
 37        public bool openBrowserWhenStart;
 38
 39        [Header("Kernel General Settings")]
 40        public bool useCustomContentServer = false;
 41
 042        public string customContentServerUrl = "http://localhost:1338/";
 43
 44        [Space(10)]
 45        public BaseUrl baseUrlMode;
 46
 47        public string baseUrlCustom;
 48
 49
 50        [Space(10)]
 51        public Environment environment;
 52
 53        [Tooltip("Set this field to force the realm (server). On the latin-american zone, recommended realms are fenrir-
 54        public string realm;
 55
 056        public Vector2 startInCoords = new Vector2(-99, 109);
 57
 58        [Header("Kernel Misc Settings")]
 059        public bool forceLocalComms = true;
 60
 61        public bool allWearables = false;
 62        public bool testWearables = false;
 63        public bool enableTutorial = false;
 64        public bool builderInWorld = false;
 065        public bool soloScene = true;
 66        public DebugPanel debugPanelMode = DebugPanel.Off;
 67
 68        private void Awake()
 69        {
 070            DataStore.i.debugConfig.soloScene = debugConfig.soloScene;
 071            DataStore.i.debugConfig.soloSceneCoords = debugConfig.soloSceneCoords;
 072            DataStore.i.debugConfig.ignoreGlobalScenes = debugConfig.ignoreGlobalScenes;
 073            DataStore.i.debugConfig.msgStepByStep = debugConfig.msgStepByStep;
 074        }
 75
 76        private void Start()
 77        {
 078            lock (DataStore.i.wsCommunication.communicationReady)
 79            {
 080                if (DataStore.i.wsCommunication.communicationReady.Get())
 81                {
 082                    InitConfig();
 083                }
 84                else
 85                {
 086                    DataStore.i.wsCommunication.communicationReady.OnChange += OnCommunicationReadyChangedValue;
 87                }
 088            }
 089        }
 90
 91        private void OnCommunicationReadyChangedValue(bool newState, bool prevState)
 92        {
 093            if (newState && !prevState)
 094                InitConfig();
 95
 096            DataStore.i.wsCommunication.communicationReady.OnChange -= OnCommunicationReadyChangedValue;
 097        }
 98
 99        private void InitConfig()
 100        {
 0101            if (useCustomContentServer)
 102            {
 0103                RendereableAssetLoadHelper.useCustomContentServerUrl = true;
 0104                RendereableAssetLoadHelper.customContentServerUrl = customContentServerUrl;
 105            }
 106
 0107            if (openBrowserWhenStart)
 0108                OpenWebBrowser();
 0109        }
 110
 111        private void OpenWebBrowser()
 112        {
 113#if (UNITY_EDITOR || UNITY_STANDALONE)
 0114            string baseUrl = "";
 0115            string debugString = "";
 116
 0117            if (baseUrlMode == BaseUrl.CUSTOM)
 0118                baseUrl = baseUrlCustom;
 119            else
 0120                baseUrl = "http://localhost:3000/?";
 121
 0122            switch (environment)
 123            {
 124                case Environment.USE_DEFAULT_FROM_URL:
 125                    break;
 126                case Environment.LOCAL:
 0127                    debugString = "DEBUG_MODE&";
 0128                    break;
 129                case Environment.ZONE:
 0130                    debugString = "NETWORK=ropsten&";
 0131                    break;
 132                case Environment.TODAY:
 0133                    debugString = "NETWORK=mainnet&";
 0134                    break;
 135                case Environment.ORG:
 0136                    debugString = "NETWORK=mainnet&";
 137                    break;
 138            }
 139
 0140            if (forceLocalComms)
 141            {
 0142                debugString += "LOCAL_COMMS&";
 143            }
 144
 0145            if (allWearables)
 146            {
 0147                debugString += "ALL_WEARABLES&";
 148            }
 149
 0150            if (testWearables)
 151            {
 0152                debugString += "TEST_WEARABLES&";
 153            }
 154
 0155            if (enableTutorial)
 156            {
 0157                debugString += "RESET_TUTORIAL&";
 158            }
 159
 0160            if (soloScene)
 161            {
 0162                debugString += "LOS=0&";
 163            }
 164
 0165            if (builderInWorld)
 166            {
 0167                debugString += "ENABLE_BUILDER_IN_WORLD&";
 168            }
 169
 0170            if ( !string.IsNullOrEmpty(realm))
 171            {
 0172                debugString += $"realm={realm}&";
 173            }
 174
 0175            string debugPanelString = "";
 176
 0177            if (debugPanelMode == DebugPanel.Engine)
 178            {
 0179                debugPanelString = ENGINE_DEBUG_PANEL + "&";
 0180            }
 0181            else if (debugPanelMode == DebugPanel.Scene)
 182            {
 0183                debugPanelString = SCENE_DEBUG_PANEL + "&";
 184            }
 185
 0186            Application.OpenURL(
 187                $"{baseUrl}{debugString}{debugPanelString}position={startInCoords.x}%2C{startInCoords.y}&ws={DataStore.i
 188#endif
 0189        }
 190
 191        private void OnDestroy()
 192        {
 0193            DataStore.i.wsCommunication.communicationReady.OnChange -= OnCommunicationReadyChangedValue;
 0194        }
 195    }
 196}