< 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    {
 40315        canvasGroup = GetComponent<CanvasGroup>();
 40316        showHideAnimator = GetComponent<ShowHideAnimator>();
 40317        animator = GetComponent<Animator>();
 40318        CommonScriptableObjects.allUIHidden.OnChange += AllUIVisible_OnChange;
 40319        SetUIVisibility(!CommonScriptableObjects.allUIHidden.Get());
 40320    }
 21
 80022    private void OnDestroy() { CommonScriptableObjects.allUIHidden.OnChange -= AllUIVisible_OnChange; }
 23
 30424    private void AllUIVisible_OnChange(bool current, bool previous) { SetUIVisibility(!current); }
 25
 26    private void SetUIVisibility(bool isVisible)
 27    {
 55528        if (showHideAnimator != null)
 5229            showHideAnimator.enabled = isVisible;
 30
 55531        if (animator != null)
 5232            animator.enabled = isVisible;
 33
 55534        canvasGroup.alpha = isVisible ? 1f : 0f;
 55535        canvasGroup.interactable = isVisible;
 55536        canvasGroup.blocksRaycasts = isVisible;
 55537    }
 38}