< 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    {
 89015        canvasGroup = GetComponent<CanvasGroup>();
 89016        showHideAnimator = GetComponent<ShowHideAnimator>();
 89017        animator = GetComponent<Animator>();
 89018        CommonScriptableObjects.allUIHidden.OnChange += AllUIVisible_OnChange;
 89019        SetUIVisibility(!CommonScriptableObjects.allUIHidden.Get());
 89020    }
 21
 178022    private void OnDestroy() { CommonScriptableObjects.allUIHidden.OnChange -= AllUIVisible_OnChange; }
 23
 3224    private void AllUIVisible_OnChange(bool current, bool previous) { SetUIVisibility(!current); }
 25
 26    private void SetUIVisibility(bool isVisible)
 27    {
 90628        if (showHideAnimator != null)
 27629            showHideAnimator.enabled = isVisible;
 30
 90631        if (animator != null)
 27632            animator.enabled = isVisible;
 33
 90634        canvasGroup.alpha = isVisible ? 1f : 0f;
 90635        canvasGroup.interactable = isVisible;
 90636        canvasGroup.blocksRaycasts = isVisible;
 90637    }
 38}