< Summary

Class:LoadingHUD.LoadingTipsRandomizer
Assembly:LoadingHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingTipsRandomizer.cs
Covered lines:12
Uncovered lines:1
Coverable lines:13
Total lines:52
Line coverage:92.3% (12 of 13)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LoadingTipsRandomizer()0%110100%
Awake()0%220100%
ShowRandomTipsRoutine()0%3.143075%
SetTip(...)0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.Linq;
 5using TMPro;
 6using UnityEngine;
 7using UnityEngine.UI;
 8
 9namespace LoadingHUD
 10{
 11
 12    public class LoadingTipsRandomizer : MonoBehaviour
 13    {
 14        [SerializeField] internal LoadingTip[] tips;
 15        [SerializeField] internal Image image;
 16        [SerializeField] internal TextMeshProUGUI label;
 1417        [SerializeField] internal float secondsBetweenTips = 7.5f;
 18
 1419        private List<LoadingTip> randomizedTips = new List<LoadingTip>();
 1420        private int tipIndex = -1;
 21
 22        private void Awake()
 23        {
 10424            randomizedTips = tips.OrderBy(x => Guid.NewGuid()).ToList();
 1325            StartCoroutine(ShowRandomTipsRoutine());
 1326        }
 27
 28        private IEnumerator ShowRandomTipsRoutine()
 29        {
 030            while (true)
 31            {
 1332                tipIndex = (tipIndex + 1) % randomizedTips.Count;
 1333                SetTip(randomizedTips[tipIndex]);
 1334                yield return WaitForSecondsCache.Get(secondsBetweenTips);
 35            }
 36        }
 37
 38        private void SetTip(LoadingTip tip)
 39        {
 1340            label.text = tip.text;
 1341            image.sprite = tip.sprite;
 1342        }
 43    }
 44
 45    [Serializable]
 46    public class LoadingTip
 47    {
 48        public string text;
 49        public Sprite sprite;
 50    }
 51
 52}