< Summary

Class:DCL.FPSDisplay.FPSDisplay
Assembly:FPSDisplay
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/Debugging/FPSDisplay/FPSDisplay.cs
Covered lines:0
Uncovered lines:34
Coverable lines:34
Total lines:112
Line coverage:0% (0 of 34)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%6200%
Start()0%6200%
OnEnable()0%6200%
OnDisable()0%6200%
UpdateLabelLoop()0%72800%
OnDestroy()0%6200%
AddValueToUpdate(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/Debugging/FPSDisplay/FPSDisplay.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEngine;
 5using UnityEngine.UI;
 6
 7namespace DCL.FPSDisplay
 8{
 9    public class FPSDisplay : MonoBehaviour
 10    {
 11        private const float REFRESH_SECONDS = 0.1f;
 12
 13        [SerializeField] internal List<DebugValue> valuesToUpdate;
 14        [SerializeField] private Button closeButton;
 15        [SerializeField] private CopyToClipboardButton copySceneToClipboard;
 16        [SerializeField] private DebugSection memorySection;
 17        [SerializeField] private RectTransform container;
 18        [SerializeField] private PerformanceMetricsDataVariable performanceData;
 19
 20        private Dictionary<DebugValueEnum, Func<string>> updateValueDictionary;
 21        private Vector3 containerStartAnchoredPosition;
 22
 23        private List<IDebugMetricModule> debugMetricsModules;
 24        private SceneDebugMetricModule sceneDebugMetricModule;
 25
 26        private void Awake()
 27        {
 028            containerStartAnchoredPosition = container.anchoredPosition;
 29
 030            sceneDebugMetricModule = new SceneDebugMetricModule();
 031            debugMetricsModules = new List<IDebugMetricModule>
 32            {
 33                new FPSDebugMetricModule(performanceData),
 34                new SkyboxDebugMetricModule(),
 35                new MemoryJSDebugMetricModule(),
 36                new MemoryDesktopDebugMetricModule(),
 37                new GeneralDebugMetricModule(),
 38                sceneDebugMetricModule
 39            };
 040            updateValueDictionary = new Dictionary<DebugValueEnum, Func<string>>();
 041            foreach (IDebugMetricModule debugMetricsModule in debugMetricsModules)
 42            {
 043                debugMetricsModule.SetUpModule(updateValueDictionary);
 44            }
 045        }
 46
 47        private void Start()
 48        {
 049            closeButton.onClick.AddListener(() =>DataStore.i.debugConfig.isFPSPanelVisible.Set(false));
 050            copySceneToClipboard.SetFuncToCopy(() =>  sceneDebugMetricModule.GetSceneID());
 051        }
 52
 53        private void OnEnable()
 54        {
 055            container.anchoredPosition = containerStartAnchoredPosition;
 056            foreach (IDebugMetricModule debugMetricsModule in debugMetricsModules)
 57            {
 058                debugMetricsModule.EnableModule();
 59            }
 60
 061            StartCoroutine(UpdateLabelLoop());
 062        }
 63
 64        private void OnDisable()
 65        {
 066            foreach (IDebugMetricModule debugMetricsModule in debugMetricsModules)
 67            {
 068                debugMetricsModule.DisableModule();
 69            }
 070            StopAllCoroutines();
 071        }
 72
 73        private IEnumerator UpdateLabelLoop()
 74        {
 075            while (performanceData.Get().totalSeconds <= 0)
 76            {
 077                yield return null;
 78            }
 79
 080            while (true)
 81            {
 082                foreach (IDebugMetricModule debugMetricsModule in debugMetricsModules)
 83                {
 084                    debugMetricsModule.UpdateModule();
 85                }
 086                for (var i = 0; i < valuesToUpdate.Count; i++)
 87                {
 088                    if (valuesToUpdate[i].isActiveAndEnabled)
 89                    {
 090                        valuesToUpdate[i].SetValue(updateValueDictionary[valuesToUpdate[i].debugValueEnum].Invoke());
 91                    }
 92                }
 093                yield return new WaitForSeconds(REFRESH_SECONDS);
 94            }
 95        }
 96
 97        private void OnDestroy()
 98        {
 099            closeButton.onClick.RemoveAllListeners();
 0100            foreach (IDebugMetricModule debugMetricsModule in debugMetricsModules)
 101            {
 0102                debugMetricsModule.Dispose();
 103            }
 0104        }
 105
 106        public void AddValueToUpdate(DebugValue valueToUpdate)
 107        {
 0108            valuesToUpdate.Add(valueToUpdate);
 0109        }
 110
 111    }
 112}