< 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
 135110    public bool hideOnEnable = true;
 135111    public float animSpeedFactor = 1.0f;
 12    public bool disableAfterFadeOut;
 135113    public string visibleParam = "visible";
 14
 6415    public bool isVisible => animator.GetBool(visibleParamHash);
 16
 17    private Animator animatorValue;
 18    private Animator animator
 19    {
 20        get
 21        {
 100622            if (animatorValue == null)
 23            {
 23724                animatorValue = GetComponent<Animator>();
 25            }
 26
 100627            return animatorValue;
 28        }
 29    }
 30    private int? visibleParamHashValue = null;
 31
 32    private int visibleParamHash
 33    {
 34        get
 35        {
 42836            if (!visibleParamHashValue.HasValue)
 23737                visibleParamHashValue = Animator.StringToHash(visibleParam);
 38
 42839            return visibleParamHashValue.Value;
 40        }
 41    }
 42
 43    public void Show(bool instant = false)
 44    {
 7045        animator.speed = animSpeedFactor;
 7046        animator.SetBool(visibleParamHash, true);
 47
 7048        if (instant)
 1149            animator.Update(10);
 7050    }
 51
 52    public void Hide(bool instant = false)
 53    {
 29454        animator.speed = animSpeedFactor;
 29455        animator.SetBool(visibleParamHash, false);
 56
 29457        if (instant)
 20358            animator.Update(10);
 29459    }
 60
 61    public void AnimEvent_HideFinished()
 62    {
 763        OnWillFinishHide?.Invoke(this);
 64
 765        if (disableAfterFadeOut)
 66        {
 367            gameObject?.SetActive(false);
 68        }
 769    }
 70
 171    public void AnimEvent_ShowFinished() { OnWillFinishStart?.Invoke(this); }
 72
 73    private void OnEnable()
 74    {
 29075        if ( hideOnEnable )
 76        {
 19777            Hide(true);
 78        }
 29079    }
 80}