< Summary

Class:ShowHideAnimator
Assembly:HUDCommon
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Common/ShowHideAnimator/ShowHideAnimator.cs
Covered lines:28
Uncovered lines:0
Coverable lines:28
Total lines:80
Line coverage:100% (28 of 28)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ShowHideAnimator()0%110100%
Show(...)0%220100%
Hide(...)0%220100%
AnimEvent_HideFinished()0%440100%
AnimEvent_ShowFinished()0%2.52050%
OnEnable()0%220100%

File(s)

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

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4[RequireComponent(typeof(Animator))]
 5public class ShowHideAnimator : MonoBehaviour
 6{
 7    public event System.Action<ShowHideAnimator> OnWillFinishHide;
 8    public event System.Action<ShowHideAnimator> OnWillFinishStart;
 9
 479410    public bool hideOnEnable = true;
 479411    public float animSpeedFactor = 1.0f;
 12    public bool disableAfterFadeOut;
 479413    public string visibleParam = "visible";
 14
 6615    public bool isVisible => animator.GetBool(visibleParamHash);
 16
 17    private Animator animatorValue;
 18    private Animator animator
 19    {
 20        get
 21        {
 129822            if (animatorValue == null)
 23            {
 32324                animatorValue = GetComponent<Animator>();
 25            }
 26
 129827            return animatorValue;
 28        }
 29    }
 30    private int? visibleParamHashValue = null;
 31
 32    private int visibleParamHash
 33    {
 34        get
 35        {
 53136            if (!visibleParamHashValue.HasValue)
 32337                visibleParamHashValue = Animator.StringToHash(visibleParam);
 38
 53139            return visibleParamHashValue.Value;
 40        }
 41    }
 42
 43    public void Show(bool instant = false)
 44    {
 7345        animator.speed = animSpeedFactor;
 7346        animator.SetBool(visibleParamHash, true);
 47
 7348        if (instant)
 1249            animator.Update(10);
 7350    }
 51
 52    public void Hide(bool instant = false)
 53    {
 39254        animator.speed = animSpeedFactor;
 39255        animator.SetBool(visibleParamHash, false);
 56
 39257        if (instant)
 29058            animator.Update(10);
 39259    }
 60
 61    public void AnimEvent_HideFinished()
 62    {
 863        OnWillFinishHide?.Invoke(this);
 64
 865        if (disableAfterFadeOut)
 66        {
 367            gameObject?.SetActive(false);
 68        }
 869    }
 70
 1271    public void AnimEvent_ShowFinished() { OnWillFinishStart?.Invoke(this); }
 72
 73    private void OnEnable()
 74    {
 78575        if ( hideOnEnable )
 76        {
 28277            Hide(true);
 78        }
 78579    }
 80}