< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
OnDestroy()0%110100%
AllUIVisible_OnChange(...)0%110100%
SetUIVisibility(...)0%550100%

File(s)

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

#LineLine coverage
 1using UnityEngine;
 2
 3/// <summary>
 4/// Attaching this component to a canvas, will hide/show it after triggering the ToggleUIVisibility input action.
 5/// </summary>
 6[RequireComponent(typeof(CanvasGroup))]
 7public class ShowHideUIByTrigger : MonoBehaviour
 8{
 9    private CanvasGroup canvasGroup;
 10    private ShowHideAnimator showHideAnimator;
 11    private Animator animator;
 12
 13    private void Awake()
 14    {
 39915        canvasGroup = GetComponent<CanvasGroup>();
 39916        showHideAnimator = GetComponent<ShowHideAnimator>();
 39917        animator = GetComponent<Animator>();
 39918        CommonScriptableObjects.allUIHidden.OnChange += AllUIVisible_OnChange;
 39919        SetUIVisibility(!CommonScriptableObjects.allUIHidden.Get());
 39920    }
 21
 79222    private void OnDestroy() { CommonScriptableObjects.allUIHidden.OnChange -= AllUIVisible_OnChange; }
 23
 5224    private void AllUIVisible_OnChange(bool current, bool previous) { SetUIVisibility(!current); }
 25
 26    private void SetUIVisibility(bool isVisible)
 27    {
 42528        if (showHideAnimator != null)
 2829            showHideAnimator.enabled = isVisible;
 30
 42531        if (animator != null)
 2832            animator.enabled = isVisible;
 33
 42534        canvasGroup.alpha = isVisible ? 1f : 0f;
 42535        canvasGroup.interactable = isVisible;
 42536        canvasGroup.blocksRaycasts = isVisible;
 42537    }
 38}