< Summary

Class:LoadingBar
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Scripts/Common/LoadingBar.cs
Covered lines:10
Uncovered lines:1
Coverable lines:11
Total lines:32
Line coverage:90.9% (10 of 11)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LoadingBar()0%110100%
Awake()0%220100%
SetActive(...)0%110100%
SetPercentage(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Scripts/Common/LoadingBar.cs

#LineLine coverage
 1using TMPro;
 2using UnityEngine;
 3
 4[RequireComponent(typeof(RectTransform))]
 5public class LoadingBar : MonoBehaviour
 6{
 07    public float currentPercentage { get; set; }
 8
 9    [SerializeField] internal string textPreviousToPercentage;
 10    [SerializeField] internal TMP_Text percentageText;
 11    [SerializeField] internal RectTransform loadingBar;
 12
 13    private float maxBarWidth;
 13314    private string percentagePreText = "";
 15
 16    private void Awake()
 17    {
 3118        maxBarWidth = ((RectTransform)transform).rect.size.x;
 19
 3120        if (!string.IsNullOrEmpty(textPreviousToPercentage))
 2821            percentagePreText = $"{textPreviousToPercentage} ";
 3122    }
 23
 1224    public void SetActive(bool isActive) { gameObject.SetActive(isActive); }
 25
 26    public void SetPercentage(float newValue)
 27    {
 2228        currentPercentage = newValue;
 2229        percentageText.text = $"{percentagePreText}{newValue.ToString("0")}%";
 2230        loadingBar.sizeDelta = new Vector2(newValue * maxBarWidth / 100f, loadingBar.sizeDelta.y);
 2231    }
 32}