< Summary

Class:DCL.StatsPanelToggler
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/Debugging/Panels/StatsPanelToggler.cs
Covered lines:0
Uncovered lines:38
Coverable lines:38
Total lines:104
Line coverage:0% (0 of 38)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%2100%
Update()0%6200%
UpdateDeepProfilingInput()0%12300%
TogglePanel()0%6200%
EnableDeepProfiling()0%6200%
DisableDeepProfiling()0%2100%
EnableProfiling()0%6200%
RefreshShortcutText()0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/Debugging/Panels/StatsPanelToggler.cs

#LineLine coverage
 1using DCL.Helpers;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5namespace DCL
 6{
 7    public class StatsPanelToggler : MonoBehaviour
 8    {
 9        const string SHORTCUT_TEXT =
 10            "P = Toggle Panel | R = Reset Profile Data | I = Toggle Deep Msg Profiling";
 11
 12        bool deepProfilingEnabled;
 13        Text text;
 14
 15        public MessageBenchmarkController messageController;
 16        public MiscBenchmarkController miscController;
 17
 18        void Start()
 19        {
 020            text = GetComponent<Text>();
 021            deepProfilingEnabled = true;
 22
 023            EnableProfiling();
 024            RefreshShortcutText();
 025        }
 26
 27        void Update()
 28        {
 029            UpdateDeepProfilingInput();
 30
 031            if (Input.GetKeyUp(KeyCode.Y))
 32            {
 033                TogglePanel();
 34            }
 035        }
 36
 37        private void UpdateDeepProfilingInput()
 38        {
 039            if (Input.GetKeyUp(KeyCode.I))
 40            {
 041                deepProfilingEnabled = !deepProfilingEnabled;
 42
 043                if (deepProfilingEnabled)
 44                {
 045                    EnableDeepProfiling();
 046                }
 47                else
 48                {
 049                    DisableDeepProfiling();
 50                }
 51
 052                RefreshShortcutText();
 53            }
 054        }
 55
 56        private void TogglePanel()
 57        {
 058            if (deepProfilingEnabled)
 59            {
 060                messageController.gameObject.SetActive(!messageController.gameObject.activeSelf);
 61            }
 62
 063            miscController.gameObject.SetActive(!miscController.gameObject.activeSelf);
 064            Utils.ForceRebuildLayoutImmediate(transform.parent.GetComponent<RectTransform>());
 065        }
 66
 67        private void EnableDeepProfiling()
 68        {
 069            messageController.StartProfiling();
 70
 071            if (miscController.gameObject.activeSelf)
 72            {
 073                messageController.gameObject.SetActive(true);
 74            }
 075        }
 76
 77        private void DisableDeepProfiling()
 78        {
 079            messageController.StopProfiling();
 080            messageController.gameObject.SetActive(false);
 081        }
 82
 83        private void EnableProfiling()
 84        {
 085            miscController.StartProfiling();
 86
 087            if (deepProfilingEnabled)
 88            {
 089                EnableDeepProfiling();
 90            }
 091        }
 92
 93        void RefreshShortcutText()
 94        {
 095            if (deepProfilingEnabled)
 96            {
 097                text.text = $"[Deep Message Profiling Enabled]\n{SHORTCUT_TEXT}";
 098                return;
 99            }
 100
 0101            text.text = $"[Profiling Enabled]\n{SHORTCUT_TEXT}";
 0102        }
 103    }
 104}