< Summary

Class:LoadingHUD.LoadingHUDView
Assembly:LoadingHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingHUDView.cs
Covered lines:18
Uncovered lines:1
Coverable lines:19
Total lines:58
Line coverage:94.7% (18 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CreateView()0%110100%
Awake()0%110100%
SetVisible(...)0%110100%
SetMessage(...)0%110100%
SetPercentage(...)0%110100%
SetTips(...)0%110100%
OnDestroy()0%110100%
Dispose()0%2.032080%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingHUDView.cs

#LineLine coverage
 1using TMPro;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5namespace LoadingHUD
 6{
 7    public interface ILoadingHUDView
 8    {
 9        void SetVisible(bool isVisible);
 10        void SetMessage(string message);
 11        void SetPercentage(float percentage);
 12        void SetTips(bool showTips);
 13        void Dispose();
 14    }
 15
 16    public class LoadingHUDView : MonoBehaviour, ILoadingHUDView
 17    {
 18        [SerializeField] internal TextMeshProUGUI text;
 19        [SerializeField] internal Image loadingBar;
 20        [SerializeField] internal GameObject tipsContainer;
 21        [SerializeField] internal GameObject noTipsContainer;
 22
 23        private bool isDestroyed = false;
 24
 25        public static ILoadingHUDView CreateView()
 26        {
 127            LoadingHUDView view = Instantiate(Resources.Load<GameObject>("LoadingHUD")).GetComponent<LoadingHUDView>();
 128            view.gameObject.name = "_LoadingHUD";
 129            return view;
 30        }
 31
 32        private void Awake()
 33        {
 834            SetMessage("");
 835            SetPercentage(0);
 836            SetTips(false);
 837        }
 38
 839        public void SetVisible(bool isVisible) { gameObject.SetActive(isVisible); }
 2040        public void SetMessage(string message) { text.text = message; }
 2041        public void SetPercentage(float percentage) { loadingBar.transform.localScale = new Vector3(percentage, 1, 1); }
 42        public void SetTips(bool showTips)
 43        {
 1144            tipsContainer.gameObject.SetActive(showTips);
 1145            noTipsContainer.gameObject.SetActive(!showTips);
 1146        }
 47
 1648        private void OnDestroy() { isDestroyed = true; }
 49
 50        public void Dispose()
 51        {
 152            if (isDestroyed)
 053                return;
 154            isDestroyed = true;
 155            Destroy(gameObject);
 156        }
 57    }
 58}