< 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:113
Line coverage:0% (0 of 34)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:7
Method coverage:0% (0 of 7)

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            };
 40
 041            updateValueDictionary = new Dictionary<DebugValueEnum, Func<string>>();
 042            foreach (IDebugMetricModule debugMetricsModule in debugMetricsModules)
 43            {
 044                debugMetricsModule.SetUpModule(updateValueDictionary);
 45            }
 046        }
 47
 48        private void Start()
 49        {
 050            closeButton.onClick.AddListener(() =>DataStore.i.debugConfig.isFPSPanelVisible.Set(false));
 051            copySceneToClipboard.SetFuncToCopy(() =>  sceneDebugMetricModule.GetSceneID());
 052        }
 53
 54        private void OnEnable()
 55        {
 056            container.anchoredPosition = containerStartAnchoredPosition;
 057            foreach (IDebugMetricModule debugMetricsModule in debugMetricsModules)
 58            {
 059                debugMetricsModule.EnableModule();
 60            }
 61
 062            StartCoroutine(UpdateLabelLoop());
 063        }
 64
 65        private void OnDisable()
 66        {
 067            foreach (IDebugMetricModule debugMetricsModule in debugMetricsModules)
 68            {
 069                debugMetricsModule.DisableModule();
 70            }
 071            StopAllCoroutines();
 072        }
 73
 74        private IEnumerator UpdateLabelLoop()
 75        {
 076            while (performanceData.Get().totalSeconds <= 0)
 77            {
 078                yield return null;
 79            }
 80
 081            while (true)
 82            {
 083                foreach (IDebugMetricModule debugMetricsModule in debugMetricsModules)
 84                {
 085                    debugMetricsModule.UpdateModule();
 86                }
 087                for (var i = 0; i < valuesToUpdate.Count; i++)
 88                {
 089                    if (valuesToUpdate[i].isActiveAndEnabled)
 90                    {
 091                        valuesToUpdate[i].SetValue(updateValueDictionary[valuesToUpdate[i].debugValueEnum].Invoke());
 92                    }
 93                }
 094                yield return new WaitForSeconds(REFRESH_SECONDS);
 95            }
 96        }
 97
 98        private void OnDestroy()
 99        {
 0100            closeButton.onClick.RemoveAllListeners();
 0101            foreach (IDebugMetricModule debugMetricsModule in debugMetricsModules)
 102            {
 0103                debugMetricsModule.Dispose();
 104            }
 0105        }
 106
 107        public void AddValueToUpdate(DebugValue valueToUpdate)
 108        {
 0109            valuesToUpdate.Add(valueToUpdate);
 0110        }
 111
 112    }
 113}