< Summary

Class:LoadingBar
Assembly:BuilderLoadingBar
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/Common/LoadingBar/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/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/Common/LoadingBar/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;
 4114    private string percentagePreText = "";
 15
 16    private void Awake()
 17    {
 1918        maxBarWidth = ((RectTransform)transform).rect.size.x;
 19
 1920        if (!string.IsNullOrEmpty(textPreviousToPercentage))
 1621            percentagePreText = $"{textPreviousToPercentage} ";
 1922    }
 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}