< 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
 486610    public bool hideOnEnable = true;
 486611    public float animSpeedFactor = 1.0f;
 12    public bool disableAfterFadeOut;
 486613    public string visibleParam = "visible";
 14
 6015    public bool isVisible => animator.GetBool(visibleParamHash);
 16
 17    private Animator animatorValue;
 18    private Animator animator
 19    {
 20        get
 21        {
 154222            if (animatorValue == null)
 23            {
 36124                animatorValue = GetComponent<Animator>();
 25            }
 26
 154227            return animatorValue;
 28        }
 29    }
 30    private int? visibleParamHashValue = null;
 31
 32    private int visibleParamHash
 33    {
 34        get
 35        {
 61336            if (!visibleParamHashValue.HasValue)
 36137                visibleParamHashValue = Animator.StringToHash(visibleParam);
 38
 61339            return visibleParamHashValue.Value;
 40        }
 41    }
 42
 43    public void Show(bool instant = false)
 44    {
 7845        animator.speed = animSpeedFactor;
 7846        animator.SetBool(visibleParamHash, true);
 47
 7848        if (instant)
 1249            animator.Update(10);
 7850    }
 51
 52    public void Hide(bool instant = false)
 53    {
 47554        animator.speed = animSpeedFactor;
 47555        animator.SetBool(visibleParamHash, false);
 56
 47557        if (instant)
 36458            animator.Update(10);
 47559    }
 60
 61    public void AnimEvent_HideFinished()
 62    {
 4663        OnWillFinishHide?.Invoke(this);
 64
 4665        if (disableAfterFadeOut)
 66        {
 367            gameObject?.SetActive(false);
 68        }
 4669    }
 70
 1071    public void AnimEvent_ShowFinished() { OnWillFinishStart?.Invoke(this); }
 72
 73    private void OnEnable()
 74    {
 227675        if ( hideOnEnable )
 76        {
 31877            Hide(true);
 78        }
 227679    }
 80}