| | 1 | | using UnityEngine; |
| | 2 | | using UnityEngine.UI; |
| | 3 | |
|
| | 4 | | namespace 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 | | { |
| 34 | 17 | | DataStore.i.HUDs.navmapVisible.OnChange += OnOpeningNavMap; |
| 34 | 18 | | DataStore.i.HUDs.navmapVisible.OnChange += SubscribeToMapRenderer; |
| | 19 | |
|
| 34 | 20 | | DataStore.i.exploreV2.isOpen.OnChange += OnExploreUiVisibilityChange; |
| 34 | 21 | | } |
| | 22 | |
|
| | 23 | | private void OnDestroy() |
| | 24 | | { |
| 34 | 25 | | DataStore.i.HUDs.navmapVisible.OnChange -= OnOpeningNavMap; |
| 34 | 26 | | DataStore.i.exploreV2.isOpen.OnChange -= OnExploreUiVisibilityChange; |
| | 27 | |
|
| 34 | 28 | | MapRenderer.i.MapVisibilityChanged -= OnNavMapLoaded; |
| 0 | 29 | | } |
| | 30 | |
|
| | 31 | | private void SubscribeToMapRenderer(bool current, bool previous) |
| | 32 | | { |
| 0 | 33 | | DataStore.i.HUDs.navmapVisible.OnChange -= SubscribeToMapRenderer; |
| 0 | 34 | | MapRenderer.i.MapVisibilityChanged += OnNavMapLoaded; |
| 0 | 35 | | } |
| | 36 | |
|
| | 37 | | private void OnExploreUiVisibilityChange(bool isOpen, bool _) |
| | 38 | | { |
| 0 | 39 | | if (!isOpen && !sectionsContent.enabled) |
| | 40 | | { |
| 0 | 41 | | SetImagesVisibility(visible: true); |
| | 42 | | } |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | private void OnOpeningNavMap(bool isShown, bool _) |
| | 46 | | { |
| 0 | 47 | | if (isShown) |
| | 48 | | { |
| 0 | 49 | | SetImagesVisibility(visible: false); |
| | 50 | | } |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | private void OnNavMapLoaded(bool _) => |
| 0 | 54 | | SetImagesVisibility(visible: true); |
| | 55 | |
|
| | 56 | | private void SetImagesVisibility(bool visible) |
| | 57 | | { |
| 0 | 58 | | sectionsContent.enabled = visible; |
| 0 | 59 | | radialGradient.enabled = visible; |
| 0 | 60 | | } |
| | 61 | | } |
| | 62 | | } |