< Summary

Class:CircleLoadingAnimator
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Scripts/Common/CircleLoadingAnimator.cs
Covered lines:0
Uncovered lines:15
Coverable lines:15
Total lines:39
Line coverage:0% (0 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CircleLoadingAnimator()0%2100%
OnEnable()0%6200%
OnDisable()0%2100%
LoadinAnimation()0%30500%

File(s)

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

#LineLine coverage
 1using System.Collections;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5//Note (Adrian): This class is temporary and will dissapear when the new UI is implemented
 6public class CircleLoadingAnimator : MonoBehaviour
 7{
 08    public float animSpeed = 6f;
 9
 10    Image fillImage;
 11    Coroutine coroutine;
 12
 13    private void OnEnable()
 14    {
 015        if (fillImage == null)
 016            fillImage = GetComponent<Image>();
 17
 018        coroutine = StartCoroutine(LoadinAnimation());
 019    }
 20
 021    private void OnDisable() { StopCoroutine(coroutine); }
 22
 23    IEnumerator LoadinAnimation()
 24    {
 025        fillImage.fillAmount = 0;
 026        float currentSpeed = animSpeed * Time.deltaTime;
 027        while (true)
 28        {
 029            fillImage.fillAmount += currentSpeed;
 30
 031            if (fillImage.fillAmount >= 1)
 032                currentSpeed = -animSpeed * Time.deltaTime;
 033            else if (fillImage.fillAmount <= 0)
 034                currentSpeed = animSpeed * Time.deltaTime;
 35
 036            yield return null;
 37        }
 38    }
 39}