< 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:6
Uncovered lines:5
Coverable lines:11
Total lines:32
Line coverage:54.5% (6 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%2100%

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;
 12914    private string percentagePreText = "";
 15
 16    private void Awake()
 17    {
 3018        maxBarWidth = ((RectTransform)transform).rect.size.x;
 19
 3020        if (!string.IsNullOrEmpty(textPreviousToPercentage))
 2721            percentagePreText = $"{textPreviousToPercentage} ";
 3022    }
 23
 1224    public void SetActive(bool isActive) { gameObject.SetActive(isActive); }
 25
 26    public void SetPercentage(float newValue)
 27    {
 028        currentPercentage = newValue;
 029        percentageText.text = $"{percentagePreText}{newValue.ToString("0")}%";
 030        loadingBar.sizeDelta = new Vector2(newValue * maxBarWidth / 100f, loadingBar.sizeDelta.y);
 031    }
 32}