< Summary

Class:GDX.Developer.BooleanWatch
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Developer/Watches/BooleanWatch.cs
Covered lines:0
Uncovered lines:18
Coverable lines:18
Total lines:56
Line coverage:0% (0 of 18)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:2
Method coverage:0% (0 of 2)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BooleanWatch(...)0%2100%
Poll()0%20400%

File(s)

./Packages/com.dotbunny.gdx/GDX/Developer/Watches/BooleanWatch.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5#if UNITY_2022_2_OR_NEWER
 6
 7using System;
 8using UnityEngine.UIElements;
 9
 10namespace GDX.Developer
 11{
 12    /// <summary>
 13    /// Thread-safe developer watch system.
 14    /// </summary>
 15    public class BooleanWatch : WatchBase
 16    {
 17        const string k_FalseText = "False";
 18        const string k_TrueText = "True";
 19
 20        readonly Func<bool> m_GetValue;
 21        bool m_CachedHash;
 22
 23        readonly Label m_DisplayNameLabel;
 24        readonly Label m_ValueLabel;
 25
 26        public BooleanWatch(string uniqueIdentifier, string displayName, Func<bool> getValue, bool enabled = true, int m
 027            : base(uniqueIdentifier, displayName, enabled, minWidth, minHeight)
 028        {
 029            m_GetValue = getValue;
 30
 031            m_DisplayNameLabel = new Label() { text = displayName };
 032            m_DisplayNameLabel.AddToClassList("gdx-watch-left");
 33
 034            m_ValueLabel = new Label();
 035            m_ValueLabel.AddToClassList("gdx-watch-right");
 36
 037            ContainerElement.Add(m_DisplayNameLabel);
 038            ContainerElement.Add(m_ValueLabel);
 039        }
 40
 41        public override void Poll()
 042        {
 43            // Poll for our new value
 044            bool getValue = m_GetValue();
 45
 46            // Only change if legit change
 047            if (m_CachedHash != getValue)
 048            {
 049                m_ValueLabel.text = getValue ? k_TrueText : k_FalseText;
 050                m_CachedHash = getValue;
 051            }
 052        }
 53    }
 54}
 55
 56#endif // UNITY_2022_2_OR_NEWER