< Summary

Class:DCL.NavMapLoadingLogo
Assembly:Navmap
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NavMap/NavMapLoadingLogo.cs
Covered lines:8
Uncovered lines:13
Coverable lines:21
Total lines:62
Line coverage:38% (8 of 21)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
OnDestroy()0%2.032080%
SubscribeToMapRenderer(...)0%2100%
OnExploreUiVisibilityChange(...)0%12300%
OnOpeningNavMap(...)0%6200%
OnNavMapLoaded(...)0%2100%
SetImagesVisibility(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NavMap/NavMapLoadingLogo.cs

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.UI;
 3
 4namespace DCL
 5{
 6    /// <summary>
 7    /// Hide white images when switching to NavMap.
 8    /// FIX issue #2071 <see cref="https://github.com/decentraland/unity-renderer/issues/2071"/>
 9    /// </summary>
 10    public class NavMapLoadingLogo : MonoBehaviour
 11    {
 12        [SerializeField] private Image sectionsContent;
 13        [SerializeField] private Image radialGradient;
 14
 15        private void Awake()
 16        {
 2917            DataStore.i.HUDs.navmapVisible.OnChange += OnOpeningNavMap;
 2918            DataStore.i.HUDs.navmapVisible.OnChange += SubscribeToMapRenderer;
 19
 2920            DataStore.i.exploreV2.isOpen.OnChange += OnExploreUiVisibilityChange;
 2921        }
 22
 23        private void OnDestroy()
 24        {
 2925            DataStore.i.HUDs.navmapVisible.OnChange -= OnOpeningNavMap;
 2926            DataStore.i.exploreV2.isOpen.OnChange -= OnExploreUiVisibilityChange;
 27
 2928            if (MapRenderer.i != null) { MapRenderer.i.MapVisibilityChanged -= OnNavMapLoaded; }
 2929        }
 30
 31        private void SubscribeToMapRenderer(bool current, bool previous)
 32        {
 033            DataStore.i.HUDs.navmapVisible.OnChange -= SubscribeToMapRenderer;
 034            MapRenderer.i.MapVisibilityChanged += OnNavMapLoaded;
 035        }
 36
 37        private void OnExploreUiVisibilityChange(bool isOpen, bool _)
 38        {
 039            if (!isOpen && !sectionsContent.enabled)
 40            {
 041                SetImagesVisibility(visible: true);
 42            }
 043        }
 44
 45        private void OnOpeningNavMap(bool isShown, bool _)
 46        {
 047            if (isShown)
 48            {
 049                SetImagesVisibility(visible: false);
 50            }
 051        }
 52
 53        private void OnNavMapLoaded(bool _) =>
 054            SetImagesVisibility(visible: true);
 55
 56        private void SetImagesVisibility(bool visible)
 57        {
 058            sectionsContent.enabled = visible;
 059            radialGradient.enabled = visible;
 060        }
 61    }
 62}