< Summary

Class:ChatEntry
Assembly:ChatHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ChatWidgetHUD/ChatEntry.cs
Covered lines:0
Uncovered lines:14
Coverable lines:14
Total lines:37
Line coverage:0% (0 of 14)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
InterpolateAlpha()0%42600%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ChatWidgetHUD/ChatEntry.cs

#LineLine coverage
 1using System.Collections;
 2using UnityEngine;
 3
 4public abstract class ChatEntry : MonoBehaviour
 5{
 6    [SerializeField] internal CanvasGroup group;
 7    protected bool fadeEnabled;
 8    protected Coroutine previewInterpolationRoutine;
 9    protected Coroutine previewInterpolationAlphaRoutine;
 10
 11    public abstract ChatEntryModel Model { get; }
 12    public abstract void Populate(ChatEntryModel model);
 13    public abstract void SetFadeout(bool enabled);
 14    public abstract void FadeOut();
 15
 16    protected IEnumerator InterpolateAlpha(float destinationAlpha, float duration)
 17    {
 018        if (!fadeEnabled)
 19        {
 020            group.alpha = destinationAlpha;
 021            StopCoroutine(previewInterpolationAlphaRoutine);
 22        }
 023        if(destinationAlpha.Equals(group.alpha)) yield break;
 024        var t = 0f;
 025        var startAlpha = group.alpha;
 26        //NOTE(Brian): Small offset using normalized Y so we keep the cascade effect
 027        double yOffset = ((RectTransform) transform).localPosition.y / (double) Screen.height * 2.5f;
 028        duration -= (float) yOffset;
 029        while (t < duration)
 30        {
 031            t += Time.deltaTime;
 032            group.alpha = Mathf.Lerp(startAlpha, destinationAlpha, t / duration);
 033            yield return null;
 34        }
 035        group.alpha = destinationAlpha;
 036    }
 37}

Methods/Properties

InterpolateAlpha()