diff --git a/Explorer/Assets/DCL/Landscape/SatelliteFloor.cs b/Explorer/Assets/DCL/Landscape/SatelliteFloor.cs index 82e865716d..d93c9a601f 100644 --- a/Explorer/Assets/DCL/Landscape/SatelliteFloor.cs +++ b/Explorer/Assets/DCL/Landscape/SatelliteFloor.cs @@ -1,6 +1,7 @@ using DCL.Landscape.Settings; using DCL.MapRenderer.ComponentsFactory; using Cysharp.Threading.Tasks; +using Cysharp.Threading.Tasks.Triggers; using UnityEngine; using Utility; @@ -23,8 +24,9 @@ public class SatelliteFloor private MaterialPropertyBlock materialPropertyBlock; private LandscapeData landscapeData; - private bool satelliteRenderersEnabled; - private bool Initialized; + private bool initialized; + private bool currentlyInGenesis; + private bool debugSettingEnabled; public void Initialize(LandscapeData config) { @@ -34,6 +36,8 @@ public void Initialize(LandscapeData config) materialPropertyBlock = new MaterialPropertyBlock(); satelliteRenderers = new Renderer[SATELLITE_MAP_RESOLUTION * SATELLITE_MAP_RESOLUTION]; + + debugSettingEnabled = landscapeData.showSatelliteView; } public void Create(MapRendererTextureContainer textureContainer) @@ -67,22 +71,32 @@ public void Create(MapRendererTextureContainer textureContainer) satelliteRenderers[x + (y * SATELLITE_MAP_RESOLUTION)] = satelliteRenderer; } - Initialized = true; - SwitchVisibilityAsync(landscapeData.showSatelliteView); + initialized = true; + SwitchVisibility(); } - - public async UniTask SwitchVisibilityAsync(bool isVisible) + public void SetCurrentlyInGenesis(bool isGenesis) { - if (satelliteRenderersEnabled == isVisible) return; + currentlyInGenesis = isGenesis; + SwitchVisibility(); + } - if (!Initialized) - await UniTask.WaitUntil(() => Initialized); + public void SwitchVisibilitySetting(bool newValue) + { + debugSettingEnabled = newValue; + SwitchVisibility(); + } - satelliteRenderersEnabled = isVisible; + private void SwitchVisibility() + { + var newVisibilityState = debugSettingEnabled && currentlyInGenesis; + + if (!initialized) + return; + // Set rendering state for each renderer foreach (Renderer satelliteRenderer in satelliteRenderers) - satelliteRenderer.forceRenderingOff = !isVisible; + satelliteRenderer.forceRenderingOff = !newVisibilityState; } } } diff --git a/Explorer/Assets/DCL/Landscape/Systems/LandscapeDebugSystem.cs b/Explorer/Assets/DCL/Landscape/Systems/LandscapeDebugSystem.cs index 32ca674ab0..5b62a276ea 100644 --- a/Explorer/Assets/DCL/Landscape/Systems/LandscapeDebugSystem.cs +++ b/Explorer/Assets/DCL/Landscape/Systems/LandscapeDebugSystem.cs @@ -62,7 +62,7 @@ private void OnDetailToggle(ChangeEvent evt) private void OnSatelliteToggle(ChangeEvent evt) { - floor.SwitchVisibilityAsync(evt.newValue); + floor.SwitchVisibilitySetting(evt.newValue); } private void OnLoadRadiusConfirm(int value) diff --git a/Explorer/Assets/DCL/MapRenderer/MapLayers/Atlas/SatelliteAtlas/SatelliteChunkController.cs b/Explorer/Assets/DCL/MapRenderer/MapLayers/Atlas/SatelliteAtlas/SatelliteChunkController.cs index e7c94d4805..1ce11d67f6 100644 --- a/Explorer/Assets/DCL/MapRenderer/MapLayers/Atlas/SatelliteAtlas/SatelliteChunkController.cs +++ b/Explorer/Assets/DCL/MapRenderer/MapLayers/Atlas/SatelliteAtlas/SatelliteChunkController.cs @@ -1,4 +1,5 @@ -using CommunicationData.URLHelpers; +using System; +using CommunicationData.URLHelpers; using Cysharp.Threading.Tasks; using DCL.Diagnostics; using DCL.MapRenderer.ComponentsFactory; @@ -9,6 +10,7 @@ using Utility; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; +using Object = UnityEngine.Object; namespace DCL.MapRenderer.MapLayers.Atlas.SatelliteAtlas { @@ -77,8 +79,9 @@ public async UniTask LoadImageAsync(Vector2Int chunkId, float chunkWorldSize, Ca { texture = await textureTask; } - catch + catch (Exception e) { + ReportHub.LogException(e, ReportCategory.UI); texture = await Addressables.LoadAssetAsync($"{chunkId.x},{chunkId.y}").Task; } diff --git a/Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/SwitchRealmMiscVisibilityStartupOperation.cs b/Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/SwitchRealmMiscVisibilityStartupOperation.cs index eb1b2dafcb..92da1e8a23 100644 --- a/Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/SwitchRealmMiscVisibilityStartupOperation.cs +++ b/Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/SwitchRealmMiscVisibilityStartupOperation.cs @@ -20,7 +20,7 @@ public SwitchRealmMiscVisibilityStartupOperation(ILoadingStatus loadingStatus, I public async UniTask ExecuteAsync(AsyncLoadProcessReport report, CancellationToken ct) { float finalizationProgress = loadingStatus.SetCurrentStage(LoadingStatus.LoadingStage.EnvironmentMiscSetting); - await realmNavigator.SwitchMiscVisibilityAsync(); + realmNavigator.SwitchMiscVisibilityAsync(); report.SetProgress(finalizationProgress); return Result.SuccessResult(); } diff --git a/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs b/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs index 4add802c32..c8e3b28c73 100644 --- a/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs +++ b/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs @@ -34,7 +34,7 @@ UniTask TryInitializeTeleportToParcelAsync(Vector2Int parcel, Cancellati UniTask LoadTerrainAsync(AsyncLoadProcessReport loadReport, CancellationToken ct); - UniTask SwitchMiscVisibilityAsync(); + void SwitchMiscVisibilityAsync(); UniTask ChangeRealmAsync(URLDomain realm, CancellationToken ct); diff --git a/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs b/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs index e12ea9f88b..8fc6a72ba5 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs @@ -406,13 +406,13 @@ private async UniTask GenerateFixedScenesTerrainAsync(AsyncLoadProcessReport lan } } - public async UniTask SwitchMiscVisibilityAsync() + public void SwitchMiscVisibilityAsync() { bool isGenesis = IsGenesisRealm(); RealmChanged?.Invoke(isGenesis); mapRenderer.SetSharedLayer(MapLayer.PlayerMarker, isGenesis); - await satelliteFloor.SwitchVisibilityAsync(isGenesis); + satelliteFloor.SetCurrentlyInGenesis(isGenesis); roadsPlugin.RoadAssetPool?.SwitchVisibility(isGenesis); } @@ -446,7 +446,7 @@ public async UniTask ChangeRealmAsync(URLDomain realm, CancellationToken ct) { await realmController.SetRealmAsync(realm, ct); currentRealm = realm; - await SwitchMiscVisibilityAsync(); + SwitchMiscVisibilityAsync(); } private bool IsGenesisRealm() =>