< 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    {
 86815        canvasGroup = GetComponent<CanvasGroup>();
 86816        showHideAnimator = GetComponent<ShowHideAnimator>();
 86817        animator = GetComponent<Animator>();
 86818        CommonScriptableObjects.allUIHidden.OnChange += AllUIVisible_OnChange;
 86819        SetUIVisibility(!CommonScriptableObjects.allUIHidden.Get());
 86820    }
 21
 173622    private void OnDestroy() { CommonScriptableObjects.allUIHidden.OnChange -= AllUIVisible_OnChange; }
 23
 4824    private void AllUIVisible_OnChange(bool current, bool previous) { SetUIVisibility(!current); }
 25
 26    private void SetUIVisibility(bool isVisible)
 27    {
 89228        if (showHideAnimator != null)
 21429            showHideAnimator.enabled = isVisible;
 30
 89231        if (animator != null)
 21432            animator.enabled = isVisible;
 33
 89234        canvasGroup.alpha = isVisible ? 1f : 0f;
 89235        canvasGroup.interactable = isVisible;
 89236        canvasGroup.blocksRaycasts = isVisible;
 89237    }
 38}