< 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:41
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 DeactivatePreview();
 15    public abstract void FadeOut();
 16    public abstract void ActivatePreview();
 17    public abstract void ActivatePreviewInstantly();
 18    public abstract void DeactivatePreviewInstantly();
 19
 20    protected IEnumerator InterpolateAlpha(float destinationAlpha, float duration)
 21    {
 022        if (!fadeEnabled)
 23        {
 024            group.alpha = destinationAlpha;
 025            StopCoroutine(previewInterpolationAlphaRoutine);
 26        }
 027        if(destinationAlpha.Equals(group.alpha)) yield break;
 028        var t = 0f;
 029        var startAlpha = group.alpha;
 30        //NOTE(Brian): Small offset using normalized Y so we keep the cascade effect
 031        double yOffset = ((RectTransform) transform).localPosition.y / (double) Screen.height * 2.5f;
 032        duration -= (float) yOffset;
 033        while (t < duration)
 34        {
 035            t += Time.deltaTime;
 036            group.alpha = Mathf.Lerp(startAlpha, destinationAlpha, t / duration);
 037            yield return null;
 38        }
 039        group.alpha = destinationAlpha;
 040    }
 41}

Methods/Properties

InterpolateAlpha()