From cc2ff05a5f4856c2d7a791279cd7a7574d06fe98 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Molteni Date: Thu, 24 Oct 2024 12:07:22 -0300 Subject: [PATCH 01/24] chore: UnloadStrategy abstract class (#2508) --- .../Global/ResourceUnloadingPlugin.cs | 1 - .../Tests/ReleaseMemorySystemShould.cs | 80 +++++++++++-------- .../UnloadStrategies/IUnloadStrategy.cs | 34 -------- .../ReduceLoadingRadiusUnloadStrategy.cs | 9 ++- .../StandardUnloadStrategy.cs | 18 ++++- .../UnloadStrategies/UnloadStrategyBase.cs | 31 +++++++ ...egy.cs.meta => UnloadStrategyBase.cs.meta} | 0 .../UnloadStrategies/UnloadStrategyHandler.cs | 31 ++++--- .../UnloadUnusedAssetUnloadStrategy.cs | 15 ++-- 9 files changed, 119 insertions(+), 100 deletions(-) delete mode 100644 Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/IUnloadStrategy.cs create mode 100644 Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadStrategyBase.cs rename Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/{IUnloadStrategy.cs.meta => UnloadStrategyBase.cs.meta} (100%) diff --git a/Explorer/Assets/DCL/PluginSystem/Global/ResourceUnloadingPlugin.cs b/Explorer/Assets/DCL/PluginSystem/Global/ResourceUnloadingPlugin.cs index 09a7146375..82d53abe27 100644 --- a/Explorer/Assets/DCL/PluginSystem/Global/ResourceUnloadingPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/Global/ResourceUnloadingPlugin.cs @@ -1,5 +1,4 @@ using Arch.SystemGroups; -using Cysharp.Threading.Tasks; using DCL.Optimization.PerformanceBudgeting; using DCL.ResourcesUnloading; using DCL.ResourcesUnloading.UnloadStrategies; diff --git a/Explorer/Assets/DCL/ResourcesUnloading/Tests/ReleaseMemorySystemShould.cs b/Explorer/Assets/DCL/ResourcesUnloading/Tests/ReleaseMemorySystemShould.cs index a523ad7e8a..1b6fbda90f 100644 --- a/Explorer/Assets/DCL/ResourcesUnloading/Tests/ReleaseMemorySystemShould.cs +++ b/Explorer/Assets/DCL/ResourcesUnloading/Tests/ReleaseMemorySystemShould.cs @@ -10,6 +10,20 @@ namespace DCL.ResourcesUnloading.Tests { public class ReleaseMemorySystemShould : UnitySystemTestBase { + public class MockUnloadStrategy : UnloadStrategyBase + { + public int strategyRunCount; + + public override void RunStrategy() + { + strategyRunCount++; + } + + public MockUnloadStrategy(int failureThreshold) : base(failureThreshold) + { + } + } + private ReleaseMemorySystem releaseMemorySystem; @@ -17,10 +31,10 @@ public class ReleaseMemorySystemShould : UnitySystemTestBase(); cacheCleaner = Substitute.For(); - standardStrategy = Substitute.For(); - aggresiveStrategy = Substitute.For(); + standardStrategy = new MockUnloadStrategy(1); + aggresiveStrategy = new MockUnloadStrategy(1); unloadStrategies = new[] { @@ -52,15 +66,12 @@ public void SetUp() [TestCase(MemoryUsageStatus.FULL, 1)] public void UnloadCacheWhenMemoryUsageIsNotNormal(MemoryUsageStatus memoryUsageStatus, int callsAmount) { - // Arrange - memoryBudgetProvider.GetMemoryUsageStatus().Returns(memoryUsageStatus); - standardStrategy.FailedOverThreshold().Returns(true); - // Act + memoryBudgetProvider.GetMemoryUsageStatus().Returns(memoryUsageStatus); releaseMemorySystem.Update(0); // Assert - standardStrategy.Received(callsAmount).TryUnload(cacheCleaner); + Assert.AreEqual(callsAmount, standardStrategy.strategyRunCount); } [Test] @@ -68,22 +79,19 @@ public void ResetUnloadStrategyIndexWhenMemoryUsageIsNormal() { // Arrange memoryBudgetProvider.GetMemoryUsageStatus().Returns(MemoryUsageStatus.WARNING); - standardStrategy.FailedOverThreshold().Returns(true); // Act releaseMemorySystem.Update(0); // Assert - Assert.AreEqual(unloadStrategyHandler.currentUnloadStrategy, 1); - standardStrategy.Received(1).TryUnload(cacheCleaner); + Assert.AreEqual(1, standardStrategy.strategyRunCount); // Act releaseMemorySystem.Update(0); // Assert - Assert.AreEqual(unloadStrategyHandler.currentUnloadStrategy, 1); - standardStrategy.Received(1).TryUnload(cacheCleaner); - aggresiveStrategy.Received(1).TryUnload(cacheCleaner); + Assert.AreEqual(2, standardStrategy.strategyRunCount); + Assert.AreEqual(1, aggresiveStrategy.strategyRunCount); // Act @@ -91,9 +99,9 @@ public void ResetUnloadStrategyIndexWhenMemoryUsageIsNormal() releaseMemorySystem.Update(0); // Assert - Assert.AreEqual(unloadStrategyHandler.currentUnloadStrategy, 0); - standardStrategy.Received(1).ResetStrategy(); - aggresiveStrategy.Received(1).ResetStrategy(); + Assert.AreEqual(0, standardStrategy.currentFailureCount); + Assert.AreEqual(0, aggresiveStrategy.currentFailureCount); + Assert.IsFalse(standardStrategy.FaillingOverThreshold()); } [Test] @@ -101,30 +109,36 @@ public void IncreaseTierAggresiveness() { // Arrange memoryBudgetProvider.GetMemoryUsageStatus().Returns(MemoryUsageStatus.WARNING); - standardStrategy.FailedOverThreshold().Returns(true); - // Act releaseMemorySystem.Update(0); // Assert - Assert.AreEqual(unloadStrategyHandler.currentUnloadStrategy, 1); - standardStrategy.Received(1).TryUnload(cacheCleaner); + Assert.AreEqual(1, standardStrategy.strategyRunCount); // Act releaseMemorySystem.Update(0); - - // Assert - Assert.AreEqual(unloadStrategyHandler.currentUnloadStrategy, 1); - standardStrategy.Received(1).TryUnload(cacheCleaner); - aggresiveStrategy.Received(1).TryUnload(cacheCleaner); + // Assert + Assert.AreEqual(2, standardStrategy.strategyRunCount); + Assert.AreEqual(1, aggresiveStrategy.strategyRunCount); + } + + [Test] + public void SkipAggressiveStrategyIfPreviousDidNotFail() + { + // Arrange + memoryBudgetProvider.GetMemoryUsageStatus().Returns(MemoryUsageStatus.WARNING); + standardStrategy.failureThreshold = 5; + // Act - releaseMemorySystem.Update(0); - + + for (var i = 0; i < 5; i++) + releaseMemorySystem.Update(0); + + // Assert - Assert.AreEqual(unloadStrategyHandler.currentUnloadStrategy, 1); - standardStrategy.Received(1).TryUnload(cacheCleaner); - aggresiveStrategy.Received(2).TryUnload(cacheCleaner); + Assert.AreEqual(5, standardStrategy.strategyRunCount); + Assert.AreEqual(0, aggresiveStrategy.strategyRunCount); } diff --git a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/IUnloadStrategy.cs b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/IUnloadStrategy.cs deleted file mode 100644 index abebc7464e..0000000000 --- a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/IUnloadStrategy.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace DCL.ResourcesUnloading.UnloadStrategies -{ - - public interface IUnloadStrategy - { - void ResetStrategy(); - void TryUnload(ICacheCleaner cacheCleaner); - bool FailedOverThreshold(); - } - - public abstract class UnloadStrategy : IUnloadStrategy - { - - private int currentFailureCount; - private readonly int FAILURE_THRESHOLD = 250; - - public virtual void ResetStrategy() - { - currentFailureCount = 0; - } - - public bool FailedOverThreshold() - { - return currentFailureCount > FAILURE_THRESHOLD; - } - - public virtual void TryUnload(ICacheCleaner cacheCleaner) - { - cacheCleaner.UnloadCache(); - cacheCleaner.UpdateProfilingCounters(); - currentFailureCount++; - } - } -} \ No newline at end of file diff --git a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/ReduceLoadingRadiusUnloadStrategy.cs b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/ReduceLoadingRadiusUnloadStrategy.cs index da8855151c..030e4c8ade 100644 --- a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/ReduceLoadingRadiusUnloadStrategy.cs +++ b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/ReduceLoadingRadiusUnloadStrategy.cs @@ -1,23 +1,24 @@ using System; using ECS.Prioritization; +using UnityEngine; namespace DCL.ResourcesUnloading.UnloadStrategies { - public class ReduceLoadingRadiusUnloadStrategy : UnloadStrategy + public class ReduceLoadingRadiusUnloadStrategy : UnloadStrategyBase { private readonly IRealmPartitionSettings realmPartitionSettings; - public ReduceLoadingRadiusUnloadStrategy(IRealmPartitionSettings realmPartitionSettings) + public ReduceLoadingRadiusUnloadStrategy(int failureThreshold, IRealmPartitionSettings realmPartitionSettings) : + base(failureThreshold) { this.realmPartitionSettings = realmPartitionSettings; } - public override void TryUnload(ICacheCleaner cacheCleaner) + public override void RunStrategy() { //Forces MaxLoadingDistanceInParcels to the minimum value //TODO (Juani): A message warning that the distance has been silently modified realmPartitionSettings.MaxLoadingDistanceInParcels = realmPartitionSettings.MinLoadingDistanceInParcels; - base.TryUnload(cacheCleaner); } } diff --git a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/StandardUnloadStrategy.cs b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/StandardUnloadStrategy.cs index bc9deaaced..1011c7b44a 100644 --- a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/StandardUnloadStrategy.cs +++ b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/StandardUnloadStrategy.cs @@ -1,8 +1,20 @@ +using UnityEngine; + namespace DCL.ResourcesUnloading.UnloadStrategies { - public class StandardUnloadStrategy : UnloadStrategy + public class StandardUnloadStrategy : UnloadStrategyBase { - - + private readonly ICacheCleaner cacheCleaner; + + public override void RunStrategy() + { + cacheCleaner.UnloadCache(); + cacheCleaner.UpdateProfilingCounters(); + } + + public StandardUnloadStrategy(int failureThreshold, ICacheCleaner cacheCleaner) : base(failureThreshold) + { + this.cacheCleaner = cacheCleaner; + } } } \ No newline at end of file diff --git a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadStrategyBase.cs b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadStrategyBase.cs new file mode 100644 index 0000000000..2155baa89b --- /dev/null +++ b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadStrategyBase.cs @@ -0,0 +1,31 @@ +namespace DCL.ResourcesUnloading.UnloadStrategies +{ + public abstract class UnloadStrategyBase + { + internal int currentFailureCount; + internal int failureThreshold; + + protected UnloadStrategyBase(int failureThreshold) + { + this.failureThreshold = failureThreshold; + } + + public virtual void ResetStrategy() + { + currentFailureCount = 0; + } + + public bool FaillingOverThreshold() + { + return currentFailureCount >= failureThreshold; + } + + public abstract void RunStrategy(); + + public void TryUnload() + { + RunStrategy(); + currentFailureCount++; + } + } +} \ No newline at end of file diff --git a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/IUnloadStrategy.cs.meta b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadStrategyBase.cs.meta similarity index 100% rename from Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/IUnloadStrategy.cs.meta rename to Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadStrategyBase.cs.meta diff --git a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadStrategyHandler.cs b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadStrategyHandler.cs index c297780046..59e5ad728e 100644 --- a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadStrategyHandler.cs +++ b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadStrategyHandler.cs @@ -5,43 +5,40 @@ namespace DCL.ResourcesUnloading.UnloadStrategies { public class UnloadStrategyHandler { - internal IUnloadStrategy[] unloadStrategies; - internal int currentUnloadStrategy; + internal UnloadStrategyBase[] unloadStrategies; private readonly ICacheCleaner cacheCleaner; + private readonly int DEFAULT_FRAME_FAILURE_THRESHOLD = 250; + public UnloadStrategyHandler(IRealmPartitionSettings realmPartitionSettings, ICacheCleaner cacheCleaner) { this.cacheCleaner = cacheCleaner; - currentUnloadStrategy = 0; - //Higher the index, more aggressive the strategy - unloadStrategies = new IUnloadStrategy[] + //The base strategy at 0 will always run + //On top of that, we adds logic that run only if the previous one fails in an additive manner + unloadStrategies = new UnloadStrategyBase[] { - new StandardUnloadStrategy(), - new ReduceLoadingRadiusUnloadStrategy(realmPartitionSettings), - new UnloadUnusedAssetUnloadStrategy() + new StandardUnloadStrategy(DEFAULT_FRAME_FAILURE_THRESHOLD, cacheCleaner), + new ReduceLoadingRadiusUnloadStrategy(DEFAULT_FRAME_FAILURE_THRESHOLD, realmPartitionSettings), + new UnloadUnusedAssetUnloadStrategy(DEFAULT_FRAME_FAILURE_THRESHOLD) }; } public void TryUnload() { - unloadStrategies[currentUnloadStrategy].TryUnload(cacheCleaner); - if( unloadStrategies[currentUnloadStrategy].FailedOverThreshold()) - IncreaseAggresivenessTier(); + for (var i = unloadStrategies.Length - 1; i >= 0; i--) + { + if (i == 0 || unloadStrategies[i - 1].FaillingOverThreshold()) + unloadStrategies[i].TryUnload(); + } } - public void ResetToNormal() { - currentUnloadStrategy = 0; for (var i = 0; i < unloadStrategies.Length; i++) unloadStrategies[i].ResetStrategy(); } - private void IncreaseAggresivenessTier() - { - currentUnloadStrategy = Math.Clamp(currentUnloadStrategy + 1, 0, unloadStrategies.Length - 1); - } } } \ No newline at end of file diff --git a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadUnusedAssetUnloadStrategy.cs b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadUnusedAssetUnloadStrategy.cs index 865f9e427b..b189d47200 100644 --- a/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadUnusedAssetUnloadStrategy.cs +++ b/Explorer/Assets/DCL/ResourcesUnloading/UnloadStrategies/UnloadUnusedAssetUnloadStrategy.cs @@ -2,19 +2,18 @@ namespace DCL.ResourcesUnloading.UnloadStrategies { - public class UnloadUnusedAssetUnloadStrategy : UnloadStrategy + public class UnloadUnusedAssetUnloadStrategy : UnloadStrategyBase { - - private int FRAMES_UNTIL_UNLOAD_IS_INVOKED = 1000; + private readonly int FRAMES_UNTIL_UNLOAD_IS_INVOKED = 5_000; private int currentFrameCountForUnloadAssets; - - public UnloadUnusedAssetUnloadStrategy() + + public UnloadUnusedAssetUnloadStrategy(int failureThreshold) : base(failureThreshold) { //We equalize it so its invoked on first invocation of TryUnload currentFrameCountForUnloadAssets = FRAMES_UNTIL_UNLOAD_IS_INVOKED; } - public override void TryUnload(ICacheCleaner cacheCleaner) + public override void RunStrategy() { currentFrameCountForUnloadAssets++; if (currentFrameCountForUnloadAssets > FRAMES_UNTIL_UNLOAD_IS_INVOKED) @@ -22,14 +21,14 @@ public override void TryUnload(ICacheCleaner cacheCleaner) Resources.UnloadUnusedAssets(); currentFrameCountForUnloadAssets = 0; } - base.TryUnload(cacheCleaner); } - + public override void ResetStrategy() { base.ResetStrategy(); currentFrameCountForUnloadAssets = FRAMES_UNTIL_UNLOAD_IS_INVOKED; } + } } \ No newline at end of file From 2745511b5052ff46582ddb5eb959797fa82c4d55 Mon Sep 17 00:00:00 2001 From: davidejensen Date: Fri, 25 Oct 2024 08:09:44 +0200 Subject: [PATCH 02/24] fix: update audio for streams with no volume set (#2589) * fix: update audio for streams with no volume set * minor fix --- .../SDKComponents/MediaStream/MediaPlayerExtensions.cs | 9 +++++++++ .../MediaStream/Systems/UpdateMediaPlayerSystem.cs | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/MediaPlayerExtensions.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/MediaPlayerExtensions.cs index a806d33262..e281a904e6 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/MediaPlayerExtensions.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/MediaPlayerExtensions.cs @@ -22,7 +22,16 @@ public static void UpdateVolume(this MediaPlayer mediaPlayer, bool isCurrentScen else { if (!hasVolume) + //This following part is a workaround applied for the MacOS platform, the reason + //is related to the video and audio streams, the MacOS environment does not support + //the volume control for the video and audio streams, as it doesn’t allow to route audio + //from HLS through to Unity. This is a limitation of Apple’s AVFoundation framework + //Similar issue reported here https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/1086 +#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX + mediaPlayer.AudioVolume = MediaPlayerComponent.DEFAULT_VOLUME * volume; +#else mediaPlayer.AudioVolume = MediaPlayerComponent.DEFAULT_VOLUME; +#endif else if (!Mathf.Approximately(mediaPlayer.AudioVolume, volume)) mediaPlayer.AudioVolume = volume; } diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs index 6774b036d9..55ba658904 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs @@ -86,7 +86,7 @@ private void UpdateAudioStream(ref MediaPlayerComponent component, PBAudioStream if (component.State != VideoState.VsError) { - float actualVolume = sdkComponent.Volume * worldVolumePercentage * masterVolumePercentage; + float actualVolume = (sdkComponent.HasVolume ? sdkComponent.Volume : MediaPlayerComponent.DEFAULT_VOLUME) * worldVolumePercentage * masterVolumePercentage; component.MediaPlayer.UpdateVolume(sceneStateProvider.IsCurrent, sdkComponent.HasVolume, actualVolume); } @@ -101,7 +101,7 @@ private void UpdateVideoStream(ref MediaPlayerComponent component, PBVideoPlayer if (component.State != VideoState.VsError) { - float actualVolume = sdkComponent.Volume * worldVolumePercentage * masterVolumePercentage; + float actualVolume = (sdkComponent.HasVolume ? sdkComponent.Volume : MediaPlayerComponent.DEFAULT_VOLUME) * worldVolumePercentage * masterVolumePercentage; component.MediaPlayer.UpdateVolume(sceneStateProvider.IsCurrent, sdkComponent.HasVolume, actualVolume); } From 94ca2b4cec7bfe35ab09e3de7513acdc41ea19b9 Mon Sep 17 00:00:00 2001 From: lorenzo-ranciaffi <41125365+lorenzo-ranciaffi@users.noreply.github.com> Date: Fri, 25 Oct 2024 10:35:43 +0200 Subject: [PATCH 03/24] fix: support resolutions for vertical monitor orientation (#2593) --- .../ModuleControllers/ResolutionSettingsController.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Explorer/Assets/DCL/Settings/ModuleControllers/ResolutionSettingsController.cs b/Explorer/Assets/DCL/Settings/ModuleControllers/ResolutionSettingsController.cs index ff55656342..3a72c8791f 100644 --- a/Explorer/Assets/DCL/Settings/ModuleControllers/ResolutionSettingsController.cs +++ b/Explorer/Assets/DCL/Settings/ModuleControllers/ResolutionSettingsController.cs @@ -51,11 +51,14 @@ private void LoadResolutionOptions() // Exclude all resolutions that are not 16:9 or 16:10 if (!ResolutionUtils.IsResolutionCompatibleWithAspectRatio(resolution.width, resolution.height, 16, 9) && - !ResolutionUtils.IsResolutionCompatibleWithAspectRatio(resolution.width, resolution.height, 16, 10)) + !ResolutionUtils.IsResolutionCompatibleWithAspectRatio(resolution.width, resolution.height, 16, 10) && + //Check for vertical monitors as well + !ResolutionUtils.IsResolutionCompatibleWithAspectRatio(resolution.width, resolution.height, 9, 16) && + !ResolutionUtils.IsResolutionCompatibleWithAspectRatio(resolution.width, resolution.height, 10, 16)) continue; - // Exclude all resolutions width less than 1024 - if (resolution.width <= 1024) + // Exclude all resolutions width less than 1024 (same for height in case of vertical monitors) + if (Mathf.Min(resolution.width, resolution.height) <= 1024) continue; // Exclude possible duplicates From 278ba86a32615ecbd896de1c1ac69829a5fb5958 Mon Sep 17 00:00:00 2001 From: Nick Khalow <71646502+NickKhalow@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:36:11 +0300 Subject: [PATCH 04/24] replace to -ea domain (#2583) --- .../DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs b/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs index f6e34e8d84..d877170655 100644 --- a/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs +++ b/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs @@ -53,7 +53,7 @@ private static string RawUrl(DecentralandUrl decentralandUrl) => DecentralandUrl.Market => $"https://market.decentraland.{ENV}", // All ABs are in org DecentralandUrl.AssetBundlesCDN => $"https://ab-cdn.decentraland.{ENV}", - DecentralandUrl.ArchipelagoStatus => $"https://archipelago-stats.decentraland.{ENV}/status", + DecentralandUrl.ArchipelagoStatus => $"https://archipelago-ea-stats.decentraland.{ENV}/status", DecentralandUrl.GatekeeperStatus => $"https://comms-gatekeeper.decentraland.{ENV}/status", DecentralandUrl.Genesis => $"https://realm-provider-ea.decentraland.{ENV}/main", DecentralandUrl.Badges => $"https://badges.decentraland.{ENV}", From a7b1dd4ae4bf30cb18869c46702691d5933a6251 Mon Sep 17 00:00:00 2001 From: Fran Colarich <56565104+fcolarich@users.noreply.github.com> Date: Sat, 26 Oct 2024 00:45:57 +0200 Subject: [PATCH 05/24] Fix: Fixed cursor sizes on Mac (#2604) --- Explorer/Assets/DCL/Input/Assets/Cursor.png.meta | 2 +- Explorer/Assets/DCL/Input/Assets/CursorInteractive.png.meta | 2 +- Explorer/Assets/DCL/Input/Assets/CursorSettings.asset | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Explorer/Assets/DCL/Input/Assets/Cursor.png.meta b/Explorer/Assets/DCL/Input/Assets/Cursor.png.meta index fe4fc320c3..19ccfe7138 100644 --- a/Explorer/Assets/DCL/Input/Assets/Cursor.png.meta +++ b/Explorer/Assets/DCL/Input/Assets/Cursor.png.meta @@ -69,7 +69,7 @@ TextureImporter: platformSettings: - serializedVersion: 3 buildTarget: DefaultTexturePlatform - maxTextureSize: 64 + maxTextureSize: 32 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 diff --git a/Explorer/Assets/DCL/Input/Assets/CursorInteractive.png.meta b/Explorer/Assets/DCL/Input/Assets/CursorInteractive.png.meta index e32bfad7e6..ad2c89a405 100644 --- a/Explorer/Assets/DCL/Input/Assets/CursorInteractive.png.meta +++ b/Explorer/Assets/DCL/Input/Assets/CursorInteractive.png.meta @@ -69,7 +69,7 @@ TextureImporter: platformSettings: - serializedVersion: 3 buildTarget: DefaultTexturePlatform - maxTextureSize: 64 + maxTextureSize: 32 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 diff --git a/Explorer/Assets/DCL/Input/Assets/CursorSettings.asset b/Explorer/Assets/DCL/Input/Assets/CursorSettings.asset index 379e0ef701..a4ccfde8a0 100644 --- a/Explorer/Assets/DCL/Input/Assets/CursorSettings.asset +++ b/Explorer/Assets/DCL/Input/Assets/CursorSettings.asset @@ -17,10 +17,10 @@ MonoBehaviour: m_SubObjectName: m_SubObjectType: m_EditorAssetChanged: 1 - k__BackingField: {x: 5, y: 3} + k__BackingField: {x: 2.5, y: 1.5} k__BackingField: m_AssetGUID: 23dcf75316411d344be316dc2cb0e41f m_SubObjectName: m_SubObjectType: m_EditorAssetChanged: 0 - k__BackingField: {x: 9, y: 3} + k__BackingField: {x: 4.5, y: 1.5} From 79806f3424326823365b578b5c366958b6a70861 Mon Sep 17 00:00:00 2001 From: Nicolas Lorusso <56365551+lorux0@users.noreply.github.com> Date: Fri, 25 Oct 2024 19:47:15 -0300 Subject: [PATCH 06/24] fix: emotes spam stuck (#2573) --- .../Helpers/ApplicationParamsEmoteProvider.cs | 45 +++++++++++++++++++ .../ApplicationParamsEmoteProvider.cs.meta | 3 ++ .../ApplicationParametersWearablesProvider.cs | 22 +++++---- .../BackpackCharacterPreviewController.cs | 15 ++++--- .../CharacterPreviewController.cs | 37 ++++++++++++--- .../CharacterPreviewControllerBase.cs | 21 ++++++--- .../Global/Dynamic/DynamicWorldContainer.cs | 3 +- 7 files changed, 120 insertions(+), 26 deletions(-) create mode 100644 Explorer/Assets/DCL/AvatarRendering/Emotes/Helpers/ApplicationParamsEmoteProvider.cs create mode 100644 Explorer/Assets/DCL/AvatarRendering/Emotes/Helpers/ApplicationParamsEmoteProvider.cs.meta diff --git a/Explorer/Assets/DCL/AvatarRendering/Emotes/Helpers/ApplicationParamsEmoteProvider.cs b/Explorer/Assets/DCL/AvatarRendering/Emotes/Helpers/ApplicationParamsEmoteProvider.cs new file mode 100644 index 0000000000..4aaf789597 --- /dev/null +++ b/Explorer/Assets/DCL/AvatarRendering/Emotes/Helpers/ApplicationParamsEmoteProvider.cs @@ -0,0 +1,45 @@ +using CommunicationData.URLHelpers; +using Cysharp.Threading.Tasks; +using DCL.AvatarRendering.Loading.Components; +using DCL.Web3; +using Global.AppArgs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +namespace DCL.AvatarRendering.Emotes +{ + public class ApplicationParamsEmoteProvider : IEmoteProvider + { + private readonly IAppArgs appArgs; + private readonly IEmoteProvider source; + + public ApplicationParamsEmoteProvider(IAppArgs appArgs, + IEmoteProvider source) + { + this.appArgs = appArgs; + this.source = source; + } + + public async UniTask GetOwnedEmotesAsync(Web3Address userId, CancellationToken ct, + IEmoteProvider.OwnedEmotesRequestOptions requestOptions, + List output) + { + if (!appArgs.TryGetValue("self-preview-emotes", out string? emotesCsv)) + return await source.GetOwnedEmotesAsync(userId, ct, requestOptions, output); + + URN[] pointers = emotesCsv!.Split(',', StringSplitOptions.RemoveEmptyEntries) + .Select(s => new URN(s)) + .ToArray(); + + await UniTask.WhenAll(GetEmotesAsync(pointers, BodyShape.MALE, ct, output), + GetEmotesAsync(pointers, BodyShape.FEMALE, ct, output)); + + return output.Count; + } + + public UniTask GetEmotesAsync(IReadOnlyCollection emoteIds, BodyShape bodyShape, CancellationToken ct, List output) => + source.GetEmotesAsync(emoteIds, bodyShape, ct, output); + } +} diff --git a/Explorer/Assets/DCL/AvatarRendering/Emotes/Helpers/ApplicationParamsEmoteProvider.cs.meta b/Explorer/Assets/DCL/AvatarRendering/Emotes/Helpers/ApplicationParamsEmoteProvider.cs.meta new file mode 100644 index 0000000000..17af71086e --- /dev/null +++ b/Explorer/Assets/DCL/AvatarRendering/Emotes/Helpers/ApplicationParamsEmoteProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9ac8d76a492e445abdcceb68bd16ef84 +timeCreated: 1729690669 \ No newline at end of file diff --git a/Explorer/Assets/DCL/AvatarRendering/Wearables/ApplicationParametersWearablesProvider.cs b/Explorer/Assets/DCL/AvatarRendering/Wearables/ApplicationParametersWearablesProvider.cs index acdb3d9f13..124ce5a38f 100644 --- a/Explorer/Assets/DCL/AvatarRendering/Wearables/ApplicationParametersWearablesProvider.cs +++ b/Explorer/Assets/DCL/AvatarRendering/Wearables/ApplicationParametersWearablesProvider.cs @@ -18,17 +18,17 @@ namespace DCL.AvatarRendering.Wearables { public class ApplicationParametersWearablesProvider : IWearablesProvider { - private readonly IAppArgs applicationParametersParser; + private readonly IAppArgs appArgs; private readonly IWearablesProvider source; private readonly World world; private readonly string[] allWearableCategories = WearablesConstants.CATEGORIES_PRIORITY.ToArray(); private readonly List resultWearablesBuffer = new (); - public ApplicationParametersWearablesProvider(IAppArgs applicationParametersParser, + public ApplicationParametersWearablesProvider(IAppArgs appArgs, IWearablesProvider source, World world) { - this.applicationParametersParser = applicationParametersParser; + this.appArgs = appArgs; this.source = source; this.world = world; } @@ -41,14 +41,18 @@ public ApplicationParametersWearablesProvider(IAppArgs applicationParametersPars string? name = null, List? results = null) { - if (!applicationParametersParser.TryGetValue("self-preview-wearables", out string? wearablesCsv)) + if (!appArgs.TryGetValue("self-preview-wearables", out string? wearablesCsv)) return await source.GetAsync(pageSize, pageNumber, ct, sortingField, orderBy, category, collectionType, name, results); URN[] pointers = wearablesCsv!.Split(',', StringSplitOptions.RemoveEmptyEntries) - .Select(s => new URN(s)).ToArray(); + .Select(s => new URN(s)) + .ToArray(); - IReadOnlyCollection? maleWearables = await RequestPointersAsync(pointers, BodyShape.MALE, ct); - IReadOnlyCollection? femaleWearables = await RequestPointersAsync(pointers, BodyShape.FEMALE, ct); + (IReadOnlyCollection? maleWearables, IReadOnlyCollection? femaleWearables) = + await UniTask.WhenAll(RequestPointersAsync(pointers, BodyShape.MALE, ct), + RequestPointersAsync(pointers, BodyShape.FEMALE, ct)); + + results ??= new List(); lock (resultWearablesBuffer) { @@ -61,7 +65,8 @@ public ApplicationParametersWearablesProvider(IAppArgs applicationParametersPars resultWearablesBuffer.AddRange(femaleWearables); int pageIndex = pageNumber - 1; - return (resultWearablesBuffer.Skip(pageIndex * pageSize).Take(pageSize).ToArray(), resultWearablesBuffer.Count); + results.AddRange(resultWearablesBuffer.Skip(pageIndex * pageSize).Take(pageSize)); + return (results, resultWearablesBuffer.Count); } } @@ -70,6 +75,7 @@ public ApplicationParametersWearablesProvider(IAppArgs applicationParametersPars CancellationToken ct) { var promise = WearablePromise.Create(world, + // We pass all categories as force renderer to force the download of all of them // Otherwise they will be skipped if any wearable is hiding the category WearableComponentsUtils.CreateGetWearablesByPointersIntention(bodyShape, pointers, allWearableCategories), diff --git a/Explorer/Assets/DCL/Backpack/CharacterPreview/BackpackCharacterPreviewController.cs b/Explorer/Assets/DCL/Backpack/CharacterPreview/BackpackCharacterPreviewController.cs index c46d21dd57..9e55882eec 100644 --- a/Explorer/Assets/DCL/Backpack/CharacterPreview/BackpackCharacterPreviewController.cs +++ b/Explorer/Assets/DCL/Backpack/CharacterPreview/BackpackCharacterPreviewController.cs @@ -131,6 +131,7 @@ private void OnColorChange(Color newColor, string category) previewAvatarModel.SkinColor = newColor; break; } + OnModelUpdated(); } @@ -180,14 +181,18 @@ async UniTaskVoid EnsureEmoteAndPlayItAsync(CancellationToken ct) { URN urn = emote.GetUrn().Shorten(); - // In case you want to preview an emote, it might happen that the asset bundles are not loaded - // By adding the emote we force to fetch them if missing + // Ensure assets are loaded for the emote if (!previewAvatarModel.Emotes?.Contains(urn) ?? true) { previewAvatarModel.Emotes!.Add(urn); - await ShowLoadingSpinnerAndUpdateAvatarAsync(ct); - // Remove the emote so it stays original - previewAvatarModel.Emotes!.Remove(urn); + + try { await ShowLoadingSpinnerAndUpdateAvatarAsync(ct); } + catch (OperationCanceledException) { } + finally + { + // Remove the emote so it stays original + previewAvatarModel.Emotes!.Remove(urn); + } } PlayEmote(urn); diff --git a/Explorer/Assets/DCL/Character/CharacterPreview/CharacterPreviewController.cs b/Explorer/Assets/DCL/Character/CharacterPreview/CharacterPreviewController.cs index 7a55fc1794..66da3feaf2 100644 --- a/Explorer/Assets/DCL/Character/CharacterPreview/CharacterPreviewController.cs +++ b/Explorer/Assets/DCL/Character/CharacterPreview/CharacterPreviewController.cs @@ -71,6 +71,8 @@ public void Dispose() public UniTask UpdateAvatarAsync(CharacterPreviewAvatarModel avatarModel, CancellationToken ct) { + ct.ThrowIfCancellationRequested(); + ref AvatarShapeComponent avatarShape = ref globalWorld.Get(characterPreviewEntity); avatarShape.SkinColor = avatarModel.SkinColor; @@ -87,25 +89,50 @@ public UniTask UpdateAvatarAsync(CharacterPreviewAvatarModel avatarModel, Cancel PartitionComponent.TOP_PRIORITY ); - globalWorld.Create(EmotePromise.Create(globalWorld, + Entity emotePromiseEntity = globalWorld.Create(EmotePromise.Create(globalWorld, EmoteComponentsUtils.CreateGetEmotesByPointersIntention(avatarShape.BodyShape, avatarModel.Emotes ?? (IReadOnlyCollection)Array.Empty()), PartitionComponent.TOP_PRIORITY)); + EntityReference emotePromiseRef = globalWorld.Reference(emotePromiseEntity); + avatarShape.IsDirty = true; - return WaitForAvatarInstantiatedAsync(ct); + return WaitForAvatarInstantiatedAsync(emotePromiseRef, ct); } - private async UniTask WaitForAvatarInstantiatedAsync(CancellationToken ct) + private async UniTask WaitForAvatarInstantiatedAsync(EntityReference emotePromiseEntity, CancellationToken ct) { - while (!ct.IsCancellationRequested && globalWorld.Get(characterPreviewEntity).IsDirty) + World world = globalWorld; + Entity avatarEntity = characterPreviewEntity; + + while (!IsAvatarLoaded() || !IsEmoteLoaded()) await UniTask.Yield(ct); + + ct.ThrowIfCancellationRequested(); + + return; + + bool IsAvatarLoaded() + { + return !world.Get(avatarEntity).IsDirty; + } + + bool IsEmoteLoaded() + { + return !emotePromiseEntity.IsAlive(world) + || world.Get(emotePromiseEntity).IsConsumed; + } } public void PlayEmote(string emoteId) { - globalWorld.Add(characterPreviewEntity, new CharacterEmoteIntent { EmoteId = emoteId, TriggerSource = TriggerSource.PREVIEW}); + var intent = new CharacterEmoteIntent { EmoteId = emoteId, TriggerSource = TriggerSource.PREVIEW }; + + if (globalWorld.Has(characterPreviewEntity)) + globalWorld.Set(characterPreviewEntity, intent); + else + globalWorld.Add(characterPreviewEntity, intent); } public void StopEmotes() diff --git a/Explorer/Assets/DCL/Character/CharacterPreview/CharacterPreviewControllerBase.cs b/Explorer/Assets/DCL/Character/CharacterPreview/CharacterPreviewControllerBase.cs index 318d6be50c..71babf4b0a 100644 --- a/Explorer/Assets/DCL/Character/CharacterPreview/CharacterPreviewControllerBase.cs +++ b/Explorer/Assets/DCL/Character/CharacterPreview/CharacterPreviewControllerBase.cs @@ -220,7 +220,18 @@ private void OnAnyCharacterPreviewHide(CharacterPreviewControllerBase characterP protected void OnModelUpdated() { updateModelCancellationToken = updateModelCancellationToken.SafeRestart(); - ShowLoadingSpinnerAndUpdateAvatarAsync(updateModelCancellationToken.Token).Forget(); + + UpdateModelAsync(updateModelCancellationToken.Token).Forget(); + return; + + async UniTaskVoid UpdateModelAsync(CancellationToken ct) + { + try + { + await ShowLoadingSpinnerAndUpdateAvatarAsync(ct); + } + catch (OperationCanceledException) { } + } } protected async UniTask ShowLoadingSpinnerAndUpdateAvatarAsync(CancellationToken ct) @@ -232,7 +243,6 @@ protected async UniTask ShowLoadingSpinnerAndUpdateAvatarAsync(CancellationToken DisableSpinner(spinner); } - private void DisableSpinner(GameObject spinner) { spinner.SetActive(false); @@ -250,11 +260,8 @@ private GameObject EnableSpinner() return spinner; } - private async UniTask UpdateAvatarAsync(CharacterPreviewAvatarModel model, CancellationToken ct) - { - try { await (previewController?.UpdateAvatarAsync(model, ct) ?? UniTask.CompletedTask); } - catch (OperationCanceledException) { } - } + private async UniTask UpdateAvatarAsync(CharacterPreviewAvatarModel model, CancellationToken ct) => + await (previewController?.UpdateAvatarAsync(model, ct) ?? UniTask.CompletedTask); protected void StopEmotes() => previewController?.StopEmotes(); diff --git a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs index f21e5a552f..787026e3a1 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs @@ -256,7 +256,8 @@ IMultiPool MultiPoolFactory() => var selfProfile = new SelfProfile(container.ProfileRepository, identityCache, equippedWearables, wearableCatalog, emotesCache, equippedEmotes, forceRender, selfEmotes); - IEmoteProvider emoteProvider = new EcsEmoteProvider(globalWorld, staticContainer.RealmData); + IEmoteProvider emoteProvider = new ApplicationParamsEmoteProvider(appArgs, + new EcsEmoteProvider(globalWorld, staticContainer.RealmData)); container.wearablesProvider = new ApplicationParametersWearablesProvider(appArgs, new ECSWearablesProvider(identityCache, globalWorld), From 34fd8dfccc386c2c903638e01318f1658f195c5d Mon Sep 17 00:00:00 2001 From: davidejensen Date: Mon, 28 Oct 2024 08:55:51 +0100 Subject: [PATCH 07/24] fixed mime header for video streams (#2545) * fixed mime header for video streams * Minor changes to query param condition * Minor comment addition --- .../MediaStream/Components/MediaPlayerComponent.cs | 1 + .../MediaStream/Systems/CreateMediaPlayerSystem.cs | 1 + .../MediaStream/Systems/UpdateMediaPlayerSystem.cs | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/Components/MediaPlayerComponent.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/Components/MediaPlayerComponent.cs index f6678cc273..f88da35c14 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/Components/MediaPlayerComponent.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/Components/MediaPlayerComponent.cs @@ -16,6 +16,7 @@ public struct MediaPlayerComponent public MediaPlayer MediaPlayer; public string URL; + public bool IsFromContentServer; public VideoState State; public double PreviousPlayingTimeCheck; public float LastStateChangeTime; diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/CreateMediaPlayerSystem.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/CreateMediaPlayerSystem.cs index 58a1759fd0..3ad6784eab 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/CreateMediaPlayerSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/CreateMediaPlayerSystem.cs @@ -83,6 +83,7 @@ private MediaPlayerComponent CreateMediaPlayerComponent(Entity entity, string ur { MediaPlayer = mediaPlayerPool.Get(), URL = url, + IsFromContentServer = url.Contains("/content/contents"), State = url.IsValidUrl() ? VideoState.VsNone : VideoState.VsError, PreviousPlayingTimeCheck = -1, LastStateChangeTime = -1, diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs index 55ba658904..fdb3d75599 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs @@ -165,7 +165,10 @@ private static void ConsumePromise(ref MediaPlayerComponent component, bool auto if (component.OpenMediaPromise.IsReachableConsume(component.URL)) { - component.MediaPlayer.OpenMedia(MediaPathType.AbsolutePathOrURL, component.URL, autoPlay); + //The problem is that video files coming from our content server are flagged as application/octet-stream, + //but mac OS without a specific content type cannot play them. (more info here https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/2008 ) + //This adds a query param for video files from content server to force the correct content type + component.MediaPlayer.OpenMedia(MediaPathType.AbsolutePathOrURL, component.IsFromContentServer ? string.Format("{0}?includeMimeType", component.URL) : component.URL, autoPlay); if (sdkVideoComponent != null) onOpened?.Invoke(component.MediaPlayer, sdkVideoComponent); From 8418d9d8da8a63432924e59e853995d4ce31fd9f Mon Sep 17 00:00:00 2001 From: Ani <139157886+anicalbano@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:08:36 -0300 Subject: [PATCH 08/24] Update bug_report.md (#2634) Signed-off-by: Ani <139157886+anicalbano@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/bug_report.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 5e1e82cd8d..4b3ae8ec70 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,7 +8,7 @@ assignees: '' --- -### **Explorer Alpha build versions:** +### **Build version:** ### **Issue Description:** @@ -20,14 +20,18 @@ assignees: '' 2. 3. -### **Expected behaviour:** +### **Expected behavior:** ### **Current behaviour:** +### **Repro Index:** + + #### **Evidence:** + #### **Additional Notes:** From 4520005f5317057496d09b5f7b86131fb78d55aa Mon Sep 17 00:00:00 2001 From: Fran Colarich <56565104+fcolarich@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:39:03 +0100 Subject: [PATCH 09/24] fix: tweens update with scene cycle (#2570) * Make tween update the transform as well as the SDK value and update after transform update as well * Update TweenUpdaterSystem.cs * Fixed tween * Streamlined tweens logic * Update TweenSDKComponentHelper.cs --- .../DCL/PluginSystem/World/TweenPlugin.cs | 3 +- .../Components/CustomTweener/CustomTweener.cs | 17 ++----- .../CustomTweener/CustomTweenerImpl.cs | 36 ++++++++------ .../CustomTweener/ICustomTweener.cs | 5 +- .../Components/CustomTweener/TweenerPool.cs | 4 +- .../Tween/Systems/TweenSDKComponentHelper.cs | 30 ++++++++---- .../Tween/Systems/TweenUpdaterSystem.cs | 49 +++++++++++-------- .../Tween/Tests/TweenUpdaterSystemShould.cs | 3 +- 8 files changed, 84 insertions(+), 63 deletions(-) diff --git a/Explorer/Assets/DCL/PluginSystem/World/TweenPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/TweenPlugin.cs index 18bea1ebf2..f66ece334e 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/TweenPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/TweenPlugin.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Threading; using DCL.SDKComponents.Tween.Components; +using SceneRunner.Scene; using UnityEngine.Pool; namespace DCL.PluginSystem.World @@ -28,7 +29,7 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder builder, { ResetDirtyFlagSystem.InjectToWorld(ref builder); TweenLoaderSystem.InjectToWorld(ref builder); - var tweenUpdaterSystem = TweenUpdaterSystem.InjectToWorld(ref builder, sharedDependencies.EcsToCRDTWriter, tweenerPool, sharedDependencies.EcsSystemsGate); + var tweenUpdaterSystem = TweenUpdaterSystem.InjectToWorld(ref builder, sharedDependencies.EcsToCRDTWriter, tweenerPool, sharedDependencies.EcsSystemsGate, sharedDependencies.SceneStateProvider); finalizeWorldSystems.Add(tweenUpdaterSystem); } } diff --git a/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/CustomTweener.cs b/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/CustomTweener.cs index 63189b26be..eb4e701b95 100644 --- a/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/CustomTweener.cs +++ b/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/CustomTweener.cs @@ -15,13 +15,10 @@ public abstract class CustomTweener : ICustomTweener protected T currentValue; private TweenerCore core; - protected Vector3 startPosition; - protected Quaternion startRotation; - protected Vector3 startScale; - protected abstract TweenerCore CreateTweener(T start, T end, float duration); - protected abstract (T, T) GetTweenValues(PBTween pbTween, SDKTransform startTransform); - public abstract void SetResult(ref SDKTransform sdkTransform); + protected abstract (T, T) GetTweenValues(PBTween pbTween); + public abstract void UpdateSDKTransform(ref SDKTransform sdkTransform); + public abstract void UpdateTransform(Transform transform); public void Play() => core.Play(); @@ -46,16 +43,12 @@ public void DoTween(Ease ease, float tweenModelCurrentTime, bool isPlaying) core.SetEase(ease).SetAutoKill(false).OnComplete(() => { finished = true; }).Goto(tweenModelCurrentTime, isPlaying); } - public void Initialize(PBTween pbTween, SDKTransform sdkTransform, float durationInSeconds) + public void Initialize(PBTween pbTween, float durationInSeconds) { core?.Kill(); finished = false; - startPosition = sdkTransform.Position; - startRotation = sdkTransform.Rotation; - startScale = sdkTransform.Scale; - - var tweenValues = GetTweenValues(pbTween, sdkTransform); + var tweenValues = GetTweenValues(pbTween); core = CreateTweener(tweenValues.Item1, tweenValues.Item2, durationInSeconds); } } diff --git a/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/CustomTweenerImpl.cs b/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/CustomTweenerImpl.cs index 0a9fa98c8f..167fc1534e 100644 --- a/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/CustomTweenerImpl.cs +++ b/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/CustomTweenerImpl.cs @@ -16,21 +16,22 @@ protected override TweenerCore CreateTweener(Ve return DOTween.To(() => currentValue, x => currentValue = x, end, duration); } - protected override (Vector3, Vector3) GetTweenValues(PBTween pbTween, SDKTransform startTransform) + protected override (Vector3, Vector3) GetTweenValues(PBTween pbTween) { Vector3 start = PrimitivesConversionExtensions.PBVectorToUnityVector(pbTween.Move.Start); Vector3 end = PrimitivesConversionExtensions.PBVectorToUnityVector(pbTween.Move.End); - startTransform.Position.Value = start; currentValue = start; return (start, end); } - public override void SetResult(ref SDKTransform sdkTransform) + public override void UpdateSDKTransform(ref SDKTransform sdkTransform) { sdkTransform.Position.Value = currentValue; + } - sdkTransform.Rotation.Value = startRotation; - sdkTransform.Scale = startScale; + public override void UpdateTransform(Transform transform) + { + transform.localPosition = currentValue; } } @@ -41,31 +42,32 @@ protected override TweenerCore CreateTweener(Ve return DOTween.To(() => currentValue, x => currentValue = x, end, duration); } - protected override (Vector3, Vector3) GetTweenValues(PBTween pbTween, SDKTransform startTransform) + protected override (Vector3, Vector3) GetTweenValues(PBTween pbTween) { Vector3 start = PrimitivesConversionExtensions.PBVectorToUnityVector(pbTween.Scale.Start); Vector3 end = PrimitivesConversionExtensions.PBVectorToUnityVector(pbTween.Scale.End); - startTransform.Scale = start; currentValue = start; return (start, end); } - public override void SetResult(ref SDKTransform sdkTransform) + public override void UpdateSDKTransform(ref SDKTransform sdkTransform) { sdkTransform.Scale = currentValue; + } - sdkTransform.Position.Value = startPosition; - sdkTransform.Rotation.Value = startRotation; + public override void UpdateTransform(Transform transform) + { + transform.localScale = currentValue; } + } public class RotationTweener : CustomTweener { - protected override (Quaternion, Quaternion) GetTweenValues(PBTween pbTween, SDKTransform startTransform) + protected override (Quaternion, Quaternion) GetTweenValues(PBTween pbTween) { Quaternion start = PrimitivesConversionExtensions.PBQuaternionToUnityQuaternion(pbTween.Rotate.Start); Quaternion end = PrimitivesConversionExtensions.PBQuaternionToUnityQuaternion(pbTween.Rotate.End); - startTransform.Rotation.Value = start; currentValue = start; return (start, end); } @@ -77,11 +79,15 @@ protected override TweenerCore CreateTweener( end, duration); } - public override void SetResult(ref SDKTransform sdkTransform) + public override void UpdateSDKTransform(ref SDKTransform sdkTransform) { sdkTransform.Rotation.Value = currentValue; - sdkTransform.Position.Value = startPosition; - sdkTransform.Scale = startScale; } + + public override void UpdateTransform(Transform transform) + { + transform.localRotation = currentValue; + } + } } diff --git a/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/ICustomTweener.cs b/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/ICustomTweener.cs index 41975052ca..5de0e2ae65 100644 --- a/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/ICustomTweener.cs +++ b/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/ICustomTweener.cs @@ -15,7 +15,8 @@ public interface ICustomTweener bool IsFinished(); bool IsActive(); - void Initialize(PBTween pbTween, SDKTransform sdkTransform, float durationInSeconds); - void SetResult(ref SDKTransform sdkTransform); + void Initialize(PBTween pbTween, float durationInSeconds); + void UpdateSDKTransform(ref SDKTransform sdkTransform); + void UpdateTransform(Transform transform); } } diff --git a/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/TweenerPool.cs b/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/TweenerPool.cs index 200454d510..d0b545433e 100644 --- a/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/TweenerPool.cs +++ b/Explorer/Assets/DCL/SDKComponents/Tween/Components/CustomTweener/TweenerPool.cs @@ -18,7 +18,7 @@ public TweenerPool() scaleTweenersPool = new ObjectPool(() => new ScaleTweener()); } - public ICustomTweener GetTweener(PBTween pbTween, SDKTransform sdkTransform, float durationInSeconds) + public ICustomTweener GetTweener(PBTween pbTween, float durationInSeconds) { ICustomTweener tweener = null; switch (pbTween.ModeCase) @@ -34,7 +34,7 @@ public ICustomTweener GetTweener(PBTween pbTween, SDKTransform sdkTransform, flo break; } - tweener!.Initialize(pbTween, sdkTransform, durationInSeconds); + tweener!.Initialize(pbTween, durationInSeconds); return tweener; } diff --git a/Explorer/Assets/DCL/SDKComponents/Tween/Systems/TweenSDKComponentHelper.cs b/Explorer/Assets/DCL/SDKComponents/Tween/Systems/TweenSDKComponentHelper.cs index 9f583b337f..3eada7fc46 100644 --- a/Explorer/Assets/DCL/SDKComponents/Tween/Systems/TweenSDKComponentHelper.cs +++ b/Explorer/Assets/DCL/SDKComponents/Tween/Systems/TweenSDKComponentHelper.cs @@ -3,6 +3,7 @@ using CrdtEcsBridge.ECSToCRDTWriter; using DCL.ECSComponents; using DCL.SDKComponents.Tween.Components; +using ECS.Unity.Transforms.Components; using UnityEngine; namespace DCL.SDKComponents.Tween.Helpers @@ -15,19 +16,30 @@ public static void WriteTweenStateInCRDT(IECSToCRDTWriter ecsToCrdtWriter, CRDTE static (component, tweenStateStatus) => component.State = tweenStateStatus, sdkEntity, tweenStateStatus); } - public static void WriteTweenResult(ref SDKTransform sdkTransform, (ICustomTweener, CRDTEntity) tweenResult) + public static void UpdateTweenResult(ref SDKTransform sdkTransform, ref TransformComponent transformComponent, ICustomTweener tweener, bool shouldUpdateTransform) { - sdkTransform.IsDirty = true; - sdkTransform.ParentId = tweenResult.Item2; - tweenResult.Item1.SetResult(ref sdkTransform); + tweener.UpdateSDKTransform(ref sdkTransform); + + //we only set the SDK transform to dirty here if we didn't already update the transform, but if the sdkTransform was already dirty, + //we dont change it, as it might have pending updates to be done from the scene side. + if (shouldUpdateTransform) + { + tweener.UpdateTransform(transformComponent.Transform); + transformComponent.UpdateCache(); + } else + sdkTransform.IsDirty = true; + } - public static void WriteTweenResultInCRDT(IECSToCRDTWriter ecsToCrdtWriter, CRDTEntity sdkEntity, (ICustomTweener, CRDTEntity) result) + public static void WriteSDKTransformUpdateInCRDT(SDKTransform sdkTransform, IECSToCRDTWriter ecsToCrdtWriter, CRDTEntity sdkEntity) { - ecsToCrdtWriter.PutMessage( - static (component, result) => WriteTweenResult(ref component, result), - sdkEntity, result); + ecsToCrdtWriter.PutMessage((component , transform) => + { + component.Position.Value = transform.Position.Value; + component.ParentId = transform.ParentId; + component.Rotation.Value = transform.Rotation.Value; + component.Scale = transform.Scale; + }, sdkEntity, sdkTransform); } - } } diff --git a/Explorer/Assets/DCL/SDKComponents/Tween/Systems/TweenUpdaterSystem.cs b/Explorer/Assets/DCL/SDKComponents/Tween/Systems/TweenUpdaterSystem.cs index 760d4da703..8fa1473bc4 100644 --- a/Explorer/Assets/DCL/SDKComponents/Tween/Systems/TweenUpdaterSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/Tween/Systems/TweenUpdaterSystem.cs @@ -16,7 +16,9 @@ using CrdtEcsBridge.Components.Transform; using CrdtEcsBridge.UpdateGate; using ECS.Groups; +using ECS.Prioritization.Components; using ECS.Unity.Transforms.Systems; +using SceneRunner.Scene; using UnityEngine; using static DCL.ECSComponents.EasingFunction; using static DG.Tweening.Ease; @@ -26,6 +28,7 @@ namespace DCL.SDKComponents.Tween.Systems [UpdateInGroup(typeof(SyncedSimulationSystemGroup))] [UpdateBefore(typeof(UpdateTransformSystem))] [UpdateAfter(typeof(TweenLoaderSystem))] + [UpdateAfter(typeof(InstantiateTransformSystem))] [LogCategory(ReportCategory.TWEEN)] public partial class TweenUpdaterSystem : BaseUnityLoopSystem, IFinalizeWorldSystem { @@ -67,16 +70,17 @@ public partial class TweenUpdaterSystem : BaseUnityLoopSystem, IFinalizeWorldSys }; private readonly TweenerPool tweenerPool; private readonly ISystemsUpdateGate systemsPriorityComponentsGate; - private readonly IECSToCRDTWriter ecsToCRDTWriter; + private readonly ISceneStateProvider sceneStateProvider; private bool openSDKTransformPriorityGate; - public TweenUpdaterSystem(World world, IECSToCRDTWriter ecsToCRDTWriter, TweenerPool tweenerPool, ISystemsUpdateGate systemsPriorityComponentsGate) : base(world) + public TweenUpdaterSystem(World world, IECSToCRDTWriter ecsToCRDTWriter, TweenerPool tweenerPool, ISystemsUpdateGate systemsPriorityComponentsGate, ISceneStateProvider sceneStateProvider) : base(world) { this.tweenerPool = tweenerPool; this.systemsPriorityComponentsGate = systemsPriorityComponentsGate; this.ecsToCRDTWriter = ecsToCRDTWriter; + this.sceneStateProvider = sceneStateProvider; } protected override void Update(float t) @@ -131,20 +135,20 @@ private void UpdatePBTween(ref PBTween pbTween, ref SDKTweenComponent tweenCompo } [Query] - private void UpdateTweenSequence(ref SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform, in PBTween pbTween, CRDTEntity sdkEntity) + private void UpdateTweenSequence(ref SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform, in PBTween pbTween, CRDTEntity sdkEntity, TransformComponent transformComponent) { if (sdkTweenComponent.IsDirty) - SetupTween(ref sdkTweenComponent, ref sdkTransform, in pbTween, sdkEntity); + SetupTween(ref sdkTweenComponent, ref sdkTransform, in pbTween, sdkEntity, transformComponent); else - UpdateTweenState(ref sdkTweenComponent, ref sdkTransform, sdkEntity); + UpdateTweenState(ref sdkTweenComponent, ref sdkTransform, sdkEntity, transformComponent); } - private void SetupTween(ref SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform, in PBTween pbTween, CRDTEntity sdkEntity) + private void SetupTween(ref SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform, in PBTween pbTween, CRDTEntity sdkEntity, TransformComponent transformComponent) { bool isPlaying = !pbTween.HasPlaying || pbTween.Playing; float durationInSeconds = pbTween.Duration / MILLISECONDS_CONVERSION_INT; - SetupTweener(ref sdkTweenComponent, ref sdkTransform, in pbTween, sdkEntity, durationInSeconds, isPlaying); + SetupTweener(ref sdkTweenComponent, ref sdkTransform, ref transformComponent, in pbTween, sdkEntity, durationInSeconds, isPlaying, sceneStateProvider.IsCurrent); if (isPlaying) { @@ -157,52 +161,55 @@ private void SetupTween(ref SDKTweenComponent sdkTweenComponent, ref SDKTransfor sdkTweenComponent.TweenStateStatus = TweenStateStatus.TsPaused; } - UpdateTweenStateAndPosition(sdkEntity, sdkTweenComponent, ref sdkTransform); + UpdateTweenStateAndPosition(sdkEntity, sdkTweenComponent, ref sdkTransform, transformComponent, sceneStateProvider.IsCurrent); sdkTweenComponent.IsDirty = false; } - private void UpdateTweenState(ref SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform, CRDTEntity sdkEntity) + private void UpdateTweenState(ref SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform, CRDTEntity sdkEntity, TransformComponent transformComponent) { TweenStateStatus newState = GetCurrentTweenState(sdkTweenComponent); if (newState != sdkTweenComponent.TweenStateStatus) { sdkTweenComponent.TweenStateStatus = newState; - UpdateTweenStateAndPosition(sdkEntity, sdkTweenComponent, ref sdkTransform); + UpdateTweenStateAndPosition(sdkEntity, sdkTweenComponent, ref sdkTransform, transformComponent, sceneStateProvider.IsCurrent); + } + else if (newState == TweenStateStatus.TsActive) + { + UpdateTweenPosition(sdkEntity, sdkTweenComponent, ref sdkTransform, transformComponent, sceneStateProvider.IsCurrent); } - else if (newState == TweenStateStatus.TsActive) { UpdateTweenPosition(sdkEntity, sdkTweenComponent, ref sdkTransform); } } - private void UpdateTweenStateAndPosition(CRDTEntity sdkEntity, SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform) + private void UpdateTweenStateAndPosition(CRDTEntity sdkEntity, SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform, TransformComponent transformComponent, bool isInCurrentScene) { - UpdateTweenPosition(sdkEntity, sdkTweenComponent, ref sdkTransform); + UpdateTweenPosition(sdkEntity, sdkTweenComponent, ref sdkTransform, transformComponent, isInCurrentScene); TweenSDKComponentHelper.WriteTweenStateInCRDT(ecsToCRDTWriter, sdkEntity, sdkTweenComponent.TweenStateStatus); } - private void UpdateTweenPosition(CRDTEntity sdkEntity, SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform) + private void UpdateTweenPosition(CRDTEntity sdkEntity, SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform, TransformComponent transformComponent, bool isInCurrentScene) { openSDKTransformPriorityGate = true; - TweenSDKComponentHelper.WriteTweenResult(ref sdkTransform, (sdkTweenComponent.CustomTweener, sdkTransform.ParentId)); - TweenSDKComponentHelper.WriteTweenResultInCRDT(ecsToCRDTWriter, sdkEntity, (sdkTweenComponent.CustomTweener, sdkTransform.ParentId)); + TweenSDKComponentHelper.UpdateTweenResult(ref sdkTransform, ref transformComponent, sdkTweenComponent.CustomTweener, isInCurrentScene); + TweenSDKComponentHelper.WriteSDKTransformUpdateInCRDT(sdkTransform, ecsToCRDTWriter, sdkEntity); } - private void SetupTweener(ref SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform, in PBTween tweenModel, CRDTEntity entity, - float durationInSeconds, bool isPlaying) + private void SetupTweener(ref SDKTweenComponent sdkTweenComponent, ref SDKTransform sdkTransform, ref TransformComponent transformComponent, in PBTween tweenModel, CRDTEntity entity, + float durationInSeconds, bool isPlaying, bool isInCurrentScene) { //NOTE: Left this per legacy reasons, Im not sure if this can happen in new renderer // There may be a tween running for the entity transform, e.g: during preview mode hot-reload. if (sdkTweenComponent.IsActive()) { sdkTweenComponent.Rewind(); - TweenSDKComponentHelper.WriteTweenResult(ref sdkTransform, (sdkTweenComponent.CustomTweener, sdkTransform.ParentId)); - TweenSDKComponentHelper.WriteTweenResultInCRDT(ecsToCRDTWriter, entity, (sdkTweenComponent.CustomTweener, sdkTransform.ParentId)); + TweenSDKComponentHelper.UpdateTweenResult(ref sdkTransform, ref transformComponent, sdkTweenComponent.CustomTweener, isInCurrentScene); + TweenSDKComponentHelper.WriteSDKTransformUpdateInCRDT(sdkTransform, ecsToCRDTWriter, entity); } ReturnTweenToPool(ref sdkTweenComponent); Ease ease = EASING_FUNCTIONS_MAP.GetValueOrDefault(tweenModel.EasingFunction, Linear); - sdkTweenComponent.CustomTweener = tweenerPool.GetTweener(tweenModel, sdkTransform, durationInSeconds); + sdkTweenComponent.CustomTweener = tweenerPool.GetTweener(tweenModel, durationInSeconds); sdkTweenComponent.CustomTweener.DoTween(ease, tweenModel.CurrentTime * durationInSeconds, isPlaying); } diff --git a/Explorer/Assets/DCL/SDKComponents/Tween/Tests/TweenUpdaterSystemShould.cs b/Explorer/Assets/DCL/SDKComponents/Tween/Tests/TweenUpdaterSystemShould.cs index 6b855adc7c..433749e05a 100644 --- a/Explorer/Assets/DCL/SDKComponents/Tween/Tests/TweenUpdaterSystemShould.cs +++ b/Explorer/Assets/DCL/SDKComponents/Tween/Tests/TweenUpdaterSystemShould.cs @@ -9,6 +9,7 @@ using NUnit.Framework; using Arch.Core; using Decentraland.Common; +using SceneRunner.Scene; using Entity = Arch.Core.Entity; namespace DCL.SDKComponents.Tween.Tests @@ -29,7 +30,7 @@ public class TweenUpdaterSystemShould : UnitySystemTestBase public void SetUp() { tweneerPool = new TweenerPool(); - system = new TweenUpdaterSystem(world, Substitute.For(), tweneerPool, null); + system = new TweenUpdaterSystem(world, Substitute.For(), tweneerPool, null, Substitute.For()); var crdtEntity = new CRDTEntity(1); var startVector = new Vector3() { X = 0, Y = 0, Z = 0}; From 93a0df38effe6fca66555da233abd536d69e44a0 Mon Sep 17 00:00:00 2001 From: Fran Colarich <56565104+fcolarich@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:39:50 +0100 Subject: [PATCH 10/24] Added logic to hide UI (#2601) --- .../DCL/PluginSystem/World/SceneUIPlugin.cs | 19 +++++++++++++++++-- .../Assets/Scripts/Global/StaticContainer.cs | 6 +++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Explorer/Assets/DCL/PluginSystem/World/SceneUIPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/SceneUIPlugin.cs index 61772f3a57..dff3eda865 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/SceneUIPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/SceneUIPlugin.cs @@ -16,12 +16,14 @@ using DCL.SDKComponents.SceneUI.Systems.UIText; using DCL.SDKComponents.SceneUI.Systems.UITransform; using DCL.SDKComponents.SceneUI.Utils; +using DCL.Utilities; using ECS.ComponentsPooling.Systems; using ECS.LifeCycle; using System; using System.Collections.Generic; using System.Threading; using UnityEngine; +using UnityEngine.InputSystem; using UnityEngine.UIElements; namespace DCL.PluginSystem.World @@ -36,8 +38,9 @@ public class SceneUIPlugin : IDCLWorldPlugin private readonly MemoryBudget memoryBudgetProvider; private readonly IComponentPool transformsPool; private readonly IInputBlock inputBlock; + public readonly ObjectProxy inputProxy; - public SceneUIPlugin(ECSWorldSingletonSharedDependencies singletonSharedDependencies, IAssetsProvisioner assetsProvisioner, IInputBlock inputBlock) + public SceneUIPlugin(ECSWorldSingletonSharedDependencies singletonSharedDependencies, IAssetsProvisioner assetsProvisioner, IInputBlock inputBlock, ObjectProxy inputProxy) { this.assetsProvisioner = assetsProvisioner; this.inputBlock = inputBlock; @@ -50,6 +53,7 @@ public SceneUIPlugin(ECSWorldSingletonSharedDependencies singletonSharedDependen frameTimeBudgetProvider = singletonSharedDependencies.FrameTimeBudget; memoryBudgetProvider = singletonSharedDependencies.MemoryBudget; + this.inputProxy = inputProxy; } public async UniTask InitializeAsync(Settings settings, CancellationToken ct) @@ -60,6 +64,8 @@ public async UniTask InitializeAsync(Settings settings, CancellationToken ct) canvas.rootVisualElement.styleSheets.Add(scenesUIStyleSheet); canvas.rootVisualElement.AddToClassList("sceneUIMainCanvas"); canvas.rootVisualElement.pickingMode = PickingMode.Ignore; + + if (inputProxy.Configured) {inputProxy.Object.Shortcuts.ShowHideUI.performed += ChangeUIShowState; } } public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in ECSWorldInstanceSharedDependencies sharedDependencies, in PersistentEntities persistentEntities, List finalizeWorldSystems, List sceneIsCurrentListeners) @@ -89,7 +95,16 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder builder, finalizeWorldSystems.Add(ReleasePoolableComponentSystem.InjectToWorld(ref builder, componentPoolsRegistry)); } - public void Dispose() { } + private void ChangeUIShowState(InputAction.CallbackContext callbackContext) + { + if (canvas != null) + canvas.rootVisualElement.parent.style.display = canvas.rootVisualElement.parent.style.display.value == DisplayStyle.Flex ? DisplayStyle.None : DisplayStyle.Flex; + } + + public void Dispose() + { + if (inputProxy.Configured) {inputProxy.Object.Shortcuts.ShowHideUI.performed -= ChangeUIShowState; } + } [Serializable] public class Settings : IDCLPluginSettings diff --git a/Explorer/Assets/Scripts/Global/StaticContainer.cs b/Explorer/Assets/Scripts/Global/StaticContainer.cs index 67b70d645e..899c750380 100644 --- a/Explorer/Assets/Scripts/Global/StaticContainer.cs +++ b/Explorer/Assets/Scripts/Global/StaticContainer.cs @@ -202,7 +202,7 @@ await UniTask.WhenAll( diagnosticsContainer.Sentry!.AddCurrentSceneToScope(scope, container.ScenesCache.CurrentScene.Info); }); - container.LoadingStatus = enableAnalytics ? + container.LoadingStatus = enableAnalytics ? new LoadingStatusAnalyticsDecorator(new LoadingStatus(), analyticsController) : new LoadingStatus(); container.ECSWorldPlugins = new IDCLWorldPlugin[] @@ -219,10 +219,10 @@ await UniTask.WhenAll( new PrimitivesRenderingPlugin(sharedDependencies), new VisibilityPlugin(), new AudioSourcesPlugin(sharedDependencies, container.WebRequestsContainer.WebRequestController, container.CacheCleaner, container.assetsProvisioner), - assetBundlePlugin, + assetBundlePlugin, new GltfContainerPlugin(sharedDependencies, container.CacheCleaner, container.SceneReadinessReportQueue, container.SingletonSharedDependencies.SceneAssetLock, componentsContainer.ComponentPoolsRegistry, localSceneDevelopment, useRemoteAssetBundles, container.LoadingStatus), new InteractionPlugin(sharedDependencies, profilingProvider, exposedGlobalDataContainer.GlobalInputEvents, componentsContainer.ComponentPoolsRegistry, container.assetsProvisioner), - new SceneUIPlugin(sharedDependencies, container.assetsProvisioner, container.InputBlock), + new SceneUIPlugin(sharedDependencies, container.assetsProvisioner, container.InputBlock, container.InputProxy), container.CharacterContainer.CreateWorldPlugin(componentsContainer.ComponentPoolsRegistry), new AnimatorPlugin(), new TweenPlugin(), From a003d59463044cda55c2097e538877a5033aa20b Mon Sep 17 00:00:00 2001 From: Pravus Date: Tue, 29 Oct 2024 22:16:09 +0100 Subject: [PATCH 11/24] chore: scene debug console app param + improve scene console toggling key binding (#2497) --- .../DCL/Input/UnityInputSystem/DCLInput.cs | 82 +++++++++++++++++++ .../UnityInputSystem/DCLInput.inputactions | 62 ++++++++++++++ .../Diagnostics/DiagnosticsContainer.cs | 14 ++-- .../LocalSceneDevelopmentReportHandler.cs | 35 -------- .../SceneDebugConsoleReportHandler.cs | 35 ++++++++ ...=> SceneDebugConsoleReportHandler.cs.meta} | 0 ...rminal.prefab => SceneDebugConsole.prefab} | 23 +++--- ...fab.meta => SceneDebugConsole.prefab.meta} | 0 ...rminal.asmdef => SceneDebugConsole.asmdef} | 6 +- ...def.meta => SceneDebugConsole.asmdef.meta} | 0 ...lSceneTerminal.cs => SceneDebugConsole.cs} | 36 ++++---- ...inal.cs.meta => SceneDebugConsole.cs.meta} | 0 .../Global/Dynamic/BootstrapContainer.cs | 5 +- 13 files changed, 226 insertions(+), 72 deletions(-) delete mode 100644 Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/LocalSceneDevelopmentReportHandler.cs create mode 100644 Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/SceneDebugConsoleReportHandler.cs rename Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/{LocalSceneDevelopmentReportHandler.cs.meta => SceneDebugConsoleReportHandler.cs.meta} (100%) rename Explorer/Assets/Plugins/CommandTerminal/Resources/{LocalSceneTerminal.prefab => SceneDebugConsole.prefab} (74%) rename Explorer/Assets/Plugins/CommandTerminal/Resources/{LocalSceneTerminal.prefab.meta => SceneDebugConsole.prefab.meta} (100%) rename Explorer/Assets/Plugins/CommandTerminal/{LocalSceneTerminal.asmdef => SceneDebugConsole.asmdef} (73%) rename Explorer/Assets/Plugins/CommandTerminal/{LocalSceneTerminal.asmdef.meta => SceneDebugConsole.asmdef.meta} (100%) rename Explorer/Assets/Plugins/CommandTerminal/{LocalSceneTerminal.cs => SceneDebugConsole.cs} (86%) rename Explorer/Assets/Plugins/CommandTerminal/{LocalSceneTerminal.cs.meta => SceneDebugConsole.cs.meta} (100%) diff --git a/Explorer/Assets/DCL/Input/UnityInputSystem/DCLInput.cs b/Explorer/Assets/DCL/Input/UnityInputSystem/DCLInput.cs index d77c055d27..1017d04130 100644 --- a/Explorer/Assets/DCL/Input/UnityInputSystem/DCLInput.cs +++ b/Explorer/Assets/DCL/Input/UnityInputSystem/DCLInput.cs @@ -2093,6 +2093,24 @@ public @DCLInput() ""processors"": """", ""interactions"": """", ""initialStateCheck"": false + }, + { + ""name"": ""ToggleSceneDebugConsole"", + ""type"": ""Button"", + ""id"": ""8a10f0d2-822d-4ec6-be75-9be85ad4fbc6"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + }, + { + ""name"": ""ToggleSceneDebugConsoleLarger"", + ""type"": ""Button"", + ""id"": ""65d092fb-6cb5-423f-8b70-93f843b54813"", + ""expectedControlType"": ""Button"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false } ], ""bindings"": [ @@ -2194,6 +2212,50 @@ public @DCLInput() ""action"": ""ToggleNametags"", ""isComposite"": false, ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""5f780ed0-edb4-436b-af9f-1215c2382586"", + ""path"": ""/backquote"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""ToggleSceneDebugConsole"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": ""SHIFT+`"", + ""id"": ""f2a9130b-c569-4b29-b34d-033430240dce"", + ""path"": ""OneModifier"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""ToggleSceneDebugConsoleLarger"", + ""isComposite"": true, + ""isPartOfComposite"": false + }, + { + ""name"": ""modifier"", + ""id"": ""70efa665-f110-4699-970a-70813d9831ba"", + ""path"": ""/leftShift"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""ToggleSceneDebugConsoleLarger"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""binding"", + ""id"": ""3cccce46-fdd9-4912-b9bf-80a37b3523d2"", + ""path"": ""/backquote"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""ToggleSceneDebugConsoleLarger"", + ""isComposite"": false, + ""isPartOfComposite"": true } ] }, @@ -2947,6 +3009,8 @@ public @DCLInput() m_Shortcuts_ToggleAvatarBubbles = m_Shortcuts.FindAction("ToggleAvatarBubbles", throwIfNotFound: true); m_Shortcuts_ShowHideUI = m_Shortcuts.FindAction("ShowHideUI", throwIfNotFound: true); m_Shortcuts_ToggleNametags = m_Shortcuts.FindAction("ToggleNametags", throwIfNotFound: true); + m_Shortcuts_ToggleSceneDebugConsole = m_Shortcuts.FindAction("ToggleSceneDebugConsole", throwIfNotFound: true); + m_Shortcuts_ToggleSceneDebugConsoleLarger = m_Shortcuts.FindAction("ToggleSceneDebugConsoleLarger", throwIfNotFound: true); // Emotes m_Emotes = asset.FindActionMap("Emotes", throwIfNotFound: true); m_Emotes_Slot1 = m_Emotes.FindAction("Slot 1", throwIfNotFound: true); @@ -3563,6 +3627,8 @@ public void SetCallbacks(IUIActions instance) private readonly InputAction m_Shortcuts_ToggleAvatarBubbles; private readonly InputAction m_Shortcuts_ShowHideUI; private readonly InputAction m_Shortcuts_ToggleNametags; + private readonly InputAction m_Shortcuts_ToggleSceneDebugConsole; + private readonly InputAction m_Shortcuts_ToggleSceneDebugConsoleLarger; public struct ShortcutsActions { private @DCLInput m_Wrapper; @@ -3576,6 +3642,8 @@ public struct ShortcutsActions public InputAction @ToggleAvatarBubbles => m_Wrapper.m_Shortcuts_ToggleAvatarBubbles; public InputAction @ShowHideUI => m_Wrapper.m_Shortcuts_ShowHideUI; public InputAction @ToggleNametags => m_Wrapper.m_Shortcuts_ToggleNametags; + public InputAction @ToggleSceneDebugConsole => m_Wrapper.m_Shortcuts_ToggleSceneDebugConsole; + public InputAction @ToggleSceneDebugConsoleLarger => m_Wrapper.m_Shortcuts_ToggleSceneDebugConsoleLarger; public InputActionMap Get() { return m_Wrapper.m_Shortcuts; } public void Enable() { Get().Enable(); } public void Disable() { Get().Disable(); } @@ -3612,6 +3680,12 @@ public void AddCallbacks(IShortcutsActions instance) @ToggleNametags.started += instance.OnToggleNametags; @ToggleNametags.performed += instance.OnToggleNametags; @ToggleNametags.canceled += instance.OnToggleNametags; + @ToggleSceneDebugConsole.started += instance.OnToggleSceneDebugConsole; + @ToggleSceneDebugConsole.performed += instance.OnToggleSceneDebugConsole; + @ToggleSceneDebugConsole.canceled += instance.OnToggleSceneDebugConsole; + @ToggleSceneDebugConsoleLarger.started += instance.OnToggleSceneDebugConsoleLarger; + @ToggleSceneDebugConsoleLarger.performed += instance.OnToggleSceneDebugConsoleLarger; + @ToggleSceneDebugConsoleLarger.canceled += instance.OnToggleSceneDebugConsoleLarger; } private void UnregisterCallbacks(IShortcutsActions instance) @@ -3643,6 +3717,12 @@ private void UnregisterCallbacks(IShortcutsActions instance) @ToggleNametags.started -= instance.OnToggleNametags; @ToggleNametags.performed -= instance.OnToggleNametags; @ToggleNametags.canceled -= instance.OnToggleNametags; + @ToggleSceneDebugConsole.started -= instance.OnToggleSceneDebugConsole; + @ToggleSceneDebugConsole.performed -= instance.OnToggleSceneDebugConsole; + @ToggleSceneDebugConsole.canceled -= instance.OnToggleSceneDebugConsole; + @ToggleSceneDebugConsoleLarger.started -= instance.OnToggleSceneDebugConsoleLarger; + @ToggleSceneDebugConsoleLarger.performed -= instance.OnToggleSceneDebugConsoleLarger; + @ToggleSceneDebugConsoleLarger.canceled -= instance.OnToggleSceneDebugConsoleLarger; } public void RemoveCallbacks(IShortcutsActions instance) @@ -3990,6 +4070,8 @@ public interface IShortcutsActions void OnToggleAvatarBubbles(InputAction.CallbackContext context); void OnShowHideUI(InputAction.CallbackContext context); void OnToggleNametags(InputAction.CallbackContext context); + void OnToggleSceneDebugConsole(InputAction.CallbackContext context); + void OnToggleSceneDebugConsoleLarger(InputAction.CallbackContext context); } public interface IEmotesActions { diff --git a/Explorer/Assets/DCL/Input/UnityInputSystem/DCLInput.inputactions b/Explorer/Assets/DCL/Input/UnityInputSystem/DCLInput.inputactions index efe537511f..2b7f85549d 100644 --- a/Explorer/Assets/DCL/Input/UnityInputSystem/DCLInput.inputactions +++ b/Explorer/Assets/DCL/Input/UnityInputSystem/DCLInput.inputactions @@ -2071,6 +2071,24 @@ "processors": "", "interactions": "", "initialStateCheck": false + }, + { + "name": "ToggleSceneDebugConsole", + "type": "Button", + "id": "8a10f0d2-822d-4ec6-be75-9be85ad4fbc6", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "ToggleSceneDebugConsoleLarger", + "type": "Button", + "id": "65d092fb-6cb5-423f-8b70-93f843b54813", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -2172,6 +2190,50 @@ "action": "ToggleNametags", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "5f780ed0-edb4-436b-af9f-1215c2382586", + "path": "/backquote", + "interactions": "", + "processors": "", + "groups": "", + "action": "ToggleSceneDebugConsole", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "SHIFT+`", + "id": "f2a9130b-c569-4b29-b34d-033430240dce", + "path": "OneModifier", + "interactions": "", + "processors": "", + "groups": "", + "action": "ToggleSceneDebugConsoleLarger", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "modifier", + "id": "70efa665-f110-4699-970a-70813d9831ba", + "path": "/leftShift", + "interactions": "", + "processors": "", + "groups": "", + "action": "ToggleSceneDebugConsoleLarger", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "binding", + "id": "3cccce46-fdd9-4912-b9bf-80a37b3523d2", + "path": "/backquote", + "interactions": "", + "processors": "", + "groups": "", + "action": "ToggleSceneDebugConsoleLarger", + "isComposite": false, + "isPartOfComposite": true } ] }, diff --git a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/DiagnosticsContainer.cs b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/DiagnosticsContainer.cs index 4c2542059a..b98d665f7f 100644 --- a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/DiagnosticsContainer.cs +++ b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/DiagnosticsContainer.cs @@ -28,11 +28,11 @@ public void AddSentryScopeConfigurator(SentryReportHandler.ConfigureScope config Sentry?.AddScopeConfigurator(configureScope); } - public static DiagnosticsContainer Create(IReportsHandlingSettings settings, bool enableLocalSceneReporting = false, params (ReportHandler, IReportHandler)[] additionalHandlers) + public static DiagnosticsContainer Create(IReportsHandlingSettings settings, bool enableSceneDebugConsole = false, params (ReportHandler, IReportHandler)[] additionalHandlers) { settings.NotifyErrorDebugLogDisabled(); - int handlersCount = DEFAULT_REPORT_HANDLERS_COUNT + additionalHandlers.Length + (enableLocalSceneReporting ? 1 : 0); + int handlersCount = DEFAULT_REPORT_HANDLERS_COUNT + additionalHandlers.Length + (enableSceneDebugConsole ? 1 : 0); List<(ReportHandler, IReportHandler)> handlers = new List<(ReportHandler, IReportHandler)>(handlersCount); handlers.AddRange(additionalHandlers); @@ -44,8 +44,8 @@ public static DiagnosticsContainer Create(IReportsHandlingSettings settings, boo if (settings.IsEnabled(ReportHandler.Sentry)) handlers.Add((ReportHandler.Sentry, sentryReportHandler = new SentryReportHandler(settings.GetMatrix(ReportHandler.Sentry), settings.DebounceEnabled))); - if (enableLocalSceneReporting) - AddLocalSceneReportingHandler(handlers); + if (enableSceneDebugConsole) + AddSceneDebugConsoleReportHandler(handlers); var logger = new ReportHubLogger(handlers); @@ -55,12 +55,12 @@ public static DiagnosticsContainer Create(IReportsHandlingSettings settings, boo Debug.unityLogger.logHandler = logger; // Enable Hub static accessors - ReportHub.Initialize(logger, enableLocalSceneReporting); + ReportHub.Initialize(logger, enableSceneDebugConsole); return new DiagnosticsContainer { ReportHubLogger = logger, defaultLogHandler = defaultLogHandler, Sentry = sentryReportHandler }; } - private static void AddLocalSceneReportingHandler(List<(ReportHandler, IReportHandler)> handlers) + private static void AddSceneDebugConsoleReportHandler(List<(ReportHandler, IReportHandler)> handlers) { var jsOnlyMatrix = new CategorySeverityMatrix(); var entries = new List(); @@ -68,7 +68,7 @@ private static void AddLocalSceneReportingHandler(List<(ReportHandler, IReportHa entries.Add(new CategorySeverityMatrix.Entry() { Category = ReportCategory.JAVASCRIPT, Severity = LogType.Exception }); entries.Add(new CategorySeverityMatrix.Entry() { Category = ReportCategory.JAVASCRIPT, Severity = LogType.Log }); jsOnlyMatrix.entries = entries; - handlers.Add((ReportHandler.DebugLog, new LocalSceneDevelopmentReportHandler(jsOnlyMatrix, false))); + handlers.Add((ReportHandler.DebugLog, new SceneDebugConsoleReportHandler(jsOnlyMatrix, false))); } } } diff --git a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/LocalSceneDevelopmentReportHandler.cs b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/LocalSceneDevelopmentReportHandler.cs deleted file mode 100644 index dfe2f0cb7f..0000000000 --- a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/LocalSceneDevelopmentReportHandler.cs +++ /dev/null @@ -1,35 +0,0 @@ -using CommandTerminal; -using System; -using UnityEngine; -using Object = UnityEngine.Object; - -namespace DCL.Diagnostics -{ - public class LocalSceneDevelopmentReportHandler : ReportHandlerBase - { - private readonly LocalSceneTerminal localSceneTerminal; - - public LocalSceneDevelopmentReportHandler(ICategorySeverityMatrix matrix, bool debounceEnabled) : base(matrix, debounceEnabled) - { - localSceneTerminal = GameObject.Instantiate(Resources.Load("LocalSceneTerminal")).GetComponent(); - } - - internal override void LogInternal(LogType logType, ReportData reportData, Object context, object message) - { - localSceneTerminal.Log(message.ToString()); - } - - internal override void LogFormatInternal(LogType logType, ReportData category, Object context, object message, params object[] args) - { } - - internal override void LogExceptionInternal(T ecsSystemException) - { - localSceneTerminal.Log(ecsSystemException.Message, ecsSystemException.StackTrace, LogType.Exception); - } - - internal override void LogExceptionInternal(Exception exception, ReportData reportData, Object context) - { - localSceneTerminal.Log(exception.Message, exception.StackTrace, LogType.Exception); - } - } -} diff --git a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/SceneDebugConsoleReportHandler.cs b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/SceneDebugConsoleReportHandler.cs new file mode 100644 index 0000000000..f61228f946 --- /dev/null +++ b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/SceneDebugConsoleReportHandler.cs @@ -0,0 +1,35 @@ +using CommandTerminal; +using System; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace DCL.Diagnostics +{ + public class SceneDebugConsoleReportHandler : ReportHandlerBase + { + private readonly SceneDebugConsole sceneDebugConsole; + + public SceneDebugConsoleReportHandler(ICategorySeverityMatrix matrix, bool debounceEnabled) : base(matrix, debounceEnabled) + { + sceneDebugConsole = GameObject.Instantiate(Resources.Load("SceneDebugConsole")).GetComponent(); + } + + internal override void LogInternal(LogType logType, ReportData reportData, Object context, object message) + { + sceneDebugConsole.Log(message.ToString()); + } + + internal override void LogFormatInternal(LogType logType, ReportData category, Object context, object message, params object[] args) + { } + + internal override void LogExceptionInternal(T ecsSystemException) + { + sceneDebugConsole.Log(ecsSystemException.Message, ecsSystemException.StackTrace, LogType.Exception); + } + + internal override void LogExceptionInternal(Exception exception, ReportData reportData, Object context) + { + sceneDebugConsole.Log(exception.Message, exception.StackTrace, LogType.Exception); + } + } +} diff --git a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/LocalSceneDevelopmentReportHandler.cs.meta b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/SceneDebugConsoleReportHandler.cs.meta similarity index 100% rename from Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/LocalSceneDevelopmentReportHandler.cs.meta rename to Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/Handlers/SceneDebugConsoleReportHandler.cs.meta diff --git a/Explorer/Assets/Plugins/CommandTerminal/Resources/LocalSceneTerminal.prefab b/Explorer/Assets/Plugins/CommandTerminal/Resources/SceneDebugConsole.prefab similarity index 74% rename from Explorer/Assets/Plugins/CommandTerminal/Resources/LocalSceneTerminal.prefab rename to Explorer/Assets/Plugins/CommandTerminal/Resources/SceneDebugConsole.prefab index ce01bcaccc..f738fb7e32 100644 --- a/Explorer/Assets/Plugins/CommandTerminal/Resources/LocalSceneTerminal.prefab +++ b/Explorer/Assets/Plugins/CommandTerminal/Resources/SceneDebugConsole.prefab @@ -11,7 +11,7 @@ GameObject: - component: {fileID: 4699631190147957370} - component: {fileID: 1558923068822012428} m_Layer: 0 - m_Name: LocalSceneTerminal + m_Name: SceneDebugConsole m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -44,13 +44,14 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ac7a2214776444260b2303810587daf3, type: 3} m_Name: m_EditorClassIdentifier: - MaxHeight: 0.7 - SmallTerminalRatio: 0.33 - ToggleSpeed: 1000 - ToggleHotkey: '`' - ToggleFullHotkey: '#`' - ConsoleFont: {fileID: 0} - BackgroundColor: {r: 0, g: 0, b: 0, a: 1} - ForegroundColor: {r: 1, g: 1, b: 1, a: 1} - WarningColor: {r: 1, g: 0.92156863, b: 0.015686275, a: 1} - ErrorColor: {r: 1, g: 0, b: 0, a: 1} + maxHeight: 0.7 + smallTerminalRatio: 0.33 + toggleSpeed: 1000 + inputActions: {fileID: -944628639613478452, guid: 6cec26357c7fb8f44b03ce452209387d, type: 3} + logsMaxAmount: 512 + fontSize: 20 + consoleFont: {fileID: 0} + backgroundColor: {r: 0, g: 0, b: 0, a: 1} + foregroundColor: {r: 1, g: 1, b: 1, a: 1} + warningColor: {r: 1, g: 0.92156863, b: 0.015686275, a: 1} + errorColor: {r: 1, g: 0, b: 0, a: 1} diff --git a/Explorer/Assets/Plugins/CommandTerminal/Resources/LocalSceneTerminal.prefab.meta b/Explorer/Assets/Plugins/CommandTerminal/Resources/SceneDebugConsole.prefab.meta similarity index 100% rename from Explorer/Assets/Plugins/CommandTerminal/Resources/LocalSceneTerminal.prefab.meta rename to Explorer/Assets/Plugins/CommandTerminal/Resources/SceneDebugConsole.prefab.meta diff --git a/Explorer/Assets/Plugins/CommandTerminal/LocalSceneTerminal.asmdef b/Explorer/Assets/Plugins/CommandTerminal/SceneDebugConsole.asmdef similarity index 73% rename from Explorer/Assets/Plugins/CommandTerminal/LocalSceneTerminal.asmdef rename to Explorer/Assets/Plugins/CommandTerminal/SceneDebugConsole.asmdef index 48880e606f..4576f779d2 100644 --- a/Explorer/Assets/Plugins/CommandTerminal/LocalSceneTerminal.asmdef +++ b/Explorer/Assets/Plugins/CommandTerminal/SceneDebugConsole.asmdef @@ -1,7 +1,9 @@ { - "name": "LocalSceneTerminal", + "name": "SceneDebugConsole", "rootNamespace": "", - "references": [], + "references": [ + "GUID:75469ad4d38634e559750d17036d5f7c" + ], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, diff --git a/Explorer/Assets/Plugins/CommandTerminal/LocalSceneTerminal.asmdef.meta b/Explorer/Assets/Plugins/CommandTerminal/SceneDebugConsole.asmdef.meta similarity index 100% rename from Explorer/Assets/Plugins/CommandTerminal/LocalSceneTerminal.asmdef.meta rename to Explorer/Assets/Plugins/CommandTerminal/SceneDebugConsole.asmdef.meta diff --git a/Explorer/Assets/Plugins/CommandTerminal/LocalSceneTerminal.cs b/Explorer/Assets/Plugins/CommandTerminal/SceneDebugConsole.cs similarity index 86% rename from Explorer/Assets/Plugins/CommandTerminal/LocalSceneTerminal.cs rename to Explorer/Assets/Plugins/CommandTerminal/SceneDebugConsole.cs index 3c7302e6ed..e20cf012d8 100644 --- a/Explorer/Assets/Plugins/CommandTerminal/LocalSceneTerminal.cs +++ b/Explorer/Assets/Plugins/CommandTerminal/SceneDebugConsole.cs @@ -1,5 +1,5 @@ using UnityEngine; -using UnityEngine.Assertions; +using UnityEngine.InputSystem; // ORIGINAL OPEN SOURCE PLUGIN SCRIPT: // https://github.com/stillwwater/command_terminal/blob/0f5918ea79014955b24c7d431625a97a1cac8797/CommandTerminal/Terminal.cs @@ -14,12 +14,10 @@ public enum TerminalState } /// - /// Dedicated toggleable console for displaying only SDK scene messages during local scene development + /// Dedicated toggleable console for displaying only JS scene messages/logs/errors /// - public class LocalSceneTerminal : MonoBehaviour + public class SceneDebugConsole : MonoBehaviour { - private const string ESCAPE_KEYBOARD_EVENT = "escape"; - [Header("Window")] [Range(0, 1)] [SerializeField] @@ -33,8 +31,9 @@ public class LocalSceneTerminal : MonoBehaviour [SerializeField] private float toggleSpeed = 1000; - [SerializeField] private string toggleHotkey = "`"; - [SerializeField] private string toggleFullHotkey = "#`"; + [SerializeField] private InputActionAsset inputActions; + private InputAction toggleInputAction; + private InputAction toggleLargeInputAction; [SerializeField] private int logsMaxAmount = 512; [Header("Theme")] @@ -60,7 +59,11 @@ public class LocalSceneTerminal : MonoBehaviour private void Start() { - Assert.AreNotEqual(toggleHotkey.ToLower(), "return", "Return is not a valid ToggleHotkey"); + var shortcutsInputActionsMap = inputActions.FindActionMap("Shortcuts"); + toggleInputAction = shortcutsInputActionsMap.FindAction("ToggleSceneDebugConsole"); + toggleInputAction.Enable(); + toggleLargeInputAction = shortcutsInputActionsMap.FindAction("ToggleSceneDebugConsoleLarger"); + toggleLargeInputAction.Enable(); SetupWindow(); SetupLabels(); @@ -71,20 +74,23 @@ private void OnEnable() consoleBuffer = new ConsoleBuffer(logsMaxAmount); } - private void OnGUI() + private void Update() { if (isClosed) { - if (Event.current.Equals(Event.KeyboardEvent(toggleHotkey))) - SetState(TerminalState.OpenSmall); - else if (Event.current.Equals(Event.KeyboardEvent(toggleFullHotkey))) + if (toggleLargeInputAction.triggered) SetState(TerminalState.OpenFull); + else if (toggleInputAction.triggered) + SetState(TerminalState.OpenSmall); } - else if (Event.current.Equals(Event.KeyboardEvent(ESCAPE_KEYBOARD_EVENT)) - || Event.current.Equals(Event.KeyboardEvent(toggleHotkey)) - || Event.current.Equals(Event.KeyboardEvent(toggleFullHotkey))) + else if (toggleInputAction.triggered || toggleLargeInputAction.triggered) + { SetState(TerminalState.Close); + } + } + private void OnGUI() + { if (isClosed) return; HandleOpenness(); diff --git a/Explorer/Assets/Plugins/CommandTerminal/LocalSceneTerminal.cs.meta b/Explorer/Assets/Plugins/CommandTerminal/SceneDebugConsole.cs.meta similarity index 100% rename from Explorer/Assets/Plugins/CommandTerminal/LocalSceneTerminal.cs.meta rename to Explorer/Assets/Plugins/CommandTerminal/SceneDebugConsole.cs.meta diff --git a/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs b/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs index 3a239967a3..ddfb366507 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs @@ -93,9 +93,10 @@ await bootstrapContainer.InitializeContainerAsync Date: Wed, 30 Oct 2024 20:35:26 +0100 Subject: [PATCH 12/24] fix: sdk video player SEEK + VS_ERROR video event (#2563) --- .../Components/MediaPlayerComponent.cs | 16 +++++--- .../MediaStream/MediaPlayerExtensions.cs | 23 +++++++++-- .../Systems/CreateMediaPlayerSystem.cs | 21 +++++++--- .../Systems/UpdateMediaPlayerSystem.cs | 22 +++++----- .../MediaStream/Systems/VideoEventsSystem.cs | 41 +++++++++++-------- .../Wrapper/MediaPlayerPluginWrapper.cs | 2 +- .../WebRequestControllerExtensions.cs | 1 + .../Assets/DCL/WebRequests/WebRequestUtils.cs | 3 +- 8 files changed, 85 insertions(+), 44 deletions(-) diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/Components/MediaPlayerComponent.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/Components/MediaPlayerComponent.cs index f88da35c14..bbba779e5a 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/Components/MediaPlayerComponent.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/Components/MediaPlayerComponent.cs @@ -1,7 +1,5 @@ using DCL.ECSComponents; -using DCL.Optimization.Pools; using RenderHeads.Media.AVProVideo; -using System; using System.Threading; using Utility; @@ -17,9 +15,10 @@ public struct MediaPlayerComponent public string URL; public bool IsFromContentServer; - public VideoState State; - public double PreviousPlayingTimeCheck; - public float LastStateChangeTime; + public VideoState State { get; private set; } + public VideoState LastPropagatedState; + public double PreviousCurrentTimeChecked; + public float LastStateChangeTime { get; private set; } public CancellationTokenSource Cts; public OpenMediaPromise OpenMediaPromise; @@ -28,6 +27,13 @@ public struct MediaPlayerComponent public float CurrentTime => (float)MediaPlayer.Control.GetCurrentTime(); public float Duration => (float)MediaPlayer.Info.GetDuration(); + public void SetState(VideoState newState) + { + if (State == newState) return; + State = newState; + LastStateChangeTime = UnityEngine.Time.realtimeSinceStartup; + } + public void Dispose() { MediaPlayer = null; diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/MediaPlayerExtensions.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/MediaPlayerExtensions.cs index e281a904e6..c85b2de153 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/MediaPlayerExtensions.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/MediaPlayerExtensions.cs @@ -1,5 +1,7 @@ +using Cysharp.Threading.Tasks; using DCL.ECSComponents; using RenderHeads.Media.AVProVideo; +using System; using UnityEngine; namespace DCL.SDKComponents.MediaStream @@ -62,12 +64,25 @@ public static MediaPlayer UpdatePlayback(this MediaPlayer mediaPlayer, bool hasP public static void SetPlaybackProperties(this MediaPlayer mediaPlayer, PBVideoPlayer sdkVideoPlayer) { if (!mediaPlayer.MediaOpened) return; + SetPlaybackPropertiesAsync(mediaPlayer.Control, sdkVideoPlayer).Forget(); + } - IMediaControl control = mediaPlayer.Control; + private static async UniTask SetPlaybackPropertiesAsync(IMediaControl control, PBVideoPlayer sdkVideoPlayer) + { + // If there are no seekable/buffered times, and we try to seek, AVPro may mistakenly play it from the start. + await UniTask.WaitUntil(() => control.GetBufferedTimes().Count > 0); - control.SetLooping(sdkVideoPlayer.HasLoop && sdkVideoPlayer.Loop); // default: false +#if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX) + // The only way found to make the video initialization consistent and reliable on MacOS even after a scene reload + await UniTask.Delay(TimeSpan.FromSeconds(1f)); +#endif + + control.SetLooping(sdkVideoPlayer is { HasLoop: true, Loop: true }); // default: false control.SetPlaybackRate(sdkVideoPlayer.HasPlaybackRate ? sdkVideoPlayer.PlaybackRate : MediaPlayerComponent.DEFAULT_PLAYBACK_RATE); - control.SeekFast(sdkVideoPlayer.HasPosition ? sdkVideoPlayer.Position : MediaPlayerComponent.DEFAULT_POSITION); + control.Seek(sdkVideoPlayer.HasPosition ? sdkVideoPlayer.Position : MediaPlayerComponent.DEFAULT_POSITION); + + if (sdkVideoPlayer is { HasPlaying: true, Playing: true }) + control.Play(); } public static void UpdatePlaybackProperties(this MediaPlayer mediaPlayer, PBVideoPlayer sdkVideoPlayer) @@ -83,7 +98,7 @@ public static void UpdatePlaybackProperties(this MediaPlayer mediaPlayer, PBVide control.SetPlaybackRate(sdkVideoPlayer.PlaybackRate); if (sdkVideoPlayer.HasPosition) - control.SeekFast(sdkVideoPlayer.Position); + control.Seek(sdkVideoPlayer.Position); } } } diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/CreateMediaPlayerSystem.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/CreateMediaPlayerSystem.cs index 3ad6784eab..a451a1ffa8 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/CreateMediaPlayerSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/CreateMediaPlayerSystem.cs @@ -24,6 +24,8 @@ namespace DCL.SDKComponents.MediaStream [ThrottlingEnabled] public partial class CreateMediaPlayerSystem : BaseUnityLoopSystem { + private static string CONTENT_SERVER_PREFIX = "/content/contents"; + private readonly ISceneStateProvider sceneStateProvider; private readonly IPerformanceBudget frameTimeBudget; private readonly IComponentPool mediaPlayerPool; @@ -76,20 +78,27 @@ private void CreateMediaPlayer(Entity entity, string url, bool hasVolume, float private MediaPlayerComponent CreateMediaPlayerComponent(Entity entity, string url, bool hasVolume, float volume) { // if it is not valid, we try get it as a scene local video - if (!url.IsValidUrl() && sceneData.TryGetMediaUrl(url, out URLAddress mediaUrl)) - url = mediaUrl; + bool isValidStreamUrl = url.IsValidUrl(); + bool isValidLocalPath = false; + + if (!isValidStreamUrl) + { + isValidLocalPath = sceneData.TryGetMediaUrl(url, out URLAddress mediaUrl); + if(isValidLocalPath) + url = mediaUrl; + } var component = new MediaPlayerComponent { MediaPlayer = mediaPlayerPool.Get(), URL = url, - IsFromContentServer = url.Contains("/content/contents"), - State = url.IsValidUrl() ? VideoState.VsNone : VideoState.VsError, - PreviousPlayingTimeCheck = -1, - LastStateChangeTime = -1, + IsFromContentServer = url.Contains(CONTENT_SERVER_PREFIX), + PreviousCurrentTimeChecked = -1, + LastPropagatedState = VideoState.VsPaused, Cts = new CancellationTokenSource(), OpenMediaPromise = new OpenMediaPromise(), }; + component.SetState(isValidStreamUrl || isValidLocalPath || string.IsNullOrEmpty(url) ? VideoState.VsNone : VideoState.VsError); #if UNITY_EDITOR component.MediaPlayer.gameObject.name = $"MediaPlayer_Entity_{entity}"; diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs index fdb3d75599..b39f161104 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/UpdateMediaPlayerSystem.cs @@ -106,7 +106,7 @@ private void UpdateVideoStream(ref MediaPlayerComponent component, PBVideoPlayer } HandleComponentChange(ref component, sdkComponent, sdkComponent.Src, sdkComponent.HasPlaying, sdkComponent.Playing, sdkComponent, static (mediaPlayer, sdk) => mediaPlayer.UpdatePlaybackProperties(sdk)); - ConsumePromise(ref component, sdkComponent.HasPlaying && sdkComponent.Playing, sdkComponent, static (mediaPlayer, sdk) => mediaPlayer.SetPlaybackProperties(sdk)); + ConsumePromise(ref component, false, sdkComponent, static (mediaPlayer, sdk) => mediaPlayer.SetPlaybackProperties(sdk)); } [Query] @@ -134,9 +134,7 @@ private void HandleComponentChange(ref MediaPlayerComponent component, IDirtyMar { if (!sdkComponent.IsDirty) return; - sceneData.TryGetMediaUrl(url, out URLAddress localMediaUrl); - - if (component.URL != url && component.URL != localMediaUrl) + if (component.URL != url && (!sceneData.TryGetMediaUrl(url, out URLAddress localMediaUrl) || component.URL != localMediaUrl)) { component.MediaPlayer.CloseCurrentStream(); @@ -175,20 +173,24 @@ private static void ConsumePromise(ref MediaPlayerComponent component, bool auto } else { - component.State = VideoState.VsError; + component.SetState(string.IsNullOrEmpty(component.URL) ? VideoState.VsNone : VideoState.VsError); component.MediaPlayer.CloseCurrentStream(); } } private void UpdateStreamUrl(ref MediaPlayerComponent component, string url) { - component.MediaPlayer.CloseCurrentStream(); - - if (!url.IsValidUrl() && sceneData.TryGetMediaUrl(url, out URLAddress mediaUrl)) - url = mediaUrl; + bool isValidStreamUrl = url.IsValidUrl(); + bool isValidLocalPath = false; + if (!isValidStreamUrl) + { + isValidLocalPath = sceneData.TryGetMediaUrl(url, out URLAddress mediaUrl); + if(isValidLocalPath) + url = mediaUrl; + } component.URL = url; - component.State = url.IsValidUrl() ? VideoState.VsNone : VideoState.VsError; + component.SetState(isValidStreamUrl || isValidLocalPath || string.IsNullOrEmpty(url) ? VideoState.VsNone : VideoState.VsError); } public override void Dispose() diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/VideoEventsSystem.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/VideoEventsSystem.cs index 7f715f77cc..b3babf0036 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/VideoEventsSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/Systems/VideoEventsSystem.cs @@ -1,13 +1,11 @@ using Arch.Core; using Arch.System; using Arch.SystemGroups; -using Arch.SystemGroups.Throttling; using CRDT; using CrdtEcsBridge.ECSToCRDTWriter; using DCL.Diagnostics; using DCL.ECSComponents; using DCL.Optimization.PerformanceBudgeting; -using DCL.Optimization.Pools; using ECS.Abstract; using ECS.Groups; using RenderHeads.Media.AVProVideo; @@ -18,21 +16,18 @@ namespace DCL.SDKComponents.MediaStream { [UpdateInGroup(typeof(SyncedPreRenderingSystemGroup))] [LogCategory(ReportCategory.MEDIA_STREAM)] - [ThrottlingEnabled] public partial class VideoEventsSystem : BaseUnityLoopSystem { private const float MAX_VIDEO_FROZEN_SECONDS_BEFORE_ERROR = 10f; private readonly IECSToCRDTWriter ecsToCRDTWriter; private readonly ISceneStateProvider sceneStateProvider; - private readonly IComponentPool componentPool; private readonly IPerformanceBudget frameTimeBudget; - private VideoEventsSystem(World world, IECSToCRDTWriter ecsToCrdtWriter, ISceneStateProvider sceneStateProvider, IComponentPool componentPool, IPerformanceBudget frameTimeBudget) : base(world) + private VideoEventsSystem(World world, IECSToCRDTWriter ecsToCrdtWriter, ISceneStateProvider sceneStateProvider, IPerformanceBudget frameTimeBudget) : base(world) { ecsToCRDTWriter = ecsToCrdtWriter; this.sceneStateProvider = sceneStateProvider; - this.componentPool = componentPool; this.frameTimeBudget = frameTimeBudget; } @@ -43,22 +38,30 @@ protected override void Update(float t) [Query] [All(typeof(PBVideoPlayer))] - private void PropagateVideoEvents(ref CRDTEntity sdkEntity, ref MediaPlayerComponent mediaPlayer) + private void PropagateVideoEvents(in CRDTEntity sdkEntity, ref MediaPlayerComponent mediaPlayer) { if (!frameTimeBudget.TrySpendBudget()) return; - VideoState newState = GetCurrentVideoState(mediaPlayer.MediaPlayer.Control, mediaPlayer.PreviousPlayingTimeCheck, mediaPlayer.LastStateChangeTime); + // The Media Player could already been flagged with errors detected on the video promise, those have to be propagated. + if (mediaPlayer.State != VideoState.VsError) + { + VideoState newState = GetCurrentVideoState(mediaPlayer); - if (mediaPlayer.State == newState) return; - mediaPlayer.LastStateChangeTime = Time.realtimeSinceStartup; - mediaPlayer.PreviousPlayingTimeCheck = mediaPlayer.MediaPlayer.Control.GetCurrentTime(); - mediaPlayer.State = newState; + if (mediaPlayer.State != newState) + { + mediaPlayer.PreviousCurrentTimeChecked = mediaPlayer.MediaPlayer.Control.GetCurrentTime(); + mediaPlayer.SetState(newState); + } + } - AppendMessage(in sdkEntity, in mediaPlayer); + PropagateStateInVideoEvent(in sdkEntity, ref mediaPlayer); } - private void AppendMessage(in CRDTEntity sdkEntity, in MediaPlayerComponent mediaPlayer) + private void PropagateStateInVideoEvent(in CRDTEntity sdkEntity, ref MediaPlayerComponent mediaPlayer) { + if (mediaPlayer.LastPropagatedState == mediaPlayer.State) return; + + mediaPlayer.LastPropagatedState = mediaPlayer.State; ecsToCRDTWriter.AppendMessage ( prepareMessage: static (pbVideoEvent, data) => @@ -74,9 +77,12 @@ private void AppendMessage(in CRDTEntity sdkEntity, in MediaPlayerComponent medi ); } - private static VideoState GetCurrentVideoState(IMediaControl mediaPlayerControl, double previousPlayingTimeCheck, float lastStateChangeTime) + private static VideoState GetCurrentVideoState(in MediaPlayerComponent mediaPlayer) { + if (string.IsNullOrEmpty(mediaPlayer.URL)) return VideoState.VsNone; + // Important: while PLAYING or PAUSED, MediaPlayerControl may also be BUFFERING and/or SEEKING. + var mediaPlayerControl = mediaPlayer.MediaPlayer.Control; if (mediaPlayerControl.IsFinished()) return VideoState.VsNone; if (mediaPlayerControl.GetLastError() != ErrorCode.None) return VideoState.VsError; @@ -87,15 +93,16 @@ private static VideoState GetCurrentVideoState(IMediaControl mediaPlayerControl, { state = VideoState.VsPlaying; - if (mediaPlayerControl.GetCurrentTime().Equals(previousPlayingTimeCheck)) // Video is frozen + if (mediaPlayerControl.GetCurrentTime().Equals(mediaPlayer.PreviousCurrentTimeChecked)) // Video is frozen { state = mediaPlayerControl.IsSeeking() ? VideoState.VsSeeking : VideoState.VsBuffering; // If the seeking/buffering never ends, update state with error so the scene can react - if ((Time.realtimeSinceStartup - lastStateChangeTime) > MAX_VIDEO_FROZEN_SECONDS_BEFORE_ERROR) + if ((Time.realtimeSinceStartup - mediaPlayer.LastStateChangeTime) > MAX_VIDEO_FROZEN_SECONDS_BEFORE_ERROR) state = VideoState.VsError; } } + return state; } } diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/Wrapper/MediaPlayerPluginWrapper.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/Wrapper/MediaPlayerPluginWrapper.cs index 373d859a19..de6159a680 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/Wrapper/MediaPlayerPluginWrapper.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/Wrapper/MediaPlayerPluginWrapper.cs @@ -73,7 +73,7 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder builder, ISceneData CreateMediaPlayerSystem.InjectToWorld(ref builder, webRequestController, sceneData, mediaPlayerPool, sceneStateProvider, frameTimeBudget); UpdateMediaPlayerSystem.InjectToWorld(ref builder, webRequestController, sceneData, sceneStateProvider, frameTimeBudget, worldVolumeMacBus); - VideoEventsSystem.InjectToWorld(ref builder, ecsToCrdtWriter, sceneStateProvider, componentPoolsRegistry.GetReferenceTypePool(), frameTimeBudget); + VideoEventsSystem.InjectToWorld(ref builder, ecsToCrdtWriter, sceneStateProvider, frameTimeBudget); finalizeWorldSystems.Add(CleanUpMediaPlayerSystem.InjectToWorld(ref builder, mediaPlayerPool, videoTexturePool)); #endif diff --git a/Explorer/Assets/DCL/WebRequests/WebRequestControllerExtensions.cs b/Explorer/Assets/DCL/WebRequests/WebRequestControllerExtensions.cs index 866734ac22..e00581411e 100644 --- a/Explorer/Assets/DCL/WebRequests/WebRequestControllerExtensions.cs +++ b/Explorer/Assets/DCL/WebRequests/WebRequestControllerExtensions.cs @@ -165,6 +165,7 @@ public static async UniTask IsHeadReachableAsync(this IWebRequestControlle { // It means there is no such end-point at all case WebRequestUtils.BAD_REQUEST: + case WebRequestUtils.FORBIDDEN_ACCESS: case WebRequestUtils.NOT_FOUND: return false; } diff --git a/Explorer/Assets/DCL/WebRequests/WebRequestUtils.cs b/Explorer/Assets/DCL/WebRequests/WebRequestUtils.cs index f0f3a9291f..75b9a9cfd8 100644 --- a/Explorer/Assets/DCL/WebRequests/WebRequestUtils.cs +++ b/Explorer/Assets/DCL/WebRequests/WebRequestUtils.cs @@ -11,8 +11,9 @@ namespace DCL.WebRequests public static class WebRequestUtils { public static string CANNOT_CONNECT_ERROR = "Cannot connect to destination host"; - + public const int BAD_REQUEST = 400; + public const int FORBIDDEN_ACCESS = 403; public const int NOT_FOUND = 404; public static SuppressExceptionWithFallback SuppressExceptionsWithFallback(this TCoreOp coreOp, TResult fallbackValue, SuppressExceptionWithFallback.Behaviour behaviour = SuppressExceptionWithFallback.Behaviour.Default, ReportData? reportContext = null) where TWebRequest: struct, ITypedWebRequest where TCoreOp: IWebRequestOp => From 070fddb6ac2573b9048a05286d0722ca0cf44662 Mon Sep 17 00:00:00 2001 From: Ashley Canning Date: Thu, 31 Oct 2024 16:10:11 +0000 Subject: [PATCH 13/24] fix: attempt to remove build id (#2669) * fix: attempt to remove build id Signed-off-by: Ashley Canning * Update build.py Signed-off-by: Ashley Canning * Update build.py Signed-off-by: Ashley Canning * Update build.py Signed-off-by: Ashley Canning * Update build.py Signed-off-by: Ashley Canning --------- Signed-off-by: Ashley Canning --- scripts/cloudbuild/build.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/cloudbuild/build.py b/scripts/cloudbuild/build.py index 5c686bbe1d..0c46316fdb 100644 --- a/scripts/cloudbuild/build.py +++ b/scripts/cloudbuild/build.py @@ -73,10 +73,11 @@ def generate_body(template_target, name, branch, options, remoteCacheStrategy): print(f"Using cache strategy target: {remoteCacheStrategy}") - # Remove cache for new targets - if 'buildTargetCopyCache' in body['settings']: - del body['settings']['buildTargetCopyCache'] - + del body['settings']['buildTargetCopyCache'] + + # Remove buildtargetid for new targets + del body['buildtargetid'] + return body # Set target name based on branch, without commit SHA From c184dc88314a8b2127105410112107d6b27f7705 Mon Sep 17 00:00:00 2001 From: Ashley Canning Date: Thu, 31 Oct 2024 18:36:09 +0000 Subject: [PATCH 14/24] Update build.py (#2681) Signed-off-by: Ashley Canning --- scripts/cloudbuild/build.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/cloudbuild/build.py b/scripts/cloudbuild/build.py index 0c46316fdb..5e453ca0a5 100644 --- a/scripts/cloudbuild/build.py +++ b/scripts/cloudbuild/build.py @@ -73,7 +73,9 @@ def generate_body(template_target, name, branch, options, remoteCacheStrategy): print(f"Using cache strategy target: {remoteCacheStrategy}") - del body['settings']['buildTargetCopyCache'] + # Remove cache for new targets + if 'buildTargetCopyCache' in body['settings']: + del body['settings']['buildTargetCopyCache'] # Remove buildtargetid for new targets del body['buildtargetid'] From c2ec69e62e8ef24179fb1749e2539475285819b3 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Molteni Date: Thu, 31 Oct 2024 16:39:16 -0300 Subject: [PATCH 15/24] fix: copy offline realm adapter value (#2613) --- .../Multiplayer/Connections/Rooms/Connective/IConnectiveRoom.cs | 2 +- Explorer/Assets/Scenes/Main.unity | 2 +- Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Explorer/Assets/DCL/Multiplayer/Connections/Rooms/Connective/IConnectiveRoom.cs b/Explorer/Assets/DCL/Multiplayer/Connections/Rooms/Connective/IConnectiveRoom.cs index 4b569c9e53..1a483ca948 100644 --- a/Explorer/Assets/DCL/Multiplayer/Connections/Rooms/Connective/IConnectiveRoom.cs +++ b/Explorer/Assets/DCL/Multiplayer/Connections/Rooms/Connective/IConnectiveRoom.cs @@ -30,7 +30,7 @@ public UniTask StopAsync() => UniTask.CompletedTask; public State CurrentState() => - State.Running; + State.Stopped; public IRoom Room() => NullRoom.INSTANCE; diff --git a/Explorer/Assets/Scenes/Main.unity b/Explorer/Assets/Scenes/Main.unity index aec95d53f9..98ceedf9ce 100644 --- a/Explorer/Assets/Scenes/Main.unity +++ b/Explorer/Assets/Scenes/Main.unity @@ -495,7 +495,7 @@ MonoBehaviour: showSplash: 1 showAuthentication: 1 showLoading: 1 - enableLandscape: 1 + enableLandscape: 0 enableLOD: 0 enableVersionUpdateGuard: 0 enableEmulateNoLivekitConnection: 0 diff --git a/Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs b/Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs index 832bd8ed93..9f879d749c 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs @@ -107,7 +107,7 @@ public async UniTask SetRealmAsync(URLDomain realm, CancellationToken ct) new IpfsRealm(web3IdentityCache, webRequestController, realm, result), result.configurations.realmName.EnsureNotNull("Realm name not found"), result.configurations.networkId, - result.comms?.adapter ?? result.comms?.fixedAdapter ?? "offline", //"offline property like in previous implementation" + result.comms?.adapter ?? result.comms?.fixedAdapter ?? "offline:offline", //"offline property like in previous implementation" result.comms?.protocol ?? "v3", hostname ); From 7d23fd33ac4b5e96db67f8921114d5977715529a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Molteni Date: Thu, 31 Oct 2024 16:43:32 -0300 Subject: [PATCH 16/24] chore: Add promise type to extension to get more data (#2671) Co-authored-by: Ashley Canning --- .../ECS/StreamableLoading/Common/AssetPromiseExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Explorer/Assets/Scripts/ECS/StreamableLoading/Common/AssetPromiseExtensions.cs b/Explorer/Assets/Scripts/ECS/StreamableLoading/Common/AssetPromiseExtensions.cs index 82ca2e385f..f29b2c76b9 100644 --- a/Explorer/Assets/Scripts/ECS/StreamableLoading/Common/AssetPromiseExtensions.cs +++ b/Explorer/Assets/Scripts/ECS/StreamableLoading/Common/AssetPromiseExtensions.cs @@ -19,7 +19,8 @@ public static bool SafeTryConsume(this ref AssetPromi result = promise.Result ?? new StreamableLoadingResult( reportData, - new Exception("The promise generated no result") + new Exception( + $"The promise of intention {promise.LoadingIntention.GetType()} generated no result") ); return true; From f425bfd6cd62b792b19100d0af324eaccd8cc482 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Molteni Date: Thu, 31 Oct 2024 21:47:20 -0300 Subject: [PATCH 17/24] feat: support for zone terrain (#2648) --- .../Assets/DCL/Landscape/TerrainGenerator.cs | 8 +- .../DCL/Landscape/TerrainGeneratorTest.cs | 2 +- .../Landscape/Utils/LandscapeParcelService.cs | 12 ++- .../Utils/TerrainGeneratorLocalCache.cs | 77 ++++++++++++------- .../PluginSystem/Global/LandscapePlugin.cs | 11 ++- .../Global/Dynamic/BootstrapContainer.cs | 3 + .../Global/Dynamic/DynamicWorldContainer.cs | 5 +- 7 files changed, 78 insertions(+), 40 deletions(-) diff --git a/Explorer/Assets/DCL/Landscape/TerrainGenerator.cs b/Explorer/Assets/DCL/Landscape/TerrainGenerator.cs index 68a0a14021..45bd4d5247 100644 --- a/Explorer/Assets/DCL/Landscape/TerrainGenerator.cs +++ b/Explorer/Assets/DCL/Landscape/TerrainGenerator.cs @@ -27,7 +27,7 @@ public class TerrainGenerator : IDisposable, IContainParcel private const float ROOT_VERTICAL_SHIFT = -0.01f; // fix for not clipping with scene (potential) floor // increment this number if we want to force the users to generate a new terrain cache - private const int CACHE_VERSION = 8; + private const int CACHE_VERSION = 9; private const float PROGRESS_COUNTER_EMPTY_PARCEL_DATA = 0.1f; private const float PROGRESS_COUNTER_TERRAIN_DATA = 0.3f; @@ -89,7 +89,8 @@ public TerrainGenerator(IMemoryProfiler profilingProvider, bool measureTime = fa terrains = new List(); } - public void Initialize(TerrainGenerationData terrainGenData, ref NativeList emptyParcels, ref NativeParallelHashSet ownedParcels, string parcelChecksum) + public void Initialize(TerrainGenerationData terrainGenData, ref NativeList emptyParcels, + ref NativeParallelHashSet ownedParcels, string parcelChecksum, bool isZone) { this.ownedParcels = ownedParcels; this.emptyParcels = emptyParcels; @@ -97,7 +98,8 @@ public void Initialize(TerrainGenerationData terrainGenData, ref NativeList public class LandscapeParcelService { - private const string MANIFEST_URL = "https://places-dcf8abb.s3.amazonaws.com/WorldManifest.json"; + private const string ORG_MANIFEST_URL = "https://places-dcf8abb.s3.amazonaws.com/WorldManifest.json"; + private const string ZONE_MANIFEST_URL = "https://places-e22845c.s3.us-east-1.amazonaws.com/WorldManifest.json"; + private readonly IWebRequestController webRequestController; + private readonly string currentManifestURL; - public LandscapeParcelService(IWebRequestController webRequestController) + public LandscapeParcelService(IWebRequestController webRequestController, bool isZone) { + currentManifestURL = isZone ? ZONE_MANIFEST_URL : ORG_MANIFEST_URL; this.webRequestController = webRequestController; } @@ -92,7 +96,9 @@ public async UniTask LoadManifestAsync(CancellationToken ct) { try { - string? result = await webRequestController.GetAsync(new CommonArguments(URLAddress.FromString(MANIFEST_URL)), ct, ReportCategory.LANDSCAPE) + var result = await webRequestController + .GetAsync(new CommonArguments(URLAddress.FromString(currentManifestURL)), ct, + ReportCategory.LANDSCAPE) .StoreTextAsync(); if (result != null) diff --git a/Explorer/Assets/DCL/Landscape/Utils/TerrainGeneratorLocalCache.cs b/Explorer/Assets/DCL/Landscape/Utils/TerrainGeneratorLocalCache.cs index 759ff82b04..ea62931a84 100644 --- a/Explorer/Assets/DCL/Landscape/Utils/TerrainGeneratorLocalCache.cs +++ b/Explorer/Assets/DCL/Landscape/Utils/TerrainGeneratorLocalCache.cs @@ -48,6 +48,7 @@ public class TerrainLocalCache private string checksum; private const string FILE_NAME = "/terrain_cache"; private const string DICTIONARY_PATH = "/terrain_cache_dictionaries/"; + private const string ZONE_MODIFIER = "_zone"; public const string ALPHA_MAPS = "alphaMaps"; @@ -76,56 +77,69 @@ public class TerrainLocalCache private TerrainLocalCache() { } - public void SaveMetadataToFile(int seed, int chunkSize, int version, string parcelChecksum) + public void SaveMetadataToFile(int seed, int chunkSize, int version, string parcelChecksum, bool isZone) { - var path = GetFilePath(seed, chunkSize, version); + var path = GetFilePath(seed, chunkSize, version, isZone); checksum = parcelChecksum; using FileStream fileStream = File.Create(path); FORMATTER.Serialize(fileStream, this); } - public void SaveArrayToFile(string name, string offsetX, string offsetZ, T[] arrayToSave) where T : struct + public void SaveArrayToFile(string name, string offsetX, string offsetZ, T[] arrayToSave, bool isZone) + where T : struct { - var pathForDictionary = GetDictionaryFilePath(name, offsetX, offsetZ); + var pathForDictionary = GetDictionaryFilePath(name, offsetX, offsetZ, isZone); using var fileStreamForHeights = File.Create(pathForDictionary); FORMATTER.Serialize(fileStreamForHeights, arrayToSave); } - public void SaveArrayToFile(string name, string offsetX, string offsetZ, string layer, T[] arrayToSave) + public void SaveArrayToFile(string name, string offsetX, string offsetZ, string layer, T[] arrayToSave, + bool isZone) where T : struct { - var pathForDictionary = GetDictionaryFilePath(name, offsetX, offsetZ, layer); + var pathForDictionary = GetDictionaryFilePath(name, offsetX, offsetZ, layer, isZone); using var fileStreamForHeights = File.Create(pathForDictionary); FORMATTER.Serialize(fileStreamForHeights, arrayToSave); } - public async UniTask RetrieveArrayFromFileAsync(string name, string offsetX, string offsetZ) + public async UniTask RetrieveArrayFromFileAsync(string name, string offsetX, string offsetZ, + bool isZone) { await using var fileStream = - new FileStream(GetDictionaryFilePath(name, offsetX, offsetZ), FileMode.Open); + new FileStream(GetDictionaryFilePath(name, offsetX, offsetZ, isZone), FileMode.Open); return await UniTask.RunOnThreadPool(() => (T[])FORMATTER.Deserialize(fileStream)); } public async UniTask RetrieveArrayFromFileAsync(string name, string offsetX, string offsetZ, - string layer) + string layer, bool isZone) { await using var fileStream = - new FileStream(GetDictionaryFilePath(name, offsetX, offsetZ, layer), FileMode.Open); + new FileStream(GetDictionaryFilePath(name, offsetX, offsetZ, layer, isZone), FileMode.Open); return await UniTask.RunOnThreadPool(() => (T[])FORMATTER.Deserialize(fileStream)); } - private static string GetDictionaryFilePath(string name, string x, string y) + private static string GetDictionaryFilePath(string name, string x, string y, bool isZone) { + if (isZone) + return GetDictionaryDirectory() + $"{name}{ZONE_MODIFIER}_{x}_{y}.data"; + return GetDictionaryDirectory() + $"{name}_{x}_{y}.data"; } - private static string GetDictionaryFilePath(string name, string x, string y, string layer) + private static string GetDictionaryFilePath(string name, string x, string y, string layer, bool isZone) { + if (isZone) + return GetDictionaryDirectory() + $"{name}{ZONE_MODIFIER}_{x}_{y}_{layer}.data"; + return GetDictionaryDirectory() + $"{name}_{x}_{y}_{layer}.data"; } - private static string GetFilePath(int seed, int chunkSize, int version) + private static string GetFilePath(int seed, int chunkSize, int version, bool isZone) { + if (isZone) + return Application.persistentDataPath + FILE_NAME + ZONE_MODIFIER + + $"_{seed}_{chunkSize}_v{version}.data"; + return Application.persistentDataPath + FILE_NAME + $"_{seed}_{chunkSize}_v{version}.data"; } @@ -134,14 +148,15 @@ private static string GetDictionaryDirectory() return Application.persistentDataPath + DICTIONARY_PATH; } - public static async UniTask LoadAsync(int seed, int chunkSize, int version, string parcelChecksum, bool force) + public static async UniTask LoadAsync(int seed, int chunkSize, int version, + string parcelChecksum, bool force, bool isZone) { var emptyCache = new TerrainLocalCache { checksum = parcelChecksum, }; - string? filePath = GetFilePath(seed, chunkSize, version); + var filePath = GetFilePath(seed, chunkSize, version, isZone); var dictionaryPath = GetDictionaryDirectory(); CheckCorruptStates(); @@ -199,24 +214,26 @@ public class TerrainGeneratorLocalCache private readonly int chunkSize; private readonly int version; private readonly string parcelChecksum; + private readonly bool isZone; - public TerrainGeneratorLocalCache(int seed, int chunkSize, int version, string parcelChecksum) + public TerrainGeneratorLocalCache(int seed, int chunkSize, int version, string parcelChecksum, bool isZone) { this.seed = seed; this.chunkSize = chunkSize; this.version = version; this.parcelChecksum = parcelChecksum; + this.isZone = isZone; } public async UniTask LoadAsync(bool force) { - localCache = await TerrainLocalCache.LoadAsync(seed, chunkSize, version, parcelChecksum, force); + localCache = await TerrainLocalCache.LoadAsync(seed, chunkSize, version, parcelChecksum, force, isZone); ReportHub.Log(ReportCategory.LANDSCAPE, "Landscape cache loaded and its validity status is: " + localCache.IsValid()); } public void Save() { - localCache.SaveMetadataToFile(seed, chunkSize, version, parcelChecksum); + localCache.SaveMetadataToFile(seed, chunkSize, version, parcelChecksum, isZone); } public bool IsValid() => @@ -226,7 +243,8 @@ public async UniTask GetHeightsAsync(int offsetX, int offsetZ) { var heightMaps = await localCache.RetrieveArrayFromFileAsync(TerrainLocalCache.HEIGHTS, offsetX.ToString(), - offsetZ.ToString()); + offsetZ.ToString(), + isZone); return UnFlatten(heightMaps, localCache.heightX, localCache.heightY); } @@ -234,7 +252,8 @@ public async UniTask GetAlphaMapsAsync(int offsetX, int offsetZ) { var alphaMaps = await localCache.RetrieveArrayFromFileAsync(TerrainLocalCache.ALPHA_MAPS, offsetX.ToString(), - offsetZ.ToString()); + offsetZ.ToString(), + isZone); return UnFlatten(alphaMaps, localCache.alphaX, localCache.alphaY, localCache.alphaZ); } @@ -244,14 +263,15 @@ public async UniTask GetTreesAsync(int offsetX, int offsetZ) var treesDTO = await localCache.RetrieveArrayFromFileAsync(TerrainLocalCache.TREES, offsetX.ToString(), - offsetZ.ToString()); + offsetZ.ToString(), + isZone); return treesDTO.Select(TreeInstanceDTO.ToOriginal).ToArray(); } public async UniTask GetDetailLayerAsync(int offsetX, int offsetZ, int layer) { var detailLayer = await localCache.RetrieveArrayFromFileAsync(TerrainLocalCache.DETAIL_LAYER, - offsetX.ToString(), offsetZ.ToString(), layer.ToString()); + offsetX.ToString(), offsetZ.ToString(), layer.ToString(), isZone); return UnFlatten(detailLayer, localCache.detailX, localCache.detailY); } @@ -260,7 +280,8 @@ public async UniTask GetHolesAsync(int offsetX, int offsetZ) try { var holesLayer = - await localCache.RetrieveArrayFromFileAsync("holes", offsetX.ToString(), offsetZ.ToString()); + await localCache.RetrieveArrayFromFileAsync("holes", offsetX.ToString(), offsetZ.ToString(), + isZone); return UnFlatten(holesLayer, localCache.holesX, localCache.holesY); } catch (Exception e) @@ -273,7 +294,7 @@ public void SaveHoles(int offsetX, int offsetZ, bool[,] valuePairValue) { (bool[] array, int row, int col) valueTuple = Flatten(valuePairValue); localCache.SaveArrayToFile(TerrainLocalCache.HOLES, offsetX.ToString(), offsetZ.ToString(), - valueTuple.array); + valueTuple.array, isZone); localCache.holesX = valueTuple.row; localCache.holesY = valueTuple.col; } @@ -283,7 +304,7 @@ public void SaveHeights(int offsetX, int offsetZ, float[,] heightArray) { (float[] array, int row, int col) valueTuple = Flatten(heightArray); localCache.SaveArrayToFile(TerrainLocalCache.HEIGHTS, offsetX.ToString(), offsetZ.ToString(), - valueTuple.array); + valueTuple.array, isZone); localCache.heightX = valueTuple.row; localCache.heightY = valueTuple.col; } @@ -292,7 +313,7 @@ public void SaveAlphaMaps(int offsetX, int offsetZ, float[,,] alphaMaps) { (float[] array, int x, int y, int z) valueTuple = Flatten(alphaMaps); localCache.SaveArrayToFile(TerrainLocalCache.ALPHA_MAPS, offsetX.ToString(), offsetZ.ToString(), - valueTuple.array); + valueTuple.array, isZone); localCache.alphaX = valueTuple.x; localCache.alphaY = valueTuple.y; localCache.alphaZ = valueTuple.z; @@ -301,14 +322,14 @@ public void SaveAlphaMaps(int offsetX, int offsetZ, float[,,] alphaMaps) public void SaveTreeInstances(int offsetX, int offsetZ, TreeInstance[] instances) { localCache.SaveArrayToFile(TerrainLocalCache.TREES, offsetX.ToString(), offsetZ.ToString(), - instances.Select(TreeInstanceDTO.Copy).ToArray()); + instances.Select(TreeInstanceDTO.Copy).ToArray(), isZone); } public void SaveDetailLayer(int offsetX, int offsetZ, int layer, int[,] detailLayer) { (int[] array, int row, int col) valueTuple = Flatten(detailLayer); localCache.SaveArrayToFile(TerrainLocalCache.DETAIL_LAYER, offsetX.ToString(), offsetZ.ToString(), - layer.ToString(), valueTuple.array); + layer.ToString(), valueTuple.array, isZone); localCache.detailX = valueTuple.row; localCache.detailY = valueTuple.col; } diff --git a/Explorer/Assets/DCL/PluginSystem/Global/LandscapePlugin.cs b/Explorer/Assets/DCL/PluginSystem/Global/LandscapePlugin.cs index 1f2cd170ef..3f95756cf5 100644 --- a/Explorer/Assets/DCL/PluginSystem/Global/LandscapePlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/Global/LandscapePlugin.cs @@ -27,6 +27,7 @@ public class LandscapePlugin : IDCLGlobalPlugin private readonly IDebugContainerBuilder debugContainerBuilder; private readonly MapRendererTextureContainer textureContainer; private readonly bool enableLandscape; + private readonly bool isZone; private ProvidedAsset realmPartitionSettings; private ProvidedAsset landscapeData; private ProvidedAsset parcelData; @@ -41,18 +42,19 @@ public LandscapePlugin(SatelliteFloor floor, IDebugContainerBuilder debugContainerBuilder, MapRendererTextureContainer textureContainer, IWebRequestController webRequestController, - bool enableLandscape) + bool enableLandscape, + bool isZone) { this.floor = floor; this.assetsProvisioner = assetsProvisioner; this.debugContainerBuilder = debugContainerBuilder; this.textureContainer = textureContainer; this.enableLandscape = enableLandscape; - + this.isZone = isZone; this.terrainGenerator = terrainGenerator; this.worldTerrainGenerator = worldTerrainGenerator; - parcelService = new LandscapeParcelService(webRequestController); + parcelService = new LandscapeParcelService(webRequestController, isZone); } public void Dispose() @@ -90,7 +92,8 @@ public async UniTask InitializeAsync(LandscapeSettings settings, CancellationTok parcelChecksum = fetchParcelResult.Checksum; } - terrainGenerator.Initialize(landscapeData.Value.terrainData, ref emptyParcels, ref ownedParcels, parcelChecksum); + terrainGenerator.Initialize(landscapeData.Value.terrainData, ref emptyParcels, ref ownedParcels, + parcelChecksum, isZone); worldTerrainGenerator.Initialize(landscapeData.Value.worldsTerrainData); } diff --git a/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs b/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs index ddfb366507..06d1842f26 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs @@ -50,6 +50,8 @@ public class BootstrapContainer : DCLGlobalContainer public bool LocalSceneDevelopment { get; private set; } public bool UseRemoteAssetBundles { get; private set; } + public DecentralandEnvironment Environment { get; private set; } + public override void Dispose() { base.Dispose(); @@ -85,6 +87,7 @@ public static async UniTask CreateAsync( ApplicationParametersParser = applicationParametersParser, DebugSettings = debugSettings, WorldVolumeMacBus = new WorldVolumeMacBus(), + Environment = sceneLoaderSettings.DecentralandEnvironment }; await bootstrapContainer.InitializeContainerAsync(settingsContainer, ct, async container => diff --git a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs index 787026e3a1..d7cd4c9b22 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs @@ -234,7 +234,10 @@ async UniTask InitializeContainersAsync(IPluginSettingsContainer settingsContain var genesisTerrain = new TerrainGenerator(staticContainer.Profiler); var worldsTerrain = new WorldTerrainGenerator(); var satelliteView = new SatelliteFloor(); - var landscapePlugin = new LandscapePlugin(satelliteView, genesisTerrain, worldsTerrain, assetsProvisioner, debugBuilder, container.MapRendererContainer.TextureContainer, staticContainer.WebRequestsContainer.WebRequestController, dynamicWorldParams.EnableLandscape); + var landscapePlugin = new LandscapePlugin(satelliteView, genesisTerrain, worldsTerrain, assetsProvisioner, + debugBuilder, container.MapRendererContainer.TextureContainer, + staticContainer.WebRequestsContainer.WebRequestController, dynamicWorldParams.EnableLandscape, + bootstrapContainer.Environment.Equals(DecentralandEnvironment.Zone)); IMultiPool MultiPoolFactory() => new DCLMultiPool(); From 039cbb90cc9e1f6d1977a48070f00c11f8192668 Mon Sep 17 00:00:00 2001 From: Ashley Canning Date: Fri, 1 Nov 2024 08:02:45 +0000 Subject: [PATCH 18/24] Update build.py Signed-off-by: Ashley Canning --- scripts/cloudbuild/build.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/cloudbuild/build.py b/scripts/cloudbuild/build.py index 5e453ca0a5..ef5ed7e7b5 100644 --- a/scripts/cloudbuild/build.py +++ b/scripts/cloudbuild/build.py @@ -77,8 +77,9 @@ def generate_body(template_target, name, branch, options, remoteCacheStrategy): if 'buildTargetCopyCache' in body['settings']: del body['settings']['buildTargetCopyCache'] - # Remove buildtargetid for new targets - del body['buildtargetid'] + # Remove buildtargetid for new targets (unity bug) + if 'buildtargetid' in body: + del body['buildtargetid'] return body From c8de7ae320bf342cf4f48c7ca6720f5ccd8d450d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ansis=20M=C4=81li=C5=86=C5=A1?= Date: Fri, 1 Nov 2024 09:47:54 +0100 Subject: [PATCH 19/24] Avoid allocating new strings every time we sign a web request (#2635) Co-authored-by: Juan Ignacio Molteni Co-authored-by: Ashley Canning --- Explorer/Assets/DCL/Web3/Chains/AuthChain.cs | 2 ++ .../Assets/DCL/WebRequests/RequestEnvelope.cs | 20 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Explorer/Assets/DCL/Web3/Chains/AuthChain.cs b/Explorer/Assets/DCL/Web3/Chains/AuthChain.cs index dfbf098a59..a6c3ecaea0 100644 --- a/Explorer/Assets/DCL/Web3/Chains/AuthChain.cs +++ b/Explorer/Assets/DCL/Web3/Chains/AuthChain.cs @@ -10,6 +10,8 @@ public class AuthChain : IEnumerable, IDisposable { private static readonly ThreadSafeObjectPool POOL = new (() => new AuthChain()); + // If you ever change the container or key type, please check that your change does not break + // the AuthChainHeaderNames class, if it still exists at the time. private readonly Dictionary chain = new (); private bool disposed; diff --git a/Explorer/Assets/DCL/WebRequests/RequestEnvelope.cs b/Explorer/Assets/DCL/WebRequests/RequestEnvelope.cs index a5703f44dc..2345973316 100644 --- a/Explorer/Assets/DCL/WebRequests/RequestEnvelope.cs +++ b/Explorer/Assets/DCL/WebRequests/RequestEnvelope.cs @@ -128,7 +128,7 @@ private void SignRequest(UnityWebRequest unityWebRequest, IWeb3IdentityCache web foreach (AuthLink link in authChain) { - var name = $"x-identity-auth-chain-{i}"; + string name = AuthChainHeaderNames.Get(i); string value = link.ToJson(); unityWebRequest.SetRequestHeader(name, value); #if DEBUG @@ -141,4 +141,22 @@ private void SignRequest(UnityWebRequest unityWebRequest, IWeb3IdentityCache web #endif } } + + /// Because is generic, we have + /// to put this out here, else we get a copy for every specific type of it we create. + internal static class AuthChainHeaderNames + { + private static readonly string[] AUTH_CHAIN_HEADER_NAMES; + + static AuthChainHeaderNames() + { + int maxAuthChainHeaders = Enum.GetNames(typeof(AuthLinkType)).Length; + AUTH_CHAIN_HEADER_NAMES = new string[maxAuthChainHeaders]; + for (int i = 0; i < maxAuthChainHeaders; i++) + AUTH_CHAIN_HEADER_NAMES[i] = $"x-identity-auth-chain-{i}"; + } + + public static string Get(int index) + => AUTH_CHAIN_HEADER_NAMES[index]; + } } From e92823859eca42f606a57ed6ef4f1e821f37c520 Mon Sep 17 00:00:00 2001 From: lorenzo-ranciaffi <41125365+lorenzo-ranciaffi@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:05:02 +0100 Subject: [PATCH 20/24] add scene restriction minimap badge (#2437) --- .../Assets/DCL/Minimap/Assets/Minimap.prefab | 266 ++++++++++ .../Assets/SceneRestrictionText.prefab | 138 +++++ .../Assets/SceneRestrictionText.prefab.meta | 7 + Explorer/Assets/DCL/Minimap/Minimap.asmdef | 3 +- .../Assets/DCL/Minimap/MinimapController.cs | 9 +- Explorer/Assets/DCL/Minimap/MinimapView.cs | 3 + .../Minimap/SceneRestrictionsController.cs | 90 ++++ .../SceneRestrictionsController.cs.meta | 3 + .../DCL/Minimap/SceneRestrictionsView.cs | 51 ++ .../DCL/Minimap/SceneRestrictionsView.cs.meta | 3 + Explorer/Assets/DCL/Minimap/Tests.meta | 3 + .../DCL/Minimap/Tests/Minimap.Tests.asmref | 3 + .../Minimap/Tests/Minimap.Tests.asmref.meta | 7 + .../Tests/SceneRestrictionControllerShould.cs | 125 +++++ .../SceneRestrictionControllerShould.cs.meta | 3 + .../DCL/PluginSystem/DCL.Plugins.asmdef | 3 +- .../DCL/PluginSystem/Global/MinimapPlugin.cs | 8 +- .../World/CharacterTriggerAreaPlugin.cs | 14 +- .../PluginSystem/World/InputModifierPlugin.cs | 7 +- .../PluginSystem/World/MainCameraPlugin.cs | 5 + .../AvatarModifierAreaHandlerSystem.cs | 25 +- .../AvatarModifierAreaHandlerSystemShould.cs | 5 +- .../Systems/CameraModeAreaHandlerSystem.cs | 10 +- .../CameraModeAreaHandlerSystemShould.cs | 3 +- .../MainCamera/Systems/MainCameraSystem.cs | 10 + .../Tests/EditMode/MainCameraSystemShould.cs | 3 +- .../SDKComponents/DCL.SDKComponents.asmdef | 5 +- .../Systems/InputModifierHandlerSystem.cs | 24 +- .../DCL/SceneRestrictionBusController.meta | 8 + .../SceneRestriction.meta | 3 + .../SceneRestriction/Assets.meta | 8 + .../Assets/SceneRestrictionsToast.prefab | 475 ++++++++++++++++++ .../Assets/SceneRestrictionsToast.prefab.meta | 7 + .../SceneRestriction/SceneRestriction.cs | 58 +++ .../SceneRestriction/SceneRestriction.cs.meta | 3 + .../SceneRestrictionBus.asmdef | 14 + .../SceneRestrictionBus.asmdef.meta | 7 + .../SceneRestrictionBus.meta | 3 + .../ISceneRestrictionBusController.cs | 9 + .../ISceneRestrictionBusController.cs.meta | 3 + .../SceneRestrictionBusController.cs | 16 + .../SceneRestrictionBusController.cs.meta | 3 + .../Tests/Editor/DCL.EditMode.Tests.asmdef | 4 +- .../Tests/PlayMode/DCL.PlayMode.Tests.asmdef | 1 + .../UI/MainUIContainer/MainUIContainer.prefab | 165 ++++++ .../Scripts/Global/Dynamic/Bootstraper.cs | 5 +- .../Global/Dynamic/DynamicWorldContainer.cs | 5 +- .../Assets/Scripts/Global/StaticContainer.cs | 10 +- 48 files changed, 1614 insertions(+), 29 deletions(-) create mode 100644 Explorer/Assets/DCL/Minimap/Assets/SceneRestrictionText.prefab create mode 100644 Explorer/Assets/DCL/Minimap/Assets/SceneRestrictionText.prefab.meta create mode 100644 Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs create mode 100644 Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs.meta create mode 100644 Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs create mode 100644 Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs.meta create mode 100644 Explorer/Assets/DCL/Minimap/Tests.meta create mode 100644 Explorer/Assets/DCL/Minimap/Tests/Minimap.Tests.asmref create mode 100644 Explorer/Assets/DCL/Minimap/Tests/Minimap.Tests.asmref.meta create mode 100644 Explorer/Assets/DCL/Minimap/Tests/SceneRestrictionControllerShould.cs create mode 100644 Explorer/Assets/DCL/Minimap/Tests/SceneRestrictionControllerShould.cs.meta create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController.meta create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction.meta create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets.meta create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets/SceneRestrictionsToast.prefab create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets/SceneRestrictionsToast.prefab.meta create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/SceneRestriction.cs create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/SceneRestriction.cs.meta create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.asmdef create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.asmdef.meta create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.meta create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/ISceneRestrictionBusController.cs create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/ISceneRestrictionBusController.cs.meta create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/SceneRestrictionBusController.cs create mode 100644 Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/SceneRestrictionBusController.cs.meta diff --git a/Explorer/Assets/DCL/Minimap/Assets/Minimap.prefab b/Explorer/Assets/DCL/Minimap/Assets/Minimap.prefab index fb19154a07..8d7a5d3a28 100644 --- a/Explorer/Assets/DCL/Minimap/Assets/Minimap.prefab +++ b/Explorer/Assets/DCL/Minimap/Assets/Minimap.prefab @@ -769,6 +769,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 742869874383310255} + - {fileID: 5647564073185826373} - {fileID: 2377257890637130518} m_Father: {fileID: 2505400538292533899} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -1458,6 +1459,7 @@ RectTransform: - {fileID: 1877242611476222848} - {fileID: 2505400538292533899} - {fileID: 3370025681631351507} + - {fileID: 6423285587092867117} m_Father: {fileID: 3721001069623505348} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} @@ -2366,6 +2368,148 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 2 +--- !u!1 &6650628162310056693 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5647564073185826373} + - component: {fileID: 4471790232475835440} + - component: {fileID: 6020027160394487556} + - component: {fileID: 9018517914487904932} + - component: {fileID: 7142479151797288909} + m_Layer: 5 + m_Name: SceneRestrictions + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &5647564073185826373 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6650628162310056693} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 2480083131922657171} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 19.0937} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &4471790232475835440 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6650628162310056693} + m_CullTransparentMesh: 1 +--- !u!114 &6020027160394487556 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6650628162310056693} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.99607843, g: 0.63529414, b: 0.09019608, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 11e50157680834b92b7f75220b425747, type: 3} + m_Type: 0 + m_PreserveAspect: 1 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &9018517914487904932 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6650628162310056693} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Delegates: + - eventID: 0 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 6087439276851581053} + m_TargetAssemblyTypeName: DCL.Minimap.SceneRestrictionsView, Minimap + m_MethodName: OnPointerEnter + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - eventID: 1 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 6087439276851581053} + m_TargetAssemblyTypeName: DCL.Minimap.SceneRestrictionsView, Minimap + m_MethodName: OnPointerExit + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &7142479151797288909 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6650628162310056693} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreLayout: 0 + m_MinWidth: -1 + m_MinHeight: -1 + m_PreferredWidth: 20 + m_PreferredHeight: -1 + m_FlexibleWidth: -1 + m_FlexibleHeight: -1 + m_LayoutPriority: 1 --- !u!1 &6683467427398306397 GameObject: m_ObjectHideFlags: 0 @@ -3006,6 +3150,7 @@ MonoBehaviour: k__BackingField: {fileID: 2377257890637130518} k__BackingField: {fileID: 3370025681631351507} k__BackingField: {fileID: 8345986520417290339} + k__BackingField: {fileID: 6087439276851581053} k__BackingField: {fileID: 5048152786859444568} k__BackingField: {fileID: 7701158923936790273} k__BackingField: {fileID: 9100000, guid: 1ca5d010fc5aeae41a709d95fe3ed97e, type: 2} @@ -3834,6 +3979,127 @@ RectTransform: m_CorrespondingSourceObject: {fileID: 1073285033825917661, guid: 9baa91391764741beab377f38b1251bc, type: 3} m_PrefabInstance: {fileID: 3987623694238618231} m_PrefabAsset: {fileID: 0} +--- !u!1001 &4471915084233856896 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 6423328223121998152} + m_Modifications: + - target: {fileID: 684450512256360453, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4966924927682336045, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_Name + value: SceneRestrictionsToast + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_AnchorMax.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_AnchorMin.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_SizeDelta.x + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_SizeDelta.y + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_AnchoredPosition.x + value: 56 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_AnchoredPosition.y + value: 100.7 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7671181397625112573, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + propertyPath: k__BackingField + value: + objectReference: {fileID: 5647564073185826373} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} +--- !u!114 &6087439276851581053 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 7671181397625112573, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + m_PrefabInstance: {fileID: 4471915084233856896} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bafe95e137294f21a295a8d5abb600bd, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!224 &6423285587092867117 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 7434166619040309165, guid: ce62870d41fed4cd7a4116ce6791c410, type: 3} + m_PrefabInstance: {fileID: 4471915084233856896} + m_PrefabAsset: {fileID: 0} --- !u!1001 &6109601585463109938 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Explorer/Assets/DCL/Minimap/Assets/SceneRestrictionText.prefab b/Explorer/Assets/DCL/Minimap/Assets/SceneRestrictionText.prefab new file mode 100644 index 0000000000..04ab31c443 --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/Assets/SceneRestrictionText.prefab @@ -0,0 +1,138 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &7173452363831430961 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2835586610455376994} + - component: {fileID: 2519259663762410760} + - component: {fileID: 8223608107908688819} + m_Layer: 5 + m_Name: SceneRestrictionText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2835586610455376994 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7173452363831430961} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 244, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2519259663762410760 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7173452363831430961} + m_CullTransparentMesh: 1 +--- !u!114 &8223608107908688819 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7173452363831430961} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: "\u2022 The camera is locked" + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 96ae0a2159a39234f858ea23bdcc74ad, type: 2} + m_sharedMaterial: {fileID: 735423033564544980, guid: 96ae0a2159a39234f858ea23bdcc74ad, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294769916 + m_fontColor: {r: 0.9882353, g: 0.9882353, b: 0.9882353, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 14 + m_fontSizeBase: 14 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_TextWrappingMode: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 0 + m_ActiveFontFeatures: 6e72656b + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_EmojiFallbackSupport: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0.6618347} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} diff --git a/Explorer/Assets/DCL/Minimap/Assets/SceneRestrictionText.prefab.meta b/Explorer/Assets/DCL/Minimap/Assets/SceneRestrictionText.prefab.meta new file mode 100644 index 0000000000..c91d4d9f2d --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/Assets/SceneRestrictionText.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0f5931afe9f9444518eb3629d8086e3f +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/Minimap/Minimap.asmdef b/Explorer/Assets/DCL/Minimap/Minimap.asmdef index 0cb2b1e0ca..635aa781de 100644 --- a/Explorer/Assets/DCL/Minimap/Minimap.asmdef +++ b/Explorer/Assets/DCL/Minimap/Minimap.asmdef @@ -24,7 +24,8 @@ "GUID:0401f68d61b24c63a3abf51e27bb46f1", "GUID:766b242fb43af451aaa331f39872177d", "GUID:d832748739a186646b8656bdbd447ad0", - "GUID:286980af24684da6acc1caa413039811" + "GUID:286980af24684da6acc1caa413039811", + "GUID:1300820cd310d4584b09afde765bdd16" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Explorer/Assets/DCL/Minimap/MinimapController.cs b/Explorer/Assets/DCL/Minimap/MinimapController.cs index 11034d30d7..75d6555817 100644 --- a/Explorer/Assets/DCL/Minimap/MinimapController.cs +++ b/Explorer/Assets/DCL/Minimap/MinimapController.cs @@ -16,6 +16,7 @@ using DCL.MapRenderer.MapLayers.Pins; using DCL.MapRenderer.MapLayers.PlayerMarker; using DCL.PlacesAPIService; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.UI; using DG.Tweening; using ECS; @@ -44,11 +45,13 @@ public partial class MinimapController : ControllerBase, IMapActivi private readonly IRealmNavigator realmNavigator; private readonly IScenesCache scenesCache; private readonly IMapPathEventBus mapPathEventBus; + private readonly ISceneRestrictionBusController sceneRestrictionBusController; private CancellationTokenSource cts; private MapRendererTrackPlayerPosition mapRendererTrackPlayerPosition; private IMapCameraController? mapCameraController; private Vector2Int previousParcelPosition; + private SceneRestrictionsController sceneRestrictionsController; public IReadOnlyDictionary LayersParameters { get; } = new Dictionary { { MapLayer.PlayerMarker, new PlayerMarkerParameter { BackgroundIsActive = false } } }; @@ -64,7 +67,8 @@ public MinimapController( IChatMessagesBus chatMessagesBus, IRealmNavigator realmNavigator, IScenesCache scenesCache, - IMapPathEventBus mapPathEventBus + IMapPathEventBus mapPathEventBus, + ISceneRestrictionBusController sceneRestrictionBusController ) : base(viewFactory) { this.mapRenderer = mapRenderer; @@ -75,6 +79,7 @@ IMapPathEventBus mapPathEventBus this.realmNavigator = realmNavigator; this.scenesCache = scenesCache; this.mapPathEventBus = mapPathEventBus; + this.sceneRestrictionBusController = sceneRestrictionBusController; } public void HookPlayerPositionTrackingSystem(TrackPlayerPositionSystem system) => @@ -96,6 +101,7 @@ protected override void OnViewInstantiated() viewInstance.SideMenuCanvasGroup.alpha = 0; viewInstance.SideMenuCanvasGroup.gameObject.SetActive(false); new SideMenuController(viewInstance.sideMenuView); + sceneRestrictionsController = new SceneRestrictionsController(viewInstance.sceneRestrictionsView, sceneRestrictionBusController); SetWorldMode(realmData.ScenesAreFixed); realmNavigator.RealmChanged += OnRealmChanged; mapPathEventBus.OnShowPinInMinimapEdge += ShowPinInMinimapEdge; @@ -249,6 +255,7 @@ public override void Dispose() realmNavigator.RealmChanged -= OnRealmChanged; mapPathEventBus.OnShowPinInMinimapEdge -= ShowPinInMinimapEdge; mapPathEventBus.OnHidePinInMinimapEdge -= HidePinInMinimapEdge; + sceneRestrictionsController.Dispose(); } protected override UniTask WaitForCloseIntentAsync(CancellationToken ct) => diff --git a/Explorer/Assets/DCL/Minimap/MinimapView.cs b/Explorer/Assets/DCL/Minimap/MinimapView.cs index fa48e8cd38..b52db32827 100644 --- a/Explorer/Assets/DCL/Minimap/MinimapView.cs +++ b/Explorer/Assets/DCL/Minimap/MinimapView.cs @@ -52,6 +52,9 @@ public class MinimapView : ViewBase, IView [field: SerializeField] internal SideMenuView sideMenuView { get; private set; } + [field: SerializeField] + internal SceneRestrictionsView sceneRestrictionsView { get; private set; } + [field: SerializeField] internal Animator minimapAnimator { get; private set; } diff --git a/Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs b/Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs new file mode 100644 index 0000000000..2de60c025e --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs @@ -0,0 +1,90 @@ +using DCL.SceneRestrictionBusController.SceneRestriction; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; +using DG.Tweening; +using System; +using System.Collections.Generic; +using TMPro; +using UnityEngine; + +namespace DCL.Minimap +{ + public class SceneRestrictionsController : IDisposable + { + private const float TOAST_X_POSITION_OFFSET_ICON_WIDTH_SCALER = 0.75f; + + private readonly ISceneRestrictionsView restrictionsView; + private readonly Dictionary restrictionsRegistry = new(); + private readonly Dictionary restrictionsGameObjects = new(); + private readonly Dictionary restrictionsTexts = new() + { + { SceneRestrictions.CAMERA_LOCKED, "• The camera is locked" }, + { SceneRestrictions.AVATAR_HIDDEN, "• The avatars are hidden" }, + { SceneRestrictions.AVATAR_MOVEMENTS_BLOCKED, "• Avatar movements are blocked" }, + { SceneRestrictions.PASSPORT_CANNOT_BE_OPENED, "• Passports can not be opened" }, + { SceneRestrictions.EXPERIENCES_BLOCKED, "• Experiences are blocked" }, + }; + + public SceneRestrictionsController(ISceneRestrictionsView restrictionsView, ISceneRestrictionBusController sceneRestrictionBusController) + { + this.restrictionsView = restrictionsView; + + restrictionsView.OnPointerEnterEvent += OnMouseEnter; + restrictionsView.OnPointerExitEvent += OnMouseExit; + sceneRestrictionBusController.SubscribeToSceneRestriction(ManageSceneRestrictions); + + foreach (SceneRestrictions restriction in Enum.GetValues(typeof(SceneRestrictions))) + { + restrictionsRegistry[restriction] = 0; + + GameObject restrictionsObject = GameObject.Instantiate(restrictionsView.RestrictionTextPrefab, restrictionsView.ToastTextParent.transform); + restrictionsObject.GetComponent().SetText(restrictionsTexts[restriction]); + restrictionsObject.SetActive(false); + restrictionsObject.name = restriction.ToString(); + restrictionsGameObjects[restriction] = restrictionsObject; + } + } + + public void Dispose() + { + restrictionsView.OnPointerEnterEvent -= OnMouseEnter; + restrictionsView.OnPointerExitEvent -= OnMouseExit; + } + + private void OnMouseEnter() + { + Vector3 toastPosition = restrictionsView.ToastRectTransform.anchoredPosition; + toastPosition.x = restrictionsView.SceneRestrictionsIcon.transform.localPosition.x - (restrictionsView.SceneRestrictionsIcon.rect.width * TOAST_X_POSITION_OFFSET_ICON_WIDTH_SCALER); + restrictionsView.ToastRectTransform.anchoredPosition = toastPosition; + restrictionsView.ToastCanvasGroup.DOFade(1f, restrictionsView.FadeTime); + } + + private void OnMouseExit() => + restrictionsView.ToastCanvasGroup.DOFade(0f, restrictionsView.FadeTime); + + private void ManageSceneRestrictions(SceneRestriction sceneRestriction) + { + int currentRestrictionCounter = restrictionsRegistry[sceneRestriction.Type]; + + currentRestrictionCounter += sceneRestriction.Action == SceneRestrictionsAction.APPLIED ? 1 : -1; + currentRestrictionCounter = Mathf.Clamp(currentRestrictionCounter, 0, int.MaxValue); + + restrictionsRegistry[sceneRestriction.Type] = currentRestrictionCounter; + + restrictionsGameObjects[sceneRestriction.Type].SetActive(currentRestrictionCounter > 0); + + bool restrictionIconEnabled = RestrictionsRegistryHasAtLeastOneActive(); + restrictionsView.SceneRestrictionsIcon.gameObject.SetActive(restrictionIconEnabled); + if (!restrictionIconEnabled) + OnMouseExit(); + } + + private bool RestrictionsRegistryHasAtLeastOneActive() + { + foreach (int counter in restrictionsRegistry.Values) + if (counter > 0) + return true; + + return false; + } + } +} diff --git a/Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs.meta b/Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs.meta new file mode 100644 index 0000000000..a424e95492 --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3316e4e419dd4c69b0727775fad2ed31 +timeCreated: 1729088411 \ No newline at end of file diff --git a/Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs b/Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs new file mode 100644 index 0000000000..47abbcc6f7 --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs @@ -0,0 +1,51 @@ +using System; +using UnityEngine; + +namespace DCL.Minimap +{ + public interface ISceneRestrictionsView + { + RectTransform SceneRestrictionsIcon { get; set; } + GameObject RestrictionTextPrefab { get; set; } + CanvasGroup ToastCanvasGroup { get; set; } + GameObject ToastTextParent { get; set; } + float FadeTime { get; set; } + RectTransform ToastRectTransform { get; set; } + + event Action? OnPointerEnterEvent; + event Action? OnPointerExitEvent; + } + + public class SceneRestrictionsView : MonoBehaviour, ISceneRestrictionsView + { + [field: SerializeField] + public RectTransform SceneRestrictionsIcon { get; set; } + + [field: SerializeField] + public GameObject RestrictionTextPrefab { get; set; } + + [field: SerializeField] + public CanvasGroup ToastCanvasGroup { get; set; } + + [field: SerializeField] + public GameObject ToastTextParent { get; set; } + + [field: SerializeField] + public float FadeTime { get; set; } = 0.3f; + + public RectTransform ToastRectTransform { get; set; } + + public event Action? OnPointerEnterEvent; + public event Action? OnPointerExitEvent; + + public void OnPointerEnter() => OnPointerEnterEvent?.Invoke(); + public void OnPointerExit() => OnPointerExitEvent?.Invoke(); + + private void Awake() + { + ToastCanvasGroup.alpha = 0; + SceneRestrictionsIcon.gameObject.SetActive(false); + ToastRectTransform = ToastCanvasGroup.GetComponent(); + } + } +} diff --git a/Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs.meta b/Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs.meta new file mode 100644 index 0000000000..c1ae7b74f3 --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bafe95e137294f21a295a8d5abb600bd +timeCreated: 1729088427 \ No newline at end of file diff --git a/Explorer/Assets/DCL/Minimap/Tests.meta b/Explorer/Assets/DCL/Minimap/Tests.meta new file mode 100644 index 0000000000..99792fd0b1 --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/Tests.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2e6728d743dc44be8d22e7e019670499 +timeCreated: 1730367185 \ No newline at end of file diff --git a/Explorer/Assets/DCL/Minimap/Tests/Minimap.Tests.asmref b/Explorer/Assets/DCL/Minimap/Tests/Minimap.Tests.asmref new file mode 100644 index 0000000000..9c56917b75 --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/Tests/Minimap.Tests.asmref @@ -0,0 +1,3 @@ +{ + "reference": "GUID:da80994a355e49d5b84f91c0a84a721f" +} \ No newline at end of file diff --git a/Explorer/Assets/DCL/Minimap/Tests/Minimap.Tests.asmref.meta b/Explorer/Assets/DCL/Minimap/Tests/Minimap.Tests.asmref.meta new file mode 100644 index 0000000000..77b30bbd3d --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/Tests/Minimap.Tests.asmref.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a1c13e34cd925414c96098fecccf141b +AssemblyDefinitionReferenceImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/Minimap/Tests/SceneRestrictionControllerShould.cs b/Explorer/Assets/DCL/Minimap/Tests/SceneRestrictionControllerShould.cs new file mode 100644 index 0000000000..ae9431c89b --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/Tests/SceneRestrictionControllerShould.cs @@ -0,0 +1,125 @@ +using DCL.SceneRestrictionBusController.SceneRestriction; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; +using NSubstitute; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using TMPro; +using UnityEngine; + +namespace DCL.Minimap.Tests +{ + public class SceneRestrictionControllerShould + { + private ISceneRestrictionsView sceneRestrictionsView; + private ISceneRestrictionBusController sceneRestrictionBusController; + private GameObject toastTextParent; + private GameObject sceneRestrictionsIcon; + + private readonly Dictionary restrictionTexts = new(); + + private SceneRestrictionsController sceneRestrictionsController; + + [SetUp] + public void SetUp() + { + sceneRestrictionsView = Substitute.For(); + sceneRestrictionBusController = new SceneRestrictionBusController.SceneRestrictionBus.SceneRestrictionBusController(); + sceneRestrictionsView.RestrictionTextPrefab.Returns(new GameObject("MockPrefab", typeof(TextMeshProUGUI))); + + toastTextParent = new GameObject("ToastTextParentMock", typeof(Transform)); + sceneRestrictionsView.ToastTextParent.Returns(toastTextParent); + + sceneRestrictionsIcon = new GameObject("IconMock", typeof(RectTransform)); + sceneRestrictionsView.SceneRestrictionsIcon.Returns(sceneRestrictionsIcon.GetComponent()); + sceneRestrictionsIcon.SetActive(false); + + sceneRestrictionsController = new SceneRestrictionsController(sceneRestrictionsView, sceneRestrictionBusController); + + foreach (SceneRestrictions restriction in Enum.GetValues(typeof(SceneRestrictions))) + restrictionTexts[restriction] = toastTextParent.transform.Find(restriction.ToString()); + } + + [TearDown] + public void Dispose() => + sceneRestrictionsController.Dispose(); + + [Test] + public void ShowAllRestrictions() + { + //Assert + foreach (SceneRestrictions restriction in Enum.GetValues(typeof(SceneRestrictions))) + { + Assert.IsNotNull(restrictionTexts[restriction]); + Assert.IsFalse(restrictionTexts[restriction].gameObject.activeSelf); + } + Assert.IsFalse(sceneRestrictionsIcon.gameObject.activeSelf); + + + //Act + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateAvatarHidden(SceneRestrictionsAction.APPLIED)); + + //Assert + Assert.IsTrue(sceneRestrictionsIcon.gameObject.activeSelf); + Assert.IsTrue(restrictionTexts[SceneRestrictions.AVATAR_HIDDEN].gameObject.activeSelf); + + //Act + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateAvatarHidden(SceneRestrictionsAction.REMOVED)); + + //Assert + Assert.IsFalse(sceneRestrictionsIcon.gameObject.activeSelf); + Assert.IsFalse(restrictionTexts[SceneRestrictions.AVATAR_HIDDEN].gameObject.activeSelf); + + //Act + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateAvatarHidden(SceneRestrictionsAction.APPLIED)); + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.APPLIED)); + + //Assert + Assert.IsTrue(sceneRestrictionsIcon.gameObject.activeSelf); + Assert.IsTrue(restrictionTexts[SceneRestrictions.AVATAR_HIDDEN].gameObject.activeSelf); + Assert.IsTrue(restrictionTexts[SceneRestrictions.CAMERA_LOCKED].gameObject.activeSelf); + + //Act + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateAvatarHidden(SceneRestrictionsAction.REMOVED)); + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.REMOVED)); + + //Assert + Assert.IsFalse(sceneRestrictionsIcon.gameObject.activeSelf); + Assert.IsFalse(restrictionTexts[SceneRestrictions.AVATAR_HIDDEN].gameObject.activeSelf); + Assert.IsFalse(restrictionTexts[SceneRestrictions.CAMERA_LOCKED].gameObject.activeSelf); + + //Act + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateAvatarHidden(SceneRestrictionsAction.APPLIED)); + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.APPLIED)); + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.APPLIED)); + + //Assert + Assert.IsTrue(sceneRestrictionsIcon.gameObject.activeSelf); + Assert.IsTrue(restrictionTexts[SceneRestrictions.AVATAR_HIDDEN].gameObject.activeSelf); + Assert.IsTrue(restrictionTexts[SceneRestrictions.CAMERA_LOCKED].gameObject.activeSelf); + + //Act + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.REMOVED)); + + //Assert + Assert.IsTrue(sceneRestrictionsIcon.gameObject.activeSelf); + Assert.IsTrue(restrictionTexts[SceneRestrictions.AVATAR_HIDDEN].gameObject.activeSelf); + Assert.IsTrue(restrictionTexts[SceneRestrictions.CAMERA_LOCKED].gameObject.activeSelf); + + //Act + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.REMOVED)); + + //Assert + Assert.IsTrue(sceneRestrictionsIcon.gameObject.activeSelf); + Assert.IsTrue(restrictionTexts[SceneRestrictions.AVATAR_HIDDEN].gameObject.activeSelf); + Assert.IsFalse(restrictionTexts[SceneRestrictions.CAMERA_LOCKED].gameObject.activeSelf); + + //Act + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateAvatarHidden(SceneRestrictionsAction.REMOVED)); + + //Assert + Assert.IsFalse(sceneRestrictionsIcon.gameObject.activeSelf); + Assert.IsFalse(restrictionTexts[SceneRestrictions.AVATAR_HIDDEN].gameObject.activeSelf); + } + } +} diff --git a/Explorer/Assets/DCL/Minimap/Tests/SceneRestrictionControllerShould.cs.meta b/Explorer/Assets/DCL/Minimap/Tests/SceneRestrictionControllerShould.cs.meta new file mode 100644 index 0000000000..98a5173b2f --- /dev/null +++ b/Explorer/Assets/DCL/Minimap/Tests/SceneRestrictionControllerShould.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c7663204aa16417b9a832f0b1c968a80 +timeCreated: 1730367637 \ No newline at end of file diff --git a/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef b/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef index a9b1813dd4..cb0aa562d9 100644 --- a/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef +++ b/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef @@ -134,7 +134,8 @@ "GUID:85ca990832a04236bf895f2316bef171", "GUID:3fadcaec8a71a42e9b1c529f453acfc1", "GUID:1c5f9b69f95e40d18f11049c155eeaf8", - "GUID:8c4c611b27046bc4a848721d1fdd4a9f" + "GUID:8c4c611b27046bc4a848721d1fdd4a9f", + "GUID:1300820cd310d4584b09afde765bdd16" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Explorer/Assets/DCL/PluginSystem/Global/MinimapPlugin.cs b/Explorer/Assets/DCL/PluginSystem/Global/MinimapPlugin.cs index 11da657460..978fd61341 100644 --- a/Explorer/Assets/DCL/PluginSystem/Global/MinimapPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/Global/MinimapPlugin.cs @@ -4,6 +4,7 @@ using DCL.MapRenderer; using DCL.Minimap; using DCL.PlacesAPIService; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.UI.MainUI; using ECS; using ECS.SceneLifeCycle; @@ -29,10 +30,11 @@ public class MinimapPlugin : IDCLGlobalPlugin private readonly MainUIView mainUIView; private readonly IMapPathEventBus mapPathEventBus; private MinimapController minimapController; + private readonly ISceneRestrictionBusController sceneRestrictionBusController; public MinimapPlugin(IMVCManager mvcManager, MapRendererContainer mapRendererContainer, IPlacesAPIService placesAPIService, IRealmData realmData, IChatMessagesBus chatMessagesBus, IRealmNavigator realmNavigator, IScenesCache scenesCache, MainUIView mainUIView, - IMapPathEventBus mapPathEventBus) + IMapPathEventBus mapPathEventBus, ISceneRestrictionBusController sceneRestrictionBusController) { this.mvcManager = mvcManager; this.mapRendererContainer = mapRendererContainer; @@ -43,6 +45,7 @@ public MinimapPlugin(IMVCManager mvcManager, MapRendererContainer mapRendererCon this.scenesCache = scenesCache; this.mapPathEventBus = mapPathEventBus; this.mainUIView = mainUIView; + this.sceneRestrictionBusController = sceneRestrictionBusController; } public void Dispose() @@ -72,7 +75,8 @@ public async UniTask InitializeAsync(MinimapSettings settings, CancellationToken chatMessagesBus, realmNavigator, scenesCache, - mapPathEventBus); + mapPathEventBus, + sceneRestrictionBusController); mvcManager.RegisterController(minimapController); } diff --git a/Explorer/Assets/DCL/PluginSystem/World/CharacterTriggerAreaPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/CharacterTriggerAreaPlugin.cs index 24b8048833..6604dc07d1 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/CharacterTriggerAreaPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/CharacterTriggerAreaPlugin.cs @@ -11,9 +11,11 @@ using DCL.PluginSystem.Global; using DCL.PluginSystem.World.Dependencies; using DCL.ResourcesUnloading; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.SDKComponents.AvatarModifierArea.Systems; using DCL.SDKComponents.CameraModeArea.Systems; using DCL.Utilities; +using DCL.Web3.Identities; using ECS.LifeCycle; using ECS.LifeCycle.Systems; using System.Collections.Generic; @@ -33,6 +35,8 @@ public class CharacterTriggerAreaPlugin : IDCLWorldPlugin cameraEntityProxy; private readonly ICharacterObject characterObject; private readonly IExposedCameraData cameraData; + private readonly ISceneRestrictionBusController sceneRestrictionBusController; + private readonly IWeb3IdentityCache web3IdentityCache; private IComponentPool? characterTriggerAreaPoolRegistry; @@ -44,7 +48,9 @@ public CharacterTriggerAreaPlugin( IComponentPoolsRegistry poolsRegistry, IAssetsProvisioner assetsProvisioner, CacheCleaner cacheCleaner, - IExposedCameraData cameraData) + IExposedCameraData cameraData, + ISceneRestrictionBusController sceneRestrictionBusController, + IWeb3IdentityCache web3IdentityCache) { this.globalWorld = globalWorld; this.assetsProvisioner = assetsProvisioner; @@ -54,6 +60,8 @@ public CharacterTriggerAreaPlugin( this.cameraEntityProxy = cameraEntityProxy; this.characterObject = characterObject; this.cameraData = cameraData; + this.sceneRestrictionBusController = sceneRestrictionBusController; + this.web3IdentityCache = web3IdentityCache; } public void Dispose() @@ -72,8 +80,8 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder builder, CharacterTriggerAreaHandlerSystem.InjectToWorld(ref builder, characterTriggerAreaPoolRegistry!, mainPlayerAvatarBaseProxy, sharedDependencies.SceneStateProvider, characterObject); - finalizeWorldSystems.Add(AvatarModifierAreaHandlerSystem.InjectToWorld(ref builder, globalWorld)); - finalizeWorldSystems.Add(CameraModeAreaHandlerSystem.InjectToWorld(ref builder, globalWorld, cameraEntityProxy, cameraData)); + finalizeWorldSystems.Add(AvatarModifierAreaHandlerSystem.InjectToWorld(ref builder, globalWorld, sceneRestrictionBusController, web3IdentityCache)); + finalizeWorldSystems.Add(CameraModeAreaHandlerSystem.InjectToWorld(ref builder, globalWorld, cameraEntityProxy, cameraData, sceneRestrictionBusController)); finalizeWorldSystems.Add(CharacterTriggerAreaCleanupSystem.InjectToWorld(ref builder, characterTriggerAreaPoolRegistry!)); } diff --git a/Explorer/Assets/DCL/PluginSystem/World/InputModifierPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/InputModifierPlugin.cs index 53b35ccd07..0a065d673d 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/InputModifierPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/InputModifierPlugin.cs @@ -3,6 +3,7 @@ using Cysharp.Threading.Tasks; using DCL.ECSComponents; using DCL.PluginSystem.World.Dependencies; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.SDKComponents.PlayerInputMovement.Systems; using ECS.LifeCycle; using ECS.LifeCycle.Systems; @@ -15,11 +16,13 @@ public class InputModifierPlugin: IDCLWorldPlugin { private readonly Arch.Core.World world; private readonly Entity playerEntity; + private readonly ISceneRestrictionBusController sceneRestrictionBusController; - public InputModifierPlugin(Arch.Core.World world, Entity playerEntity) + public InputModifierPlugin(Arch.Core.World world, Entity playerEntity, ISceneRestrictionBusController sceneRestrictionBusController) { this.world = world; this.playerEntity = playerEntity; + this.sceneRestrictionBusController = sceneRestrictionBusController; } public void Dispose() @@ -33,7 +36,7 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in PersistentEntities persistentEntities, List finalizeWorldSystems, List sceneIsCurrentListeners) { ResetDirtyFlagSystem.InjectToWorld(ref builder); - var system = InputModifierHandlerSystem.InjectToWorld(ref builder, world, playerEntity, sharedDependencies.SceneStateProvider); + var system = InputModifierHandlerSystem.InjectToWorld(ref builder, world, playerEntity, sharedDependencies.SceneStateProvider, sceneRestrictionBusController); sceneIsCurrentListeners.Add(system); finalizeWorldSystems.Add(system); } diff --git a/Explorer/Assets/DCL/PluginSystem/World/MainCameraPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/MainCameraPlugin.cs index 3eb0d0c62e..98bb88ad44 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/MainCameraPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/MainCameraPlugin.cs @@ -6,6 +6,7 @@ using DCL.Optimization.Pools; using DCL.PluginSystem.World.Dependencies; using DCL.ResourcesUnloading; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.SDKComponents.CameraControl.MainCamera.Systems; using ECS.LifeCycle; using System; @@ -34,12 +35,14 @@ public class Settings : IDCLPluginSettings private readonly IExposedCameraData cameraData; private readonly Arch.Core.World globalWorld; private IComponentPool? virtualCameraPoolRegistry; + private readonly ISceneRestrictionBusController sceneRestrictionBusController; public MainCameraPlugin( IComponentPoolsRegistry poolsRegistry, IAssetsProvisioner assetsProvisioner, CacheCleaner cacheCleaner, IExposedCameraData cameraData, + ISceneRestrictionBusController sceneRestrictionBusController, Arch.Core.World globalWorld) { this.assetsProvisioner = assetsProvisioner; @@ -47,6 +50,7 @@ public MainCameraPlugin( this.cacheCleaner = cacheCleaner; this.cameraData = cameraData; this.globalWorld = globalWorld; + this.sceneRestrictionBusController = sceneRestrictionBusController; } public async UniTask InitializeAsync(Settings settings, CancellationToken ct) @@ -79,6 +83,7 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder builder, sharedDependencies.EntitiesMap, sharedDependencies.SceneStateProvider, cameraData, + sceneRestrictionBusController, globalWorld)); } diff --git a/Explorer/Assets/DCL/SDKComponents/AvatarModifierArea/Systems/AvatarModifierAreaHandlerSystem.cs b/Explorer/Assets/DCL/SDKComponents/AvatarModifierArea/Systems/AvatarModifierAreaHandlerSystem.cs index da37bb8877..4dfa66f51b 100644 --- a/Explorer/Assets/DCL/SDKComponents/AvatarModifierArea/Systems/AvatarModifierAreaHandlerSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/AvatarModifierArea/Systems/AvatarModifierAreaHandlerSystem.cs @@ -3,12 +3,15 @@ using Arch.SystemGroups; using DCL.AvatarRendering.AvatarShape.Components; using DCL.AvatarRendering.AvatarShape.UnityInterface; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.CharacterTriggerArea.Components; using DCL.Diagnostics; using DCL.ECSComponents; using DCL.Multiplayer.Connections.Typing; using DCL.Profiles; +using DCL.SceneRestrictionBusController.SceneRestriction; using DCL.SDKComponents.AvatarModifierArea.Components; +using DCL.Web3.Identities; using ECS.Abstract; using ECS.Groups; using ECS.LifeCycle; @@ -26,11 +29,16 @@ public partial class AvatarModifierAreaHandlerSystem : BaseUnityLoopSystem, IFin private static readonly QueryDescription AVATAR_BASE_QUERY = new QueryDescription().WithAll(); private readonly World globalWorld; private readonly FindAvatarQuery findAvatarQuery; + private readonly ISceneRestrictionBusController sceneRestrictionBusController; + private readonly IWeb3IdentityCache web3IdentityCache; + private Transform? localAvatarTransform; - public AvatarModifierAreaHandlerSystem(World world, World globalWorld) : base(world) + public AvatarModifierAreaHandlerSystem(World world, World globalWorld, ISceneRestrictionBusController sceneRestrictionBusController, IWeb3IdentityCache web3IdentityCache) : base(world) { this.globalWorld = globalWorld; findAvatarQuery = new FindAvatarQuery(globalWorld); + this.sceneRestrictionBusController = sceneRestrictionBusController; + this.web3IdentityCache = web3IdentityCache; } protected override void Update(float t) @@ -106,7 +114,7 @@ private void HandleEntityDestruction(ref CharacterTriggerAreaComponent triggerAr [Query] [None(typeof(DeleteEntityIntention), typeof(PBAvatarModifierArea))] - private void HandleComponentRemoval(Entity e, ref CharacterTriggerAreaComponent triggerAreaComponent, ref AvatarModifierAreaComponent modifierComponent) + private void HandleComponentRemoval(in Entity entity, ref CharacterTriggerAreaComponent triggerAreaComponent, ref AvatarModifierAreaComponent modifierComponent) { // Reset state of affected entities foreach (Transform avatarTransform in triggerAreaComponent.CurrentAvatarsInside) @@ -114,7 +122,7 @@ private void HandleComponentRemoval(Entity e, ref CharacterTriggerAreaComponent modifierComponent.Dispose(); - World!.Remove(e); + World!.Remove(entity); } private void ShowAvatar(Transform avatarTransform) @@ -128,6 +136,11 @@ private void ShowAvatar(Transform avatarTransform) if (!hasAvatarShape) return; avatarShape.HiddenByModifierArea = false; + if (avatarTransform == localAvatarTransform) + { + localAvatarTransform = null; + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateAvatarHidden(SceneRestrictionsAction.REMOVED)); + } } private void HideAvatar(Transform avatarTransform, HashSet excludedIds) @@ -144,6 +157,12 @@ private void HideAvatar(Transform avatarTransform, HashSet excludedIds) bool shouldHide = !excludedIds.Contains(profile!.UserId); avatarShape.HiddenByModifierArea = shouldHide; + + if (shouldHide && profile.UserId == web3IdentityCache.Identity?.Address) + { + localAvatarTransform = avatarTransform; + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateAvatarHidden(SceneRestrictionsAction.APPLIED)); + } } private class FindAvatarQuery diff --git a/Explorer/Assets/DCL/SDKComponents/AvatarModifierArea/Tests/AvatarModifierAreaHandlerSystemShould.cs b/Explorer/Assets/DCL/SDKComponents/AvatarModifierArea/Tests/AvatarModifierAreaHandlerSystemShould.cs index 6b5d4c0df3..a5768f35f8 100644 --- a/Explorer/Assets/DCL/SDKComponents/AvatarModifierArea/Tests/AvatarModifierAreaHandlerSystemShould.cs +++ b/Explorer/Assets/DCL/SDKComponents/AvatarModifierArea/Tests/AvatarModifierAreaHandlerSystemShould.cs @@ -6,12 +6,15 @@ using DCL.CharacterTriggerArea.Components; using DCL.ECSComponents; using DCL.Profiles; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.SDKComponents.AvatarModifierArea.Components; using DCL.SDKComponents.AvatarModifierArea.Systems; +using DCL.Web3.Identities; using ECS.LifeCycle.Components; using ECS.Prioritization.Components; using ECS.TestSuite; using ECS.Unity.Transforms.Components; +using NSubstitute; using NUnit.Framework; using System.Collections.Generic; using UnityEngine; @@ -37,7 +40,7 @@ public class AvatarModifierAreaHandlerSystemShould : UnitySystemTestBase(), Substitute.For()); fakeTriggerAreaGO = new GameObject("fake character area trigger"); characterTriggerArea = fakeTriggerAreaGO.AddComponent(); diff --git a/Explorer/Assets/DCL/SDKComponents/CameraControl/CameraModeArea/Systems/CameraModeAreaHandlerSystem.cs b/Explorer/Assets/DCL/SDKComponents/CameraControl/CameraModeArea/Systems/CameraModeAreaHandlerSystem.cs index 95f639d269..212cfbcb50 100644 --- a/Explorer/Assets/DCL/SDKComponents/CameraControl/CameraModeArea/Systems/CameraModeAreaHandlerSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/CameraControl/CameraModeArea/Systems/CameraModeAreaHandlerSystem.cs @@ -5,7 +5,9 @@ using DCL.CharacterTriggerArea.Components; using DCL.Diagnostics; using DCL.ECSComponents; +using DCL.SceneRestrictionBusController.SceneRestriction; using DCL.SDKComponents.CameraModeArea.Components; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.Utilities; using ECS.Abstract; using ECS.Groups; @@ -32,12 +34,14 @@ public partial class CameraModeAreaHandlerSystem : BaseUnityLoopSystem, IFinaliz private readonly World globalWorld; private readonly ObjectProxy cameraEntityProxy; private readonly IExposedCameraData cameraData; + private readonly ISceneRestrictionBusController sceneRestrictionBusController; - public CameraModeAreaHandlerSystem(World world, World globalWorld, ObjectProxy cameraEntityProxy, IExposedCameraData cameraData) : base(world) + public CameraModeAreaHandlerSystem(World world, World globalWorld, ObjectProxy cameraEntityProxy, IExposedCameraData cameraData, ISceneRestrictionBusController sceneRestrictionBusController) : base(world) { this.globalWorld = globalWorld; this.cameraEntityProxy = cameraEntityProxy; this.cameraData = cameraData; + this.sceneRestrictionBusController = sceneRestrictionBusController; } protected override void Update(float t) @@ -113,6 +117,8 @@ internal void OnEnteredCameraModeArea(CameraMode targetCameraMode) cameraModeBeforeLastAreaEnter = camera.Mode; camera.Mode = targetCameraMode; camera.AddCameraInputLock(); + + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.APPLIED)); } internal void OnExitedCameraModeArea() @@ -124,6 +130,8 @@ internal void OnExitedCameraModeArea() // If there are more locks then there is another newer camera mode area in place if (camera.CameraInputChangeEnabled) camera.Mode = cameraModeBeforeLastAreaEnter; + + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.REMOVED)); } [Query] diff --git a/Explorer/Assets/DCL/SDKComponents/CameraControl/CameraModeArea/Tests/CameraModeAreaHandlerSystemShould.cs b/Explorer/Assets/DCL/SDKComponents/CameraControl/CameraModeArea/Tests/CameraModeAreaHandlerSystemShould.cs index af60b53951..e1a7f94566 100644 --- a/Explorer/Assets/DCL/SDKComponents/CameraControl/CameraModeArea/Tests/CameraModeAreaHandlerSystemShould.cs +++ b/Explorer/Assets/DCL/SDKComponents/CameraControl/CameraModeArea/Tests/CameraModeAreaHandlerSystemShould.cs @@ -4,6 +4,7 @@ using DCL.CharacterCamera; using DCL.CharacterTriggerArea.Components; using DCL.ECSComponents; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.SDKComponents.CameraModeArea.Components; using DCL.SDKComponents.CameraModeArea.Systems; using DCL.Utilities; @@ -35,7 +36,7 @@ public void Setup() var cameraEntityProxy = new ObjectProxy(); cameraEntityProxy.SetObject(cameraEntity); - system = new CameraModeAreaHandlerSystem(world, globalWorld, cameraEntityProxy, Substitute.For()); + system = new CameraModeAreaHandlerSystem(world, globalWorld, cameraEntityProxy, Substitute.For(), Substitute.For()); entity = world.Create(PartitionComponent.TOP_PRIORITY); AddTransformToEntity(entity); diff --git a/Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Systems/MainCameraSystem.cs b/Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Systems/MainCameraSystem.cs index 4d3112d517..8218cd153b 100644 --- a/Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Systems/MainCameraSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Systems/MainCameraSystem.cs @@ -6,6 +6,8 @@ using CRDT; using DCL.CharacterCamera; using DCL.ECSComponents; +using DCL.SceneRestrictionBusController.SceneRestriction; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.SDKComponents.CameraControl.MainCamera.Components; using DCL.SDKComponents.CameraModeArea.Systems; using ECS.Abstract; @@ -26,6 +28,7 @@ public partial class MainCameraSystem : BaseUnityLoopSystem, IFinalizeWorldSyste private readonly Entity cameraEntity; private readonly ISceneStateProvider sceneStateProvider; private readonly IExposedCameraData cameraData; + private readonly ISceneRestrictionBusController sceneRestrictionBusController; private readonly World globalWorld; private CameraMode lastNonSDKCameraMode; @@ -35,6 +38,7 @@ public MainCameraSystem( Dictionary entitiesMap, ISceneStateProvider sceneStateProvider, IExposedCameraData cameraData, + ISceneRestrictionBusController sceneRestrictionBusController, World globalWorld) : base(world) { this.cameraEntity = cameraEntity; @@ -42,6 +46,7 @@ public MainCameraSystem( this.sceneStateProvider = sceneStateProvider; this.cameraData = cameraData; this.globalWorld = globalWorld; + this.sceneRestrictionBusController = sceneRestrictionBusController; } protected override void Update(float t) @@ -84,6 +89,7 @@ private void HandleVirtualCameraChange(Entity entity, ref MainCameraComponent ma virtualCameraCRDTEntity.Value, hasPreviousVirtualCamera ? previousVirtualCamera!.transform.position : cinemachineCurrentActiveCamPos ); + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.APPLIED)); } else { @@ -91,7 +97,10 @@ private void HandleVirtualCameraChange(Entity entity, ref MainCameraComponent ma } if (hasPreviousVirtualCamera) + { previousVirtualCamera!.enabled = false; + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.REMOVED)); + } UpdateGlobalWorldCameraMode(mainCameraComponent.virtualCameraInstance != null); } @@ -147,6 +156,7 @@ private void HandleMainCameraEntityDestruction(in MainCameraComponent component) private void FinalizeMainCameraComponent(in MainCameraComponent mainCameraComponent) { DisableActiveVirtualCamera(mainCameraComponent); + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateCameraLocked(SceneRestrictionsAction.REMOVED)); } public void FinalizeComponents(in Query query) diff --git a/Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Tests/EditMode/MainCameraSystemShould.cs b/Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Tests/EditMode/MainCameraSystemShould.cs index dfb95f6f18..76e76c8d19 100644 --- a/Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Tests/EditMode/MainCameraSystemShould.cs +++ b/Explorer/Assets/DCL/SDKComponents/CameraControl/MainCamera/Tests/EditMode/MainCameraSystemShould.cs @@ -4,6 +4,7 @@ using CrdtEcsBridge.Components; using DCL.CharacterCamera; using DCL.ECSComponents; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.SDKComponents.CameraControl.MainCamera.Components; using DCL.SDKComponents.CameraControl.MainCamera.Systems; using DCL.Utilities; @@ -92,7 +93,7 @@ public void Setup() cameraData.CinemachineBrain.Returns(cinemachineBrain); cameraData.CameraEntityProxy.Returns(cameraEntityProxy); - system = new MainCameraSystem(world, mainCameraEntity, entitiesMap, sceneStateProvider, cameraData, globalWorld); + system = new MainCameraSystem(world, mainCameraEntity, entitiesMap, sceneStateProvider, cameraData, Substitute.For(), globalWorld); } [TearDown] diff --git a/Explorer/Assets/DCL/SDKComponents/DCL.SDKComponents.asmdef b/Explorer/Assets/DCL/SDKComponents/DCL.SDKComponents.asmdef index d3187abfc4..0b2da7d7f9 100644 --- a/Explorer/Assets/DCL/SDKComponents/DCL.SDKComponents.asmdef +++ b/Explorer/Assets/DCL/SDKComponents/DCL.SDKComponents.asmdef @@ -23,7 +23,10 @@ "GUID:e25ef972de004615a22937e739de2def", "GUID:702f733b4deb246808c6ce84d93b5c9c", "GUID:7175400a68914a45acecc9fb068de3b8", - "GUID:f51ebe6a0ceec4240a699833d6309b23" + "GUID:f51ebe6a0ceec4240a699833d6309b23", + "GUID:1300820cd310d4584b09afde765bdd16", + "GUID:5ab29fa8ae5769b49ab29e390caca7a4", + "GUID:ca4e81cdd6a34d1aa54c32ad41fc5b3b" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Explorer/Assets/DCL/SDKComponents/InputModifier/Systems/InputModifierHandlerSystem.cs b/Explorer/Assets/DCL/SDKComponents/InputModifier/Systems/InputModifierHandlerSystem.cs index 2cacf36378..a94fbcc2f4 100644 --- a/Explorer/Assets/DCL/SDKComponents/InputModifier/Systems/InputModifierHandlerSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/InputModifier/Systems/InputModifierHandlerSystem.cs @@ -2,6 +2,8 @@ using Arch.System; using Arch.SystemGroups; using DCL.ECSComponents; +using DCL.SceneRestrictionBusController.SceneRestriction; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.SDKComponents.InputModifier.Components; using ECS.Abstract; using ECS.Groups; @@ -16,12 +18,16 @@ public partial class InputModifierHandlerSystem : BaseUnityLoopSystem, ISceneIsC private readonly Entity playerEntity; private readonly World globalWorld; private readonly ISceneStateProvider sceneStateProvider; + private readonly ISceneRestrictionBusController sceneRestrictionBusController; - public InputModifierHandlerSystem(World world, World globalWorld, Entity playerEntity, ISceneStateProvider sceneStateProvider) : base(world) + private SceneRestrictionsAction lastBusMessageAction = SceneRestrictionsAction.REMOVED; + + public InputModifierHandlerSystem(World world, World globalWorld, Entity playerEntity, ISceneStateProvider sceneStateProvider, ISceneRestrictionBusController sceneRestrictionBusController) : base(world) { this.playerEntity = playerEntity; this.sceneStateProvider = sceneStateProvider; this.globalWorld = globalWorld; + this.sceneRestrictionBusController = sceneRestrictionBusController; } protected override void Update(float t) @@ -29,6 +35,16 @@ protected override void Update(float t) ApplyModifiersQuery(World); } + private void SendBusMessage(InputModifierComponent inputModifier) + { + SceneRestrictionsAction currentAction = inputModifier is { DisableAll: false, DisableWalk: false, DisableJog: false, DisableRun: false, DisableJump: false, DisableEmote: false } ? SceneRestrictionsAction.REMOVED : SceneRestrictionsAction.APPLIED; + + if (currentAction == lastBusMessageAction) return; + + sceneRestrictionBusController.PushSceneRestriction(SceneRestriction.CreateAvatarMovementsBlocked(currentAction)); + lastBusMessageAction = currentAction; + } + private void ResetModifiersOnLeave() { ref InputModifierComponent inputModifier = ref globalWorld.Get(playerEntity); @@ -38,6 +54,8 @@ private void ResetModifiersOnLeave() inputModifier.DisableRun = false; inputModifier.DisableJump = false; inputModifier.DisableEmote = false; + + SendBusMessage(inputModifier); } [Query] @@ -46,6 +64,8 @@ private void ApplyModifiers(in PBInputModifier pbInputModifier) if (!sceneStateProvider.IsCurrent) return; if(pbInputModifier.ModeCase == PBInputModifier.ModeOneofCase.None) return; + if (!pbInputModifier.IsDirty) return; + ref var inputModifier = ref globalWorld.Get(playerEntity); PBInputModifier.Types.StandardInput? pb = pbInputModifier.Standard; @@ -60,6 +80,8 @@ private void ApplyModifiers(in PBInputModifier pbInputModifier) inputModifier.DisableJump = pb.DisableJump; inputModifier.DisableEmote = pb.DisableEmote; } + + SendBusMessage(inputModifier); } public void OnSceneIsCurrentChanged(bool value) diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController.meta b/Explorer/Assets/DCL/SceneRestrictionBusController.meta new file mode 100644 index 0000000000..192dafed95 --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 287643ce1737e4b10bcf516e74e6d7d9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction.meta b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction.meta new file mode 100644 index 0000000000..96ce4d3311 --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ae8334fae51542a19db06dad199da58a +timeCreated: 1729159243 \ No newline at end of file diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets.meta b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets.meta new file mode 100644 index 0000000000..7e56f1998e --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c0ede8be0451d4683b879f57aac29885 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets/SceneRestrictionsToast.prefab b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets/SceneRestrictionsToast.prefab new file mode 100644 index 0000000000..0dd1e8ece3 --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets/SceneRestrictionsToast.prefab @@ -0,0 +1,475 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2680132346790437763 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 684450512256360453} + - component: {fileID: 9156791859951390335} + - component: {fileID: 7391636652124656314} + - component: {fileID: 8769766311802082231} + - component: {fileID: 3361352168504223168} + m_Layer: 5 + m_Name: VerticalLayoutGroup + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &684450512256360453 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2680132346790437763} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7434166619040309165} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 137.99707, y: -58} + m_SizeDelta: {x: 276, y: 0} + m_Pivot: {x: 0.5, y: 1} +--- !u!114 &9156791859951390335 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2680132346790437763} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 14 + m_Bottom: 14 + m_ChildAlignment: 1 + m_Spacing: 1 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 0 + m_ChildControlWidth: 0 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 + m_ReverseArrangement: 0 +--- !u!222 &7391636652124656314 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2680132346790437763} + m_CullTransparentMesh: 1 +--- !u!114 &8769766311802082231 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2680132346790437763} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.08627451, g: 0.08235294, b: 0.09411765, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 6a691ff28b59f4236a6a8d3b7f4aa258, type: 3} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 2 +--- !u!114 &3361352168504223168 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2680132346790437763} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalFit: 0 + m_VerticalFit: 2 +--- !u!1 &3247906196772821027 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 455637641516174093} + - component: {fileID: 8374687070976786852} + - component: {fileID: 2605273860976138218} + m_Layer: 5 + m_Name: Title + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &455637641516174093 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3247906196772821027} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1159939997348515854} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 219, y: 34} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8374687070976786852 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3247906196772821027} + m_CullTransparentMesh: 1 +--- !u!114 &2605273860976138218 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3247906196772821027} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: This scene is restricting the use of some features + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 96ae0a2159a39234f858ea23bdcc74ad, type: 2} + m_sharedMaterial: {fileID: 735423033564544980, guid: 96ae0a2159a39234f858ea23bdcc74ad, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4279739134 + m_fontColor: {r: 0.99607843, g: 0.63529414, b: 0.09019608, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 14 + m_fontSizeBase: 14 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_TextWrappingMode: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 0 + m_ActiveFontFeatures: 6e72656b + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_EmojiFallbackSupport: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!1 &3905604814641488115 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1159939997348515854} + - component: {fileID: 1519343156901108001} + - component: {fileID: 7418174050770848779} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1159939997348515854 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3905604814641488115} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 913407909056274034} + - {fileID: 455637641516174093} + m_Father: {fileID: 7434166619040309165} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 138, y: -29} + m_SizeDelta: {x: 276, y: 58} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &1519343156901108001 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3905604814641488115} + m_CullTransparentMesh: 1 +--- !u!114 &7418174050770848779 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3905604814641488115} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 0777b27ffb579410cbb9d7bd29774538, type: 3} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 2 +--- !u!1 &4966924927682336045 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7434166619040309165} + - component: {fileID: 7671181397625112573} + - component: {fileID: 4631154171231165118} + m_Layer: 5 + m_Name: SceneRestrictionsToast + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7434166619040309165 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4966924927682336045} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1159939997348515854} + - {fileID: 684450512256360453} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 56, y: 100.7} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &7671181397625112573 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4966924927682336045} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bafe95e137294f21a295a8d5abb600bd, type: 3} + m_Name: + m_EditorClassIdentifier: + k__BackingField: {fileID: 0} + k__BackingField: {fileID: 7173452363831430961, guid: 0f5931afe9f9444518eb3629d8086e3f, type: 3} + k__BackingField: {fileID: 4631154171231165118} + k__BackingField: {fileID: 2680132346790437763} + k__BackingField: 0.3 +--- !u!225 &4631154171231165118 +CanvasGroup: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4966924927682336045} + m_Enabled: 1 + m_Alpha: 0 + m_Interactable: 0 + m_BlocksRaycasts: 1 + m_IgnoreParentGroups: 0 +--- !u!1 &8218898394440155128 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 913407909056274034} + - component: {fileID: 9021678001228509555} + - component: {fileID: 3440684703357633740} + m_Layer: 5 + m_Name: Peak + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &913407909056274034 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8218898394440155128} + m_LocalRotation: {x: -0, y: -0, z: -0.7071068, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.24000001, y: 0.1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1159939997348515854} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -142.90002, y: -2.9} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &9021678001228509555 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8218898394440155128} + m_CullTransparentMesh: 1 +--- !u!114 &3440684703357633740 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8218898394440155128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 91a92410d7b9c497b90aa66f9a5569ec, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets/SceneRestrictionsToast.prefab.meta b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets/SceneRestrictionsToast.prefab.meta new file mode 100644 index 0000000000..9c6233aeca --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/Assets/SceneRestrictionsToast.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ce62870d41fed4cd7a4116ce6791c410 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/SceneRestriction.cs b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/SceneRestriction.cs new file mode 100644 index 0000000000..2309a1e8e6 --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/SceneRestriction.cs @@ -0,0 +1,58 @@ +namespace DCL.SceneRestrictionBusController.SceneRestriction +{ + public struct SceneRestriction + { + public SceneRestrictions Type { get; set; } + public SceneRestrictionsAction Action { get; set; } + + public static SceneRestriction CreateCameraLocked(SceneRestrictionsAction action) => + new() + { + Type = SceneRestrictions.CAMERA_LOCKED, + Action = action + }; + + public static SceneRestriction CreateAvatarHidden(SceneRestrictionsAction action) => + new() + { + Type = SceneRestrictions.AVATAR_HIDDEN, + Action = action + }; + + public static SceneRestriction CreateAvatarMovementsBlocked(SceneRestrictionsAction action) => + new() + { + Type = SceneRestrictions.AVATAR_MOVEMENTS_BLOCKED, + Action = action + }; + + public static SceneRestriction CreatePassportCannotBeOpened(SceneRestrictionsAction action) => + new() + { + Type = SceneRestrictions.PASSPORT_CANNOT_BE_OPENED, + Action = action + }; + + public static SceneRestriction CreateExperiencesBlocked(SceneRestrictionsAction action) => + new() + { + Type = SceneRestrictions.EXPERIENCES_BLOCKED, + Action = action + }; + } + + public enum SceneRestrictions + { + CAMERA_LOCKED, + AVATAR_HIDDEN, + AVATAR_MOVEMENTS_BLOCKED, + PASSPORT_CANNOT_BE_OPENED, + EXPERIENCES_BLOCKED, + } + + public enum SceneRestrictionsAction + { + APPLIED, + REMOVED, + } +} diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/SceneRestriction.cs.meta b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/SceneRestriction.cs.meta new file mode 100644 index 0000000000..ece17856bd --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestriction/SceneRestriction.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f32de7e268f841b585dbfa5ecca587c8 +timeCreated: 1730363074 \ No newline at end of file diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.asmdef b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.asmdef new file mode 100644 index 0000000000..59917e45af --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.asmdef @@ -0,0 +1,14 @@ +{ + "name": "SceneRestrictionsBus", + "rootNamespace": "", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.asmdef.meta b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.asmdef.meta new file mode 100644 index 0000000000..98be7a7125 --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1300820cd310d4584b09afde765bdd16 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.meta b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.meta new file mode 100644 index 0000000000..628c58e1dd --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ea6d7473412344f596550f605d09b67c +timeCreated: 1729159158 \ No newline at end of file diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/ISceneRestrictionBusController.cs b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/ISceneRestrictionBusController.cs new file mode 100644 index 0000000000..9136e981e2 --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/ISceneRestrictionBusController.cs @@ -0,0 +1,9 @@ + +namespace DCL.SceneRestrictionBusController.SceneRestrictionBus +{ + public interface ISceneRestrictionBusController + { + void PushSceneRestriction(SceneRestriction.SceneRestriction sceneRestriction); + void SubscribeToSceneRestriction(SceneRestrictionBusController.SceneRestrictionReceivedDelegate callback); + } +} diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/ISceneRestrictionBusController.cs.meta b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/ISceneRestrictionBusController.cs.meta new file mode 100644 index 0000000000..4f64c070a6 --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/ISceneRestrictionBusController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c870c364c81a46f7a2b688e283574e1c +timeCreated: 1729159188 \ No newline at end of file diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/SceneRestrictionBusController.cs b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/SceneRestrictionBusController.cs new file mode 100644 index 0000000000..9cb209d0f2 --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/SceneRestrictionBusController.cs @@ -0,0 +1,16 @@ + +namespace DCL.SceneRestrictionBusController.SceneRestrictionBus +{ + public class SceneRestrictionBusController : ISceneRestrictionBusController + { + public delegate void SceneRestrictionReceivedDelegate(SceneRestriction.SceneRestriction sceneRestriction); + + private SceneRestrictionReceivedDelegate sceneRestrictionReceivedDelegate; + + public void PushSceneRestriction(SceneRestriction.SceneRestriction sceneRestriction) => + sceneRestrictionReceivedDelegate?.Invoke(sceneRestriction); + + public void SubscribeToSceneRestriction(SceneRestrictionReceivedDelegate callback) => + sceneRestrictionReceivedDelegate += callback; + } +} diff --git a/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/SceneRestrictionBusController.cs.meta b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/SceneRestrictionBusController.cs.meta new file mode 100644 index 0000000000..0ff250bc1b --- /dev/null +++ b/Explorer/Assets/DCL/SceneRestrictionBusController/SceneRestrictionBus/SceneRestrictionBusController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5e14d2507b2944258aa248055ab647bf +timeCreated: 1729160552 \ No newline at end of file diff --git a/Explorer/Assets/DCL/Tests/Editor/DCL.EditMode.Tests.asmdef b/Explorer/Assets/DCL/Tests/Editor/DCL.EditMode.Tests.asmdef index eb6e9399e8..ce1c4d8fe6 100644 --- a/Explorer/Assets/DCL/Tests/Editor/DCL.EditMode.Tests.asmdef +++ b/Explorer/Assets/DCL/Tests/Editor/DCL.EditMode.Tests.asmdef @@ -71,7 +71,9 @@ "GUID:78cc93eb55f63084db95d7a9b7cc3c57", "GUID:f4a0f40a2545482b8929d4c3c642f50a", "GUID:21c2e77c042a2d34d8cfbf58f8217053", - "GUID:b46779583a009f04ba9f5f31d0e7e6ac" + "GUID:b46779583a009f04ba9f5f31d0e7e6ac", + "GUID:1300820cd310d4584b09afde765bdd16", + "GUID:a7b31707bb5e04b20bfe1421647e6707" ], "includePlatforms": [ "Editor" diff --git a/Explorer/Assets/DCL/Tests/PlayMode/DCL.PlayMode.Tests.asmdef b/Explorer/Assets/DCL/Tests/PlayMode/DCL.PlayMode.Tests.asmdef index e006d8ec64..ef4bce30d4 100644 --- a/Explorer/Assets/DCL/Tests/PlayMode/DCL.PlayMode.Tests.asmdef +++ b/Explorer/Assets/DCL/Tests/PlayMode/DCL.PlayMode.Tests.asmdef @@ -66,6 +66,7 @@ "GUID:ca4e81cdd6a34d1aa54c32ad41fc5b3b", "GUID:f4a0f40a2545482b8929d4c3c642f50a", "GUID:1d75b3d8691c845b1a51082e81433dfc", + "GUID:1300820cd310d4584b09afde765bdd16", "GUID:d28a7e4beeca475418c15757abf1b6f1" ], "includePlatforms": [], diff --git a/Explorer/Assets/DCL/UI/MainUIContainer/MainUIContainer.prefab b/Explorer/Assets/DCL/UI/MainUIContainer/MainUIContainer.prefab index c78dbc4522..9fd9e5ff23 100644 --- a/Explorer/Assets/DCL/UI/MainUIContainer/MainUIContainer.prefab +++ b/Explorer/Assets/DCL/UI/MainUIContainer/MainUIContainer.prefab @@ -1784,6 +1784,26 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 1087183099738520250, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1087183099738520250, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1087183099738520250, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1087183099738520250, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1087183099738520250, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2377257890637130518, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -1808,6 +1828,58 @@ PrefabInstance: propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} + - target: {fileID: 2549752290301589492, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2549752290301589492, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2549752290301589492, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2549752290301589492, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2616731610518440135, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2616731610518440135, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2616731610518440135, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2616731610518440135, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2730229354344199221, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2730229354344199221, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2730229354344199221, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_SizeDelta.y + value: 20 + objectReference: {fileID: 0} + - target: {fileID: 2730229354344199221, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2730229354344199221, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 3721001069623505348, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} propertyPath: m_Pivot.x value: 0 @@ -1888,6 +1960,46 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 3994911733430335365, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5037157834932558718, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5037157834932558718, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5037157834932558718, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5037157834932558718, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5647564073185826373, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5647564073185826373, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5647564073185826373, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5647564073185826373, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5647564073185826373, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 5846655602745955872, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} propertyPath: m_OverrideSorting value: 0 @@ -1896,6 +2008,54 @@ PrefabInstance: propertyPath: m_VertexColorAlwaysGammaSpace value: 1 objectReference: {fileID: 0} + - target: {fileID: 6087439276851581053, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: k__BackingField + value: + objectReference: {fileID: 7037425886153711862} + - target: {fileID: 8925690281373403926, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8925690281373403926, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8925690281373403926, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8925690281373403926, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8925690281373403926, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8925690281373403926, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8925690281373403926, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8988185207445522830, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8988185207445522830, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8988185207445522830, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8988185207445522830, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 9152785347356188261, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} propertyPath: m_Name value: Minimap @@ -1925,6 +2085,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f38b33006c1e47c191dab3acdcc972df, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!224 &7037425886153711862 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 5647564073185826373, guid: f2ef3a867ab2840cb9bc73b4762922fd, type: 3} + m_PrefabInstance: {fileID: 3443520972679509683} + m_PrefabAsset: {fileID: 0} --- !u!1001 &8223576145474373599 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Explorer/Assets/Scripts/Global/Dynamic/Bootstraper.cs b/Explorer/Assets/Scripts/Global/Dynamic/Bootstraper.cs index 8bba2ff8c9..8e2308259c 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/Bootstraper.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/Bootstraper.cs @@ -16,7 +16,6 @@ using DCL.UserInAppInitializationFlow; using DCL.Utilities.Extensions; using DCL.Web3.Identities; -using ECS.Abstract; using Global.AppArgs; using Global.Dynamic.DebugSettings; using MVC; @@ -76,8 +75,7 @@ public void PreInitializeSetup(UIDocument cursorRoot, public async UniTask<(StaticContainer?, bool)> LoadStaticContainerAsync(BootstrapContainer bootstrapContainer, PluginSettingsContainer globalPluginSettingsContainer, DebugViewsCatalog debugViewsCatalog, Entity playerEntity, ISystemMemoryCap memoryCap, CancellationToken ct) => await StaticContainer.CreateAsync(bootstrapContainer.DecentralandUrlsSource, bootstrapContainer.AssetsProvisioner, bootstrapContainer.ReportHandlingSettings, appArgs, debugViewsCatalog, globalPluginSettingsContainer, - bootstrapContainer.DiagnosticsContainer, bootstrapContainer.IdentityCache, bootstrapContainer.VerifiedEthereumApi, bootstrapContainer.LocalSceneDevelopment, bootstrapContainer.UseRemoteAssetBundles, world, playerEntity, memoryCap, bootstrapContainer.WorldVolumeMacBus, - EnableAnalytics, bootstrapContainer.Analytics, ct); + bootstrapContainer.DiagnosticsContainer, bootstrapContainer.IdentityCache, bootstrapContainer.VerifiedEthereumApi, bootstrapContainer.LocalSceneDevelopment, bootstrapContainer.UseRemoteAssetBundles, world, playerEntity, memoryCap, bootstrapContainer.WorldVolumeMacBus, EnableAnalytics, bootstrapContainer.Analytics, ct); public async UniTask<(DynamicWorldContainer?, bool)> LoadDynamicWorldContainerAsync(BootstrapContainer bootstrapContainer, StaticContainer staticContainer, @@ -130,6 +128,7 @@ await StaticContainer.CreateAsync(bootstrapContainer.DecentralandUrlsSource, boo world, playerEntity, appArgs, + staticContainer.SceneRestrictionBusController, staticContainer.LoadingStatus, ct); } diff --git a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs index d7cd4c9b22..d06d05981e 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs @@ -56,6 +56,7 @@ using DCL.Profiles; using DCL.Profiles.Self; using DCL.SceneLoadingScreens.LoadingScreen; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.Settings; using DCL.SidebarBus; using DCL.UI.MainUI; @@ -139,7 +140,6 @@ public class DynamicWorldContainer : DCLWorldContainer private MultiplayerMovementMessageBus? multiplayerMovementMessageBus; - public override void Dispose() { ChatMessagesBus.Dispose(); @@ -157,6 +157,7 @@ public override void Dispose() World globalWorld, Entity playerEntity, IAppArgs appArgs, + ISceneRestrictionBusController sceneRestrictionBusController, ILoadingStatus loadingStatus, CancellationToken ct) { @@ -519,7 +520,7 @@ IMultiPool MultiPoolFactory() => globalWorld, playerEntity), new ErrorPopupPlugin(container.MvcManager, assetsProvisioner), connectionStatusPanelPlugin, - new MinimapPlugin(container.MvcManager, container.MapRendererContainer, placesAPIService, staticContainer.RealmData, container.ChatMessagesBus, realmNavigator, staticContainer.ScenesCache, mainUIView, mapPathEventBus), + new MinimapPlugin(container.MvcManager, container.MapRendererContainer, placesAPIService, staticContainer.RealmData, container.ChatMessagesBus, realmNavigator, staticContainer.ScenesCache, mainUIView, mapPathEventBus, sceneRestrictionBusController), new ChatPlugin(assetsProvisioner, container.MvcManager, container.ChatMessagesBus, chatHistory, entityParticipantTable, nametagsData, dclInput, unityEventSystem, mainUIView, staticContainer.InputBlock, globalWorld, playerEntity), new ExplorePanelPlugin( assetsProvisioner, diff --git a/Explorer/Assets/Scripts/Global/StaticContainer.cs b/Explorer/Assets/Scripts/Global/StaticContainer.cs index 899c750380..b5a9ebf4e6 100644 --- a/Explorer/Assets/Scripts/Global/StaticContainer.cs +++ b/Explorer/Assets/Scripts/Global/StaticContainer.cs @@ -22,6 +22,7 @@ using DCL.Profiling; using DCL.Quality; using DCL.ResourcesUnloading; +using DCL.SceneRestrictionBusController.SceneRestrictionBus; using DCL.SDKComponents.VideoPlayer; using DCL.Settings; using DCL.Time; @@ -96,6 +97,7 @@ public class StaticContainer : IDCLPlugin public IFeatureFlagsProvider FeatureFlagsProvider { get; private set; } public IPortableExperiencesController PortableExperiencesController { get; private set; } public IDebugContainerBuilder DebugContainerBuilder { get; private set; } + public ISceneRestrictionBusController SceneRestrictionBusController { get; private set; } public ILoadingStatus LoadingStatus { get; private set; } @@ -152,6 +154,7 @@ await UniTask.WhenAll( container.InputBlock = new ECSInputBlock(globalWorld); container.assetsProvisioner = assetsProvisioner; container.MemoryCap = memoryCap; + container.SceneRestrictionBusController = new SceneRestrictionBusController(); var exposedPlayerTransform = new ExposedTransform(); @@ -227,13 +230,13 @@ await UniTask.WhenAll( new AnimatorPlugin(), new TweenPlugin(), new MediaPlayerPlugin(sharedDependencies, videoTexturePool, sharedDependencies.FrameTimeBudget, container.assetsProvisioner, container.WebRequestsContainer.WebRequestController, container.CacheCleaner, worldVolumeMacBus), - new CharacterTriggerAreaPlugin(globalWorld, container.MainPlayerAvatarBaseProxy, exposedGlobalDataContainer.ExposedCameraData.CameraEntityProxy, container.CharacterContainer.CharacterObject, componentsContainer.ComponentPoolsRegistry, container.assetsProvisioner, container.CacheCleaner, exposedGlobalDataContainer.ExposedCameraData), + new CharacterTriggerAreaPlugin(globalWorld, container.MainPlayerAvatarBaseProxy, exposedGlobalDataContainer.ExposedCameraData.CameraEntityProxy, container.CharacterContainer.CharacterObject, componentsContainer.ComponentPoolsRegistry, container.assetsProvisioner, container.CacheCleaner, exposedGlobalDataContainer.ExposedCameraData, container.SceneRestrictionBusController, web3IdentityProvider), new InteractionsAudioPlugin(container.assetsProvisioner), new MapPinPlugin(globalWorld, container.FeatureFlagsCache), new MultiplayerPlugin(), new RealmInfoPlugin(container.RealmData, container.RoomHubProxy), - new InputModifierPlugin(globalWorld, container.PlayerEntity), - new MainCameraPlugin(componentsContainer.ComponentPoolsRegistry, container.assetsProvisioner, container.CacheCleaner, exposedGlobalDataContainer.ExposedCameraData, globalWorld), + new InputModifierPlugin(globalWorld, container.PlayerEntity, container.SceneRestrictionBusController), + new MainCameraPlugin(componentsContainer.ComponentPoolsRegistry, container.assetsProvisioner, container.CacheCleaner, exposedGlobalDataContainer.ExposedCameraData, container.SceneRestrictionBusController, globalWorld), #if UNITY_EDITOR new GizmosWorldPlugin(), @@ -248,7 +251,6 @@ await UniTask.WhenAll( textureResolvePlugin, }; - return (container, true); } From 1ece63b2a2205418c1ae5017c86402eeef0cba2b Mon Sep 17 00:00:00 2001 From: Romina Marchetti <51088292+RominaMarchetti@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:04:22 -0300 Subject: [PATCH 21/24] style: badges minor fixes (#2678) * Turned off maskable feature for tooltip * Decrease progress bar width. Increase progress text box size. * Turned of mask feature for the tooltip text --------- Co-authored-by: Ashley Canning --- .../Badges/BadgeInfo_PassportSubView.prefab | 14 +++++++------- .../Badges/BadgeOverviewItem_PassportField.prefab | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Explorer/Assets/DCL/Passport/Prefabs/Badges/BadgeInfo_PassportSubView.prefab b/Explorer/Assets/DCL/Passport/Prefabs/Badges/BadgeInfo_PassportSubView.prefab index 5c588abffc..9441b3e632 100644 --- a/Explorer/Assets/DCL/Passport/Prefabs/Badges/BadgeInfo_PassportSubView.prefab +++ b/Explorer/Assets/DCL/Passport/Prefabs/Badges/BadgeInfo_PassportSubView.prefab @@ -442,8 +442,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} - m_AnchoredPosition: {x: 367, y: 0} - m_SizeDelta: {x: 70, y: 22} + m_AnchoredPosition: {x: 348.14984, y: 0} + m_SizeDelta: {x: 120, y: 22} m_Pivot: {x: 0, y: 0.5} --- !u!222 &5172796849477954305 CanvasRenderer: @@ -935,7 +935,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 360, y: 10} + m_SizeDelta: {x: 340, y: 10} m_Pivot: {x: 0, y: 0.5} --- !u!222 &2515089727087958638 CanvasRenderer: @@ -1259,7 +1259,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 360, y: 10} + m_SizeDelta: {x: 340, y: 10} m_Pivot: {x: 0, y: 0.5} --- !u!222 &378815463696260501 CanvasRenderer: @@ -2003,8 +2003,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} - m_AnchoredPosition: {x: 367, y: 0} - m_SizeDelta: {x: 70, y: 22} + m_AnchoredPosition: {x: 348.14984, y: 0} + m_SizeDelta: {x: 120, y: 22} m_Pivot: {x: 0, y: 0.5} --- !u!222 &5906000884932099535 CanvasRenderer: @@ -2145,7 +2145,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} m_AnchoredPosition: {x: 0, y: -583} - m_SizeDelta: {x: -92, y: 0} + m_SizeDelta: {x: -80, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!114 &8055502815389580269 MonoBehaviour: diff --git a/Explorer/Assets/DCL/Passport/Prefabs/Badges/BadgeOverviewItem_PassportField.prefab b/Explorer/Assets/DCL/Passport/Prefabs/Badges/BadgeOverviewItem_PassportField.prefab index 300240930f..561fc4ac75 100644 --- a/Explorer/Assets/DCL/Passport/Prefabs/Badges/BadgeOverviewItem_PassportField.prefab +++ b/Explorer/Assets/DCL/Passport/Prefabs/Badges/BadgeOverviewItem_PassportField.prefab @@ -61,7 +61,7 @@ MonoBehaviour: m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 + m_Maskable: 0 m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] @@ -201,7 +201,7 @@ MonoBehaviour: m_Color: {r: 0.08627451, g: 0.08235294, b: 0.09411765, a: 1} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 + m_Maskable: 0 m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] From c3602c2ea436e46c448ddddb0e7c8d9c9e7d0ae8 Mon Sep 17 00:00:00 2001 From: Vitaly Popuzin <35366872+popuz@users.noreply.github.com> Date: Fri, 1 Nov 2024 18:47:15 +0200 Subject: [PATCH 22/24] Feat: camera reel storage services (#2672) ## What does this PR change? Adds infrastructure layer for connecting with the Camera Reel backend to Get/Delete/Upload screenshots with their metadata. Currently working only GET request (others are Unauthorized and will be solved it on the back end side) --- .../DecentralandUrls/DecentralandUrl.cs | 3 + .../DecentralandUrlsSource.cs | 3 +- Explorer/Assets/DCL/InWorldCamera.meta | 3 + .../CameraReelStorageService.meta | 3 + .../CameraReelStorageService/AssemblyInfo.cs | 5 + .../AssemblyInfo.cs.meta | 3 + .../CameraReelImagesMetadataRemoteDatabase.cs | 93 ++++ ...raReelImagesMetadataRemoteDatabase.cs.meta | 3 + .../CameraReelRemoteStorageService.cs | 44 ++ .../CameraReelRemoteStorageService.cs.meta | 3 + .../CameraReelS3BucketScreenshotsStorage.cs | 31 ++ ...meraReelS3BucketScreenshotsStorage.cs.meta | 3 + .../DCL.CameraReelStorageService.asmdef | 24 + .../DCL.CameraReelStorageService.asmdef.meta | 3 + .../ICameraReelImagesMetadataDatabase.cs | 17 + .../ICameraReelImagesMetadataDatabase.cs.meta | 3 + .../ICameraReelScreenshotsStorage.cs | 12 + .../ICameraReelScreenshotsStorage.cs.meta | 3 + .../ICameraReelStorageService.cs | 21 + .../ICameraReelStorageService.cs.meta | 3 + .../CameraReelStorageService/Playground.meta | 8 + .../CameraReelRemoteServicesManualTest.cs | 82 ++++ ...CameraReelRemoteServicesManualTest.cs.meta | 11 + .../CameraReelStoragePlayground.unity | 443 ++++++++++++++++++ .../CameraReelStoragePlayground.unity.meta | 7 + .../CameraReelStorageService/Schemas.meta | 8 + .../Schemas/CameraReelResponses.cs | 46 ++ .../Schemas/CameraReelResponses.cs.meta | 3 + .../Schemas/CameraReelStorageStatus.cs | 18 + .../Schemas/CameraReelStorageStatus.cs.meta | 3 + .../Schemas/ScreenshotMetadata.cs | 46 ++ .../Schemas/ScreenshotMetadata.cs.meta | 3 + .../CameraReelStorageService/Tests.meta | 3 + .../Tests/CameraReelStorageServiceTests.cs | 78 +++ .../CameraReelStorageServiceTests.cs.meta | 3 + ...DCL.CameraReelStorage.EditModeTests.asmref | 3 + ...ameraReelStorage.EditModeTests.asmref.meta | 7 + .../ReportsHandling/ReportCategory.cs | 2 + .../NFTShape/Textures/Genesis_TX.png.meta | 46 +- .../Tests/Editor/DCL.EditMode.Tests.asmdef | 3 +- .../GenericDownloadHandlerUtils.cs | 24 +- .../SignedWebRequestControllerExtensions.cs | 125 +++++ ...gnedWebRequestControllerExtensions.cs.meta | 3 + .../WebRequestControllerExtensions.cs | 25 - ...ameraReelStorageService.csproj.DotSettings | 2 + 45 files changed, 1224 insertions(+), 61 deletions(-) create mode 100644 Explorer/Assets/DCL/InWorldCamera.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/AssemblyInfo.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/AssemblyInfo.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelImagesMetadataRemoteDatabase.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelImagesMetadataRemoteDatabase.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelS3BucketScreenshotsStorage.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelS3BucketScreenshotsStorage.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/DCL.CameraReelStorageService.asmdef create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/DCL.CameraReelStorageService.asmdef.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelImagesMetadataDatabase.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelImagesMetadataDatabase.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelScreenshotsStorage.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelScreenshotsStorage.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelStorageService.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelStorageService.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelRemoteServicesManualTest.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelRemoteServicesManualTest.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelStoragePlayground.unity create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelStoragePlayground.unity.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelResponses.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelResponses.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelStorageStatus.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelStorageStatus.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/ScreenshotMetadata.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/ScreenshotMetadata.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/CameraReelStorageServiceTests.cs create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/CameraReelStorageServiceTests.cs.meta create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/DCL.CameraReelStorage.EditModeTests.asmref create mode 100644 Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/DCL.CameraReelStorage.EditModeTests.asmref.meta create mode 100644 Explorer/Assets/DCL/WebRequests/SignedWebRequestControllerExtensions.cs create mode 100644 Explorer/Assets/DCL/WebRequests/SignedWebRequestControllerExtensions.cs.meta create mode 100644 Explorer/DCL.CameraReelStorageService.csproj.DotSettings diff --git a/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrl.cs b/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrl.cs index be6637d424..38777bbc74 100644 --- a/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrl.cs +++ b/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrl.cs @@ -40,5 +40,8 @@ public enum DecentralandUrl AssetBundlesCDN, Badges, + + CameraReelUsers, + CameraReelImages } } diff --git a/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs b/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs index d877170655..deb6c33319 100644 --- a/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs +++ b/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs @@ -51,12 +51,13 @@ private static string RawUrl(DecentralandUrl decentralandUrl) => DecentralandUrl.FeatureFlags => $"https://feature-flags.decentraland.{ENV}", DecentralandUrl.Help => $"https://decentraland.{ENV}/help/", DecentralandUrl.Market => $"https://market.decentraland.{ENV}", - // All ABs are in org DecentralandUrl.AssetBundlesCDN => $"https://ab-cdn.decentraland.{ENV}", DecentralandUrl.ArchipelagoStatus => $"https://archipelago-ea-stats.decentraland.{ENV}/status", DecentralandUrl.GatekeeperStatus => $"https://comms-gatekeeper.decentraland.{ENV}/status", DecentralandUrl.Genesis => $"https://realm-provider-ea.decentraland.{ENV}/main", DecentralandUrl.Badges => $"https://badges.decentraland.{ENV}", + DecentralandUrl.CameraReelUsers => $"https://camera-reel-service.decentraland.{ENV}/api/users", + DecentralandUrl.CameraReelImages => $"https://camera-reel-service.decentraland.{ENV}/api/images", _ => throw new ArgumentOutOfRangeException(nameof(decentralandUrl), decentralandUrl, null!) }; } diff --git a/Explorer/Assets/DCL/InWorldCamera.meta b/Explorer/Assets/DCL/InWorldCamera.meta new file mode 100644 index 0000000000..dd834b496e --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8406b56e19ba453da288d2fb6b58ff57 +timeCreated: 1730134477 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService.meta new file mode 100644 index 0000000000..39948764e9 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ba58cf3e0f064bcbb6d591019fcfe187 +timeCreated: 1730134489 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/AssemblyInfo.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/AssemblyInfo.cs new file mode 100644 index 0000000000..26143776dd --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/AssemblyInfo.cs @@ -0,0 +1,5 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("DCL.EditMode.Tests")] +[assembly: InternalsVisibleTo("DCL.PlayMode.Tests")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // for NSubstitute diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/AssemblyInfo.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/AssemblyInfo.cs.meta new file mode 100644 index 0000000000..52cd4f57cc --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/AssemblyInfo.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 98da528f3b3d4bc6a967d3b544f013ed +timeCreated: 1730391816 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelImagesMetadataRemoteDatabase.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelImagesMetadataRemoteDatabase.cs new file mode 100644 index 0000000000..c57078d5ad --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelImagesMetadataRemoteDatabase.cs @@ -0,0 +1,93 @@ +using CommunicationData.URLHelpers; +using Cysharp.Threading.Tasks; +using DCL.InWorldCamera.CameraReelStorageService.Schemas; +using DCL.Multiplayer.Connections.DecentralandUrls; +using DCL.WebRequests; +using System.Collections.Generic; +using System.Threading; +using UnityEngine; +using UnityEngine.Networking; + +namespace DCL.InWorldCamera.CameraReelStorageService +{ + internal class CameraReelImagesMetadataRemoteDatabase : ICameraReelImagesMetadataDatabase + { + private readonly IWebRequestController webRequestController; + + private readonly URLBuilder urlBuilder = new (); + private readonly URLDomain imageDomain; + private readonly URLDomain userDomain; + + public CameraReelImagesMetadataRemoteDatabase(IWebRequestController webRequestController, IDecentralandUrlsSource decentralandUrlsSource) + { + this.webRequestController = webRequestController; + + imageDomain = URLDomain.FromString(decentralandUrlsSource.Url(DecentralandUrl.CameraReelImages)); + userDomain = URLDomain.FromString(decentralandUrlsSource.Url(DecentralandUrl.CameraReelUsers)); + } + + public async UniTask GetStorageInfoAsync(string userAddress, CancellationToken ct) + { + URLAddress url = urlBuilder.AppendDomain(userDomain) + .AppendSubDirectory(URLSubdirectory.FromString(userAddress)) + .Build(); + + urlBuilder.Clear(); + + CameraReelStorageResponse responseData = await webRequestController + .SignedFetchGetAsync(url, string.Empty, ct) + .CreateFromJson(WRJsonParser.Unity); + + return responseData; + } + + public async UniTask GetScreenshotsAsync(string userAddress, int limit, int offset, CancellationToken ct) + { + URLAddress url = urlBuilder.AppendDomain(userDomain) + .AppendSubDirectory(URLSubdirectory.FromString(userAddress)) + .AppendSubDirectory(URLSubdirectory.FromString($"images?limit={limit}&offset={offset}")) + .Build(); + + urlBuilder.Clear(); + + CameraReelResponses responseData = await webRequestController + .SignedFetchGetAsync(url, string.Empty, ct) + .CreateFromJson(WRJsonParser.Unity); + + return responseData; + } + + public async UniTask DeleteScreenshotAsync(string uuid, CancellationToken ct) + { + URLAddress url = urlBuilder.AppendDomain(imageDomain) + .AppendSubDirectory(URLSubdirectory.FromString(uuid)) + .Build(); + + urlBuilder.Clear(); + + CameraReelStorageResponse responseData = await webRequestController + .SignedFetchDeleteAsync(url, string.Empty, ct) + .CreateFromJson(WRJsonParser.Unity); + + return responseData; + } + + public async UniTask UploadScreenshotAsync(byte[] image, ScreenshotMetadata metadata, CancellationToken ct) + { + URLAddress url = urlBuilder.AppendDomain(imageDomain).Build(); + urlBuilder.Clear(); + + var formData = new List + { + new MultipartFormFileSection("image", image, $"{metadata.dateTime}.jpg", "image/jpeg"), + new MultipartFormDataSection("metadata", JsonUtility.ToJson(metadata)), + }; + + CameraReelUploadResponse responseData = await webRequestController + .SignedFetchPostAsync(url, GenericPostArguments.CreateMultipartForm(formData), string.Empty, ct) + .CreateFromJson(WRJsonParser.Unity); + + return responseData; + } + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelImagesMetadataRemoteDatabase.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelImagesMetadataRemoteDatabase.cs.meta new file mode 100644 index 0000000000..734fb51a5b --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelImagesMetadataRemoteDatabase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ad9d72f987364b57883135bf5b76ef09 +timeCreated: 1730135291 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs new file mode 100644 index 0000000000..35dda4508d --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs @@ -0,0 +1,44 @@ +using Cysharp.Threading.Tasks; +using DCL.InWorldCamera.CameraReelStorageService.Schemas; +using System; +using System.Threading; +using UnityEngine; + +namespace DCL.InWorldCamera.CameraReelStorageService +{ + public class CameraReelRemoteStorageService : ICameraReelStorageService + { + private readonly ICameraReelImagesMetadataDatabase imagesMetadataDatabase; + + public event Action ScreenshotUploaded; + + internal CameraReelRemoteStorageService(ICameraReelImagesMetadataDatabase imagesMetadataDatabase) + { + this.imagesMetadataDatabase = imagesMetadataDatabase; + } + + public async UniTask GetUserGalleryStorageInfoAsync(string userAddress, CancellationToken ct = default) + { + CameraReelStorageResponse response = await imagesMetadataDatabase.GetStorageInfoAsync(userAddress, ct); + return new CameraReelStorageStatus(response.currentImages, response.maxImages); + } + + public async UniTask GetScreenshotGalleryAsync(string userAddress, int limit, int offset, CancellationToken ct) => + await imagesMetadataDatabase.GetScreenshotsAsync(userAddress, limit, offset, ct); + + public async UniTask DeleteScreenshotAsync(string uuid, CancellationToken ct = default) + { + CameraReelStorageResponse response = await imagesMetadataDatabase.DeleteScreenshotAsync(uuid, ct); + return new CameraReelStorageStatus(response.currentImages, response.maxImages); + } + + public async UniTask UploadScreenshotAsync(Texture2D image, ScreenshotMetadata metadata, CancellationToken ct = default) + { + CameraReelUploadResponse response = await imagesMetadataDatabase.UploadScreenshotAsync(image.EncodeToJPG(), metadata, ct); + + var storageStatus = new CameraReelStorageStatus(response.currentImages, response.maxImages); + ScreenshotUploaded?.Invoke(response.image, storageStatus); + return storageStatus; + } + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs.meta new file mode 100644 index 0000000000..49dc98ab48 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelRemoteStorageService.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 582d1d518be44bcc81bff57bb8c2787b +timeCreated: 1730135079 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelS3BucketScreenshotsStorage.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelS3BucketScreenshotsStorage.cs new file mode 100644 index 0000000000..8a8818a286 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelS3BucketScreenshotsStorage.cs @@ -0,0 +1,31 @@ +using CommunicationData.URLHelpers; +using Cysharp.Threading.Tasks; +using DCL.Diagnostics; +using DCL.WebRequests; +using System.Threading; +using UnityEngine; + +namespace DCL.InWorldCamera.CameraReelStorageService +{ + public class CameraReelS3BucketScreenshotsStorage : ICameraReelScreenshotsStorage + { + private readonly IWebRequestController webRequestController; + + public CameraReelS3BucketScreenshotsStorage(IWebRequestController webRequestController) + { + this.webRequestController = webRequestController; + } + + public async UniTask GetScreenshotImageAsync(string url) => + await GetImageAsync(url); + + public async UniTask GetScreenshotThumbnailAsync(string url) => + await GetImageAsync(url); + + private async UniTask GetImageAsync(string url) => + await webRequestController.GetTextureAsync( + new CommonArguments(URLAddress.FromString(url)), + new GetTextureArguments(false), + GetTextureWebRequest.CreateTexture(TextureWrapMode.Clamp), default(CancellationToken), ReportCategory.CAMERA_REEL); + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelS3BucketScreenshotsStorage.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelS3BucketScreenshotsStorage.cs.meta new file mode 100644 index 0000000000..fa8e77a513 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/CameraReelS3BucketScreenshotsStorage.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9d3dcbac8fda4bc3a82210e0d15c2cad +timeCreated: 1730378286 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/DCL.CameraReelStorageService.asmdef b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/DCL.CameraReelStorageService.asmdef new file mode 100644 index 0000000000..5d75612b6b --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/DCL.CameraReelStorageService.asmdef @@ -0,0 +1,24 @@ +{ + "name": "DCL.CameraReelStorageService", + "rootNamespace": "", + "references": [ + "GUID:f51ebe6a0ceec4240a699833d6309b23", + "GUID:4a12c0b1b77ec6b418a8d7bd5c925be3", + "GUID:0b3eab7834a09c24ca4e84fe0d8a43ce", + "GUID:3640f3c0b42946b0b8794a1ed8e06ca5", + "GUID:8322ea9340a544c59ddc56d4793eac74", + "GUID:91cf8206af184dac8e30eb46747e9939", + "GUID:fa7b3fdbb04d67549916da7bd2af58ab", + "GUID:5ab29fa8ae5769b49ab29e390caca7a4", + "GUID:ca4e81cdd6a34d1aa54c32ad41fc5b3b" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/DCL.CameraReelStorageService.asmdef.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/DCL.CameraReelStorageService.asmdef.meta new file mode 100644 index 0000000000..45109c5485 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/DCL.CameraReelStorageService.asmdef.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f0968673e9444d64b49cde6a40d7df7a +timeCreated: 1730134632 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelImagesMetadataDatabase.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelImagesMetadataDatabase.cs new file mode 100644 index 0000000000..758f2aa3d5 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelImagesMetadataDatabase.cs @@ -0,0 +1,17 @@ +using Cysharp.Threading.Tasks; +using DCL.InWorldCamera.CameraReelStorageService.Schemas; +using System.Threading; + +namespace DCL.InWorldCamera.CameraReelStorageService +{ + internal interface ICameraReelImagesMetadataDatabase + { + UniTask GetStorageInfoAsync(string userAddress, CancellationToken ct); + + UniTask GetScreenshotsAsync(string userAddress, int limit, int offset, CancellationToken ct); + + UniTask UploadScreenshotAsync(byte[] image, ScreenshotMetadata metadata, CancellationToken ct); + + UniTask DeleteScreenshotAsync(string uuid, CancellationToken ct); + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelImagesMetadataDatabase.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelImagesMetadataDatabase.cs.meta new file mode 100644 index 0000000000..078ecb665c --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelImagesMetadataDatabase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3244b967213b456baf2bdd1487e25888 +timeCreated: 1730135021 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelScreenshotsStorage.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelScreenshotsStorage.cs new file mode 100644 index 0000000000..aafa0cd75a --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelScreenshotsStorage.cs @@ -0,0 +1,12 @@ +using Cysharp.Threading.Tasks; +using UnityEngine; + +namespace DCL.InWorldCamera.CameraReelStorageService +{ + public interface ICameraReelScreenshotsStorage + { + public UniTask GetScreenshotImageAsync(string url); + + public UniTask GetScreenshotThumbnailAsync(string url); + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelScreenshotsStorage.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelScreenshotsStorage.cs.meta new file mode 100644 index 0000000000..0c3a9a4942 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelScreenshotsStorage.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0b54ff9f66f747daa49d78ba97315fab +timeCreated: 1730377987 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelStorageService.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelStorageService.cs new file mode 100644 index 0000000000..5e8ecb26fb --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelStorageService.cs @@ -0,0 +1,21 @@ +using Cysharp.Threading.Tasks; +using DCL.InWorldCamera.CameraReelStorageService.Schemas; +using System; +using System.Threading; +using UnityEngine; + +namespace DCL.InWorldCamera.CameraReelStorageService +{ + public interface ICameraReelStorageService + { + event Action ScreenshotUploaded; + + UniTask GetUserGalleryStorageInfoAsync(string userAddress, CancellationToken ct = default); + + UniTask GetScreenshotGalleryAsync(string userAddress, int limit, int offset, CancellationToken ct = default); + + UniTask DeleteScreenshotAsync(string uuid, CancellationToken ct = default); + + UniTask UploadScreenshotAsync(Texture2D image, ScreenshotMetadata metadata, CancellationToken ct = default); + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelStorageService.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelStorageService.cs.meta new file mode 100644 index 0000000000..83927803af --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/ICameraReelStorageService.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ad6a57d98d444ed884aee83809b8fed7 +timeCreated: 1730134526 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground.meta new file mode 100644 index 0000000000..2bcc4c163f --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eaf61f728c61acf42800b039a42d03cd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelRemoteServicesManualTest.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelRemoteServicesManualTest.cs new file mode 100644 index 0000000000..892cf1a801 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelRemoteServicesManualTest.cs @@ -0,0 +1,82 @@ +using DCL.Browser.DecentralandUrls; +using DCL.InWorldCamera.CameraReelStorageService.Schemas; +using DCL.Multiplayer.Connections.DecentralandUrls; +using DCL.Web3.Identities; +using DCL.WebRequests; +using System.Linq; +using System.Threading; +using UnityEngine; + +namespace DCL.InWorldCamera.CameraReelStorageService.Playground +{ + public class CameraReelRemoteServicesManualTest : MonoBehaviour + { + private readonly IWeb3IdentityCache.Default identity = new (); + private readonly IWebRequestController webRequestController = IWebRequestController.DEFAULT; + private readonly CancellationToken ct = CancellationToken.None; + + public DecentralandEnvironment Env; + + public CameraReelStorageResponse Storage; + + [Header("GALLERY")] + public int Limit = 10; + public int Offset; + + [Space(5)] + public CameraReelResponses Result; + public Texture2D ImageTexture; + public Texture2D ThumbnailTexture; + + [Header("UPLOAD")] + public string ThumbnailUrl; + + private ICameraReelScreenshotsStorage screenshotsStorageInternal; + private ICameraReelScreenshotsStorage screenshotsStorage => screenshotsStorageInternal ??= new CameraReelS3BucketScreenshotsStorage(webRequestController); + + private ICameraReelImagesMetadataDatabase metadataDatabase + { + get + { + var urlsSource = new DecentralandUrlsSource(Env); + return new CameraReelImagesMetadataRemoteDatabase(webRequestController, urlsSource); + } + } + + [ContextMenu("GET STORAGE")] + public async void GetStorageAsync() + { + Storage = await metadataDatabase.GetStorageInfoAsync(identity.Identity.Address, ct); + } + + [ContextMenu("GET GALLERY")] + public async void GetGalleryAsync() + { + Result = await metadataDatabase.GetScreenshotsAsync(identity.Identity.Address, Limit, Offset, ct); + + Storage.currentImages = Result.currentImages; + Storage.maxImages = Result.maxImages; + + CameraReelResponse screenshot = Result.images.First(); + ImageTexture = await screenshotsStorage.GetScreenshotImageAsync(screenshot.url); + ThumbnailTexture = await screenshotsStorage.GetScreenshotThumbnailAsync(screenshot.thumbnailUrl); + } + + [ContextMenu("UPLOAD IMAGE")] + public async void UploadImageAsync() + { + CameraReelUploadResponse response = await metadataDatabase.UploadScreenshotAsync(ImageTexture.EncodeToJPG(), Result.images.First().metadata, ct); + + Storage.currentImages = response.currentImages; + Storage.maxImages = response.maxImages; + + ThumbnailUrl = response.image.thumbnailUrl; + } + + [ContextMenu("DELETE IMAGE")] + public async void DeleteImageAsync() + { + Storage = await metadataDatabase.DeleteScreenshotAsync(Result.images.First().id, ct); + } + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelRemoteServicesManualTest.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelRemoteServicesManualTest.cs.meta new file mode 100644 index 0000000000..251f179156 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelRemoteServicesManualTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 095eeef8af7fd1c48bab8e486c999941 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelStoragePlayground.unity b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelStoragePlayground.unity new file mode 100644 index 0000000000..b2c38c823f --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelStoragePlayground.unity @@ -0,0 +1,443 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 1 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &305995175 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 305995178} + - component: {fileID: 305995177} + - component: {fileID: 305995176} + - component: {fileID: 305995179} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &305995176 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 305995175} + m_Enabled: 1 +--- !u!20 &305995177 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 305995175} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &305995178 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 305995175} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &305995179 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 305995175} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_VolumeFrameworkUpdateModeOption: 2 + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_AllowXRRendering: 1 + m_AllowHDROutput: 1 + m_UseScreenCoordOverride: 0 + m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} + m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0} + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 + m_TaaSettings: + m_Quality: 3 + m_FrameInfluence: 0.1 + m_JitterScale: 1 + m_MipBias: 0 + m_VarianceClampScale: 0.9 + m_ContrastAdaptiveSharpening: 0 +--- !u!1 &1128956470 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1128956472} + - component: {fileID: 1128956471} + - component: {fileID: 1128956473} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1128956471 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1128956470} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1128956472 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1128956470} + serializedVersion: 2 + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!114 &1128956473 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1128956470} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Version: 3 + m_UsePipelineSettings: 1 + m_AdditionalLightsShadowResolutionTier: 2 + m_LightLayerMask: 1 + m_RenderingLayers: 1 + m_CustomShadowLayers: 0 + m_ShadowLayerMask: 1 + m_ShadowRenderingLayers: 1 + m_LightCookieSize: {x: 1, y: 1} + m_LightCookieOffset: {x: 0, y: 0} + m_SoftShadowQuality: 0 +--- !u!1 &1362899095 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1362899097} + - component: {fileID: 1362899096} + m_Layer: 0 + m_Name: _entry-S3_and_DB + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1362899096 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1362899095} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 095eeef8af7fd1c48bab8e486c999941, type: 3} + m_Name: + m_EditorClassIdentifier: + Env: 1 + Storage: + currentImages: 0 + maxImages: 0 + Limit: 10 + Offset: 0 + Result: + images: [] + currentImages: 0 + maxImages: 0 + ImageTexture: {fileID: 0} + ThumbnailTexture: {fileID: 0} + ThumbnailUrl: +--- !u!4 &1362899097 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1362899095} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -8.971594, y: 2.073621, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 1362899097} + - {fileID: 305995178} + - {fileID: 1128956472} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelStoragePlayground.unity.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelStoragePlayground.unity.meta new file mode 100644 index 0000000000..d679546cbd --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Playground/CameraReelStoragePlayground.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 67c14bc2248d74943a15314d88970c7a +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas.meta new file mode 100644 index 0000000000..fe0282fb64 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 80a32bde08f36e346b1f0ac7ce6faedc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelResponses.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelResponses.cs new file mode 100644 index 0000000000..24c14793d6 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelResponses.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; + +namespace DCL.InWorldCamera.CameraReelStorageService.Schemas +{ + [Serializable] + public class CameraReelResponses + { + public List images = new (); + public int currentImages; + public int maxImages; + } + + [Serializable] + public class CameraReelResponse + { + public string id; + public string url; + public string thumbnailUrl; + + public ScreenshotMetadata metadata; + } + + [Serializable] + public class CameraReelUploadResponse + { + public int currentImages; + public int maxImages; + + public CameraReelResponse image; + } + + [Serializable] + public class CameraReelStorageResponse + { + public int currentImages; + public int maxImages; + } + + [Serializable] + public class CameraReelErrorResponse + { + public string message; + public string reason; + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelResponses.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelResponses.cs.meta new file mode 100644 index 0000000000..b22c2d384d --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelResponses.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 15c93b2d287a4daaa3436f81aaac0247 +timeCreated: 1730134731 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelStorageStatus.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelStorageStatus.cs new file mode 100644 index 0000000000..198779c773 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelStorageStatus.cs @@ -0,0 +1,18 @@ +namespace DCL.InWorldCamera.CameraReelStorageService.Schemas +{ + public readonly struct CameraReelStorageStatus + { + public readonly int ScreenshotsAmount; + public readonly int MaxScreenshots; + + public readonly bool HasFreeSpace; + + public CameraReelStorageStatus(int screenshotsAmount, int maxScreenshots) + { + this.ScreenshotsAmount = screenshotsAmount; + MaxScreenshots = maxScreenshots; + + HasFreeSpace = ScreenshotsAmount < MaxScreenshots; + } + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelStorageStatus.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelStorageStatus.cs.meta new file mode 100644 index 0000000000..49c3517dc8 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/CameraReelStorageStatus.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f86950c281df4a98b184ba877d56ca1c +timeCreated: 1730134674 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/ScreenshotMetadata.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/ScreenshotMetadata.cs new file mode 100644 index 0000000000..254bf247c8 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/ScreenshotMetadata.cs @@ -0,0 +1,46 @@ +using System; +using UnityEngine; + +namespace DCL.InWorldCamera.CameraReelStorageService.Schemas +{ + [Serializable] + public class ScreenshotMetadata + { + public string userName; + public string userAddress; + public string dateTime; + public string realm; + public Scene scene; + public VisiblePerson[] visiblePeople; + } + + [Serializable] + public class Scene + { + public string name; + public Location location; + } + + [Serializable] + public class Location + { + public string x; + public string y; + + public Location(Vector2Int position) + { + x = position.x.ToString(); + y = position.y.ToString(); + } + } + + [Serializable] + public class VisiblePerson + { + public string userName; + public string userAddress; + public bool isGuest; + + public string[] wearables; + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/ScreenshotMetadata.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/ScreenshotMetadata.cs.meta new file mode 100644 index 0000000000..ceb159d791 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Schemas/ScreenshotMetadata.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a6b4a510059145578a1ca5fca13232c4 +timeCreated: 1730134853 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests.meta new file mode 100644 index 0000000000..c88c9b7c3d --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c758fdcdc0b249a4880d365c5e441bd4 +timeCreated: 1730379153 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/CameraReelStorageServiceTests.cs b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/CameraReelStorageServiceTests.cs new file mode 100644 index 0000000000..cc885dcc16 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/CameraReelStorageServiceTests.cs @@ -0,0 +1,78 @@ +using Cysharp.Threading.Tasks; +using DCL.InWorldCamera.CameraReelStorageService.Schemas; +using NSubstitute; +using NUnit.Framework; +using System.Threading; +using System.Threading.Tasks; + +namespace DCL.InWorldCamera.CameraReelStorageService.Tests +{ + public class CameraReelStorageServiceTests + { + private const string USER_ADDRESS = "testAddress"; + private const int LIMIT = 10; + private const int OFFSET = 0; + + private ICameraReelImagesMetadataDatabase metadataDatabase; + private CameraReelRemoteStorageService storageService; + + [SetUp] + public void Setup() + { + metadataDatabase = Substitute.For(); + storageService = new CameraReelRemoteStorageService(metadataDatabase); + } + + [Test] + public async Task GetUserGalleryStorageInfo_ShouldReturnCorrectStatus() + { + // Arrange + var expectedResponse = new CameraReelStorageResponse { currentImages = 5, maxImages = 10 }; + metadataDatabase.GetStorageInfoAsync(USER_ADDRESS, Arg.Any()) + .Returns(UniTask.FromResult(expectedResponse)); + + // Act + CameraReelStorageStatus result = await storageService.GetUserGalleryStorageInfoAsync(USER_ADDRESS); + + // Assert + Assert.That(result.ScreenshotsAmount, Is.EqualTo(expectedResponse.currentImages)); + Assert.That(result.MaxScreenshots, Is.EqualTo(expectedResponse.maxImages)); + await metadataDatabase.Received(1).GetStorageInfoAsync(USER_ADDRESS, Arg.Any()); + } + + [Test] + public async Task GetScreenshotGallery_ShouldReturnResponseFromDatabase() + { + // Arrange + + var expectedResponse = new CameraReelResponses(); + metadataDatabase.GetScreenshotsAsync(USER_ADDRESS, LIMIT, OFFSET, Arg.Any()) + .Returns(UniTask.FromResult(expectedResponse)); + + // Act + var result = await storageService.GetScreenshotGalleryAsync(USER_ADDRESS, LIMIT, OFFSET, CancellationToken.None); + + // Assert + Assert.That(result, Is.EqualTo(expectedResponse)); + await metadataDatabase.Received(1).GetScreenshotsAsync(USER_ADDRESS, LIMIT, OFFSET, Arg.Any()); + } + + [Test] + public async Task DeleteScreenshot_ShouldReturnUpdatedStatus() + { + // Arrange + const string UUID = "test-uuid"; + var expectedResponse = new CameraReelStorageResponse { currentImages = 4, maxImages = 10 }; + metadataDatabase.DeleteScreenshotAsync(UUID, Arg.Any()) + .Returns(UniTask.FromResult(expectedResponse)); + + // Act + var result = await storageService.DeleteScreenshotAsync(UUID); + + // Assert + Assert.That(result.ScreenshotsAmount, Is.EqualTo(expectedResponse.currentImages)); + Assert.That(result.MaxScreenshots, Is.EqualTo(expectedResponse.maxImages)); + await metadataDatabase.Received(1).DeleteScreenshotAsync(UUID, Arg.Any()); + } + } +} diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/CameraReelStorageServiceTests.cs.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/CameraReelStorageServiceTests.cs.meta new file mode 100644 index 0000000000..de65970750 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/CameraReelStorageServiceTests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2357685abe5f47fc9dc00e67eeef2339 +timeCreated: 1730381131 \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/DCL.CameraReelStorage.EditModeTests.asmref b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/DCL.CameraReelStorage.EditModeTests.asmref new file mode 100644 index 0000000000..9c56917b75 --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/DCL.CameraReelStorage.EditModeTests.asmref @@ -0,0 +1,3 @@ +{ + "reference": "GUID:da80994a355e49d5b84f91c0a84a721f" +} \ No newline at end of file diff --git a/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/DCL.CameraReelStorage.EditModeTests.asmref.meta b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/DCL.CameraReelStorage.EditModeTests.asmref.meta new file mode 100644 index 0000000000..05260af17a --- /dev/null +++ b/Explorer/Assets/DCL/InWorldCamera/CameraReelStorageService/Tests/DCL.CameraReelStorage.EditModeTests.asmref.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4348944ebec49d34eb2e085d5f24fe23 +AssemblyDefinitionReferenceImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/ReportCategory.cs b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/ReportCategory.cs index 15c820a49a..219cc1afc5 100644 --- a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/ReportCategory.cs +++ b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/ReportCategory.cs @@ -248,6 +248,8 @@ public static class ReportCategory /// public const string UI = nameof(UI); + public const string CAMERA_REEL = nameof(CAMERA_REEL); + /// /// Fetch requests initiated from the Scene side through the fetch API /// diff --git a/Explorer/Assets/DCL/SDKComponents/NFTShape/Textures/Genesis_TX.png.meta b/Explorer/Assets/DCL/SDKComponents/NFTShape/Textures/Genesis_TX.png.meta index 6ea142cfc4..fd17eca38e 100644 --- a/Explorer/Assets/DCL/SDKComponents/NFTShape/Textures/Genesis_TX.png.meta +++ b/Explorer/Assets/DCL/SDKComponents/NFTShape/Textures/Genesis_TX.png.meta @@ -3,7 +3,7 @@ guid: a2219697073014232b2c52386770c95b TextureImporter: internalIDToNameTable: [] externalObjects: {} - serializedVersion: 10 + serializedVersion: 13 mipmaps: mipMapMode: 0 enableMipMap: 1 @@ -20,9 +20,12 @@ TextureImporter: externalNormalMap: 0 heightScale: 0.25 normalMapFilter: 0 - isReadable: 0 + flipGreenChannel: 0 + isReadable: 1 streamingMipmaps: 0 streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -31,12 +34,12 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: -1 - wrapV: -1 - wrapW: -1 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 nPOTScale: 1 lightmap: 0 compressionQuality: 50 @@ -54,11 +57,17 @@ TextureImporter: textureType: 0 textureShape: 1 singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 maxTextureSizeSet: 0 compressionQualitySet: 0 textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 1 + swizzle: 50462976 + cookieLightType: 1 platformSettings: - - serializedVersion: 2 + - serializedVersion: 3 buildTarget: DefaultTexturePlatform maxTextureSize: 2048 resizeAlgorithm: 0 @@ -68,7 +77,22 @@ TextureImporter: crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 + ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: [] @@ -82,9 +106,9 @@ TextureImporter: edges: [] weights: [] secondaryTextures: [] - spritePackingTag: + nameFileIdTable: {} + mipmapLimitGroupName: pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 userData: assetBundleName: assetBundleVariant: diff --git a/Explorer/Assets/DCL/Tests/Editor/DCL.EditMode.Tests.asmdef b/Explorer/Assets/DCL/Tests/Editor/DCL.EditMode.Tests.asmdef index ce1c4d8fe6..d4e64f64eb 100644 --- a/Explorer/Assets/DCL/Tests/Editor/DCL.EditMode.Tests.asmdef +++ b/Explorer/Assets/DCL/Tests/Editor/DCL.EditMode.Tests.asmdef @@ -73,7 +73,8 @@ "GUID:21c2e77c042a2d34d8cfbf58f8217053", "GUID:b46779583a009f04ba9f5f31d0e7e6ac", "GUID:1300820cd310d4584b09afde765bdd16", - "GUID:a7b31707bb5e04b20bfe1421647e6707" + "GUID:a7b31707bb5e04b20bfe1421647e6707", + "GUID:f0968673e9444d64b49cde6a40d7df7a" ], "includePlatforms": [ "Editor" diff --git a/Explorer/Assets/DCL/WebRequests/GenericDownloadHandlerUtils.cs b/Explorer/Assets/DCL/WebRequests/GenericDownloadHandlerUtils.cs index 96b6090e2e..bd879767d4 100644 --- a/Explorer/Assets/DCL/WebRequests/GenericDownloadHandlerUtils.cs +++ b/Explorer/Assets/DCL/WebRequests/GenericDownloadHandlerUtils.cs @@ -1,5 +1,6 @@ using Cysharp.Threading.Tasks; using DCL.Diagnostics; +using DCL.WebRequests.GenericDelete; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -8,7 +9,6 @@ using UnityEngine; using UnityEngine.Networking; using Utility; -using Utility.Times; using static DCL.WebRequests.WebRequestControllerExtensions; namespace DCL.WebRequests @@ -20,28 +20,6 @@ public static class GenericDownloadHandlerUtils { public delegate Exception CreateExceptionOnParseFail(Exception exception, string text); - public static Adapter SignedFetchPostAsync( - this IWebRequestController controller, - CommonArguments commonArguments, - string jsonMetaData, - CancellationToken ct - ) - { - ulong unixTimestamp = DateTime.UtcNow.UnixTimeAsMilliseconds(); - - return new Adapter( - controller, - commonArguments, - GenericPostArguments.Empty, - ct, - ReportCategory.GENERIC_WEB_REQUEST, - new WebRequestHeadersInfo().WithSign(jsonMetaData, unixTimestamp), - WebRequestSignInfo.NewFromRaw(jsonMetaData, commonArguments.URL, unixTimestamp, "post"), - null, - POST_GENERIC - ); - } - public static Adapter GetAsync(this IWebRequestController controller, CommonArguments commonArguments, CancellationToken ct, ReportData reportData, WebRequestHeadersInfo? headersInfo = null, WebRequestSignInfo? signInfo = null, ISet? ignoreErrorCodes = null) => new (controller, commonArguments, default(GenericGetArguments), ct, reportData, headersInfo, signInfo, ignoreErrorCodes, GET_GENERIC); diff --git a/Explorer/Assets/DCL/WebRequests/SignedWebRequestControllerExtensions.cs b/Explorer/Assets/DCL/WebRequests/SignedWebRequestControllerExtensions.cs new file mode 100644 index 0000000000..3e881d2f3f --- /dev/null +++ b/Explorer/Assets/DCL/WebRequests/SignedWebRequestControllerExtensions.cs @@ -0,0 +1,125 @@ +using Cysharp.Threading.Tasks; +using DCL.Diagnostics; +using DCL.WebRequests.GenericDelete; +using System; +using System.Threading; +using Utility.Times; +using static DCL.WebRequests.WebRequestControllerExtensions; + +namespace DCL.WebRequests +{ + public static class SignedWebRequestControllerExtensions + { + public static UniTask SignedFetchPostAsync( + this IWebRequestController controller, + CommonArguments commonArguments, + TOp webRequestOp, + string signatureMetadata, + ReportData reportData, + CancellationToken ct + ) + where TOp: struct, IWebRequestOp + { + ulong unixTimestamp = DateTime.UtcNow.UnixTimeAsMilliseconds(); + + return controller.PostAsync( + commonArguments, + webRequestOp, + GenericPostArguments.Empty, + ct, + reportData, + signInfo: WebRequestSignInfo.NewFromRaw(signatureMetadata, commonArguments.URL, unixTimestamp, "post"), + headersInfo: new WebRequestHeadersInfo().WithSign(signatureMetadata, unixTimestamp) + ); + } + + public static GenericDownloadHandlerUtils.Adapter SignedFetchPostAsync( + this IWebRequestController controller, + CommonArguments commonArguments, + string jsonMetaData, + CancellationToken ct + ) + { + ulong unixTimestamp = DateTime.UtcNow.UnixTimeAsMilliseconds(); + + return new GenericDownloadHandlerUtils.Adapter( + controller, + commonArguments, + GenericPostArguments.Empty, + ct, + ReportCategory.GENERIC_WEB_REQUEST, + new WebRequestHeadersInfo().WithSign(jsonMetaData, unixTimestamp), + WebRequestSignInfo.NewFromRaw(jsonMetaData, commonArguments.URL, unixTimestamp, "post"), + null, + POST_GENERIC + ); + } + + public static GenericDownloadHandlerUtils.Adapter SignedFetchPostAsync( + this IWebRequestController controller, + CommonArguments commonArguments, + GenericPostArguments postArguments, + string jsonMetaData, + CancellationToken ct + ) + { + ulong unixTimestamp = DateTime.UtcNow.UnixTimeAsMilliseconds(); + + return new GenericDownloadHandlerUtils.Adapter( + controller, + commonArguments, + GenericPostArguments.Empty, + ct, + ReportCategory.GENERIC_WEB_REQUEST, + new WebRequestHeadersInfo().WithSign(jsonMetaData, unixTimestamp), + WebRequestSignInfo.NewFromRaw(jsonMetaData, commonArguments.URL, unixTimestamp, "post"), + null, + POST_GENERIC + ); + } + + public static GenericDownloadHandlerUtils.Adapter SignedFetchGetAsync( + this IWebRequestController controller, + CommonArguments commonArguments, + string jsonMetaData, + CancellationToken ct + ) + { + ulong unixTimestamp = DateTime.UtcNow.UnixTimeAsMilliseconds(); + + return new GenericDownloadHandlerUtils.Adapter( + controller, + commonArguments, + new GenericGetArguments(), + ct, + ReportCategory.GENERIC_WEB_REQUEST, + new WebRequestHeadersInfo().WithSign(jsonMetaData, unixTimestamp), + WebRequestSignInfo.NewFromRaw(jsonMetaData, commonArguments.URL, unixTimestamp, "get"), + null, + GET_GENERIC + ); + } + + public static GenericDownloadHandlerUtils.Adapter SignedFetchDeleteAsync( + this IWebRequestController controller, + CommonArguments commonArguments, + string jsonMetaData, + CancellationToken ct + ) + { + ulong unixTimestamp = DateTime.UtcNow.UnixTimeAsMilliseconds(); + + return new GenericDownloadHandlerUtils.Adapter( + controller, + commonArguments, + GenericDeleteArguments.Empty, + ct, + ReportCategory.GENERIC_WEB_REQUEST, + new WebRequestHeadersInfo().WithSign(jsonMetaData, unixTimestamp), + WebRequestSignInfo.NewFromRaw(jsonMetaData, commonArguments.URL, unixTimestamp, "delete"), + null, + DELETE_GENERIC + ); + } + } +} diff --git a/Explorer/Assets/DCL/WebRequests/SignedWebRequestControllerExtensions.cs.meta b/Explorer/Assets/DCL/WebRequests/SignedWebRequestControllerExtensions.cs.meta new file mode 100644 index 0000000000..7f15b6f2d7 --- /dev/null +++ b/Explorer/Assets/DCL/WebRequests/SignedWebRequestControllerExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ca80d1c7455640e9a8c21588ad26998f +timeCreated: 1730229109 \ No newline at end of file diff --git a/Explorer/Assets/DCL/WebRequests/WebRequestControllerExtensions.cs b/Explorer/Assets/DCL/WebRequests/WebRequestControllerExtensions.cs index e00581411e..0b66305dbc 100644 --- a/Explorer/Assets/DCL/WebRequests/WebRequestControllerExtensions.cs +++ b/Explorer/Assets/DCL/WebRequests/WebRequestControllerExtensions.cs @@ -1,7 +1,6 @@ using CommunicationData.URLHelpers; using Cysharp.Threading.Tasks; using DCL.Diagnostics; -using DCL.Optimization.PerformanceBudgeting; using DCL.WebRequests.GenericDelete; using System; using System.Collections.Generic; @@ -9,7 +8,6 @@ using DCL.DebugUtilities.UIBindings; using UnityEngine; using UnityEngine.Networking; -using Utility.Times; namespace DCL.WebRequests { @@ -55,29 +53,6 @@ public static UniTask SendAsync SignedFetchPostAsync( - this IWebRequestController controller, - CommonArguments commonArguments, - TOp webRequestOp, - string signatureMetadata, - ReportData reportData, - CancellationToken ct - ) - where TOp: struct, IWebRequestOp - { - ulong unixTimestamp = DateTime.UtcNow.UnixTimeAsMilliseconds(); - - return controller.PostAsync( - commonArguments, - webRequestOp, - GenericPostArguments.Empty, - ct, - reportData, - signInfo: WebRequestSignInfo.NewFromRaw(signatureMetadata, commonArguments.URL, unixTimestamp, "post"), - headersInfo: new WebRequestHeadersInfo().WithSign(signatureMetadata, unixTimestamp) - ); - } - /// /// Make a generic get request to download arbitrary data /// diff --git a/Explorer/DCL.CameraReelStorageService.csproj.DotSettings b/Explorer/DCL.CameraReelStorageService.csproj.DotSettings new file mode 100644 index 0000000000..5ffcf67001 --- /dev/null +++ b/Explorer/DCL.CameraReelStorageService.csproj.DotSettings @@ -0,0 +1,2 @@ + + False \ No newline at end of file From b858f2bac3561c8552e14360d62a1cffe7addfd2 Mon Sep 17 00:00:00 2001 From: lorenzo-ranciaffi <41125365+lorenzo-ranciaffi@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:16:51 +0100 Subject: [PATCH 23/24] fix: disable scene restriction toast while invisible in order to unblock quest tracker button (#2685) --- Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs | 3 ++- Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs b/Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs index 2de60c025e..a87ac10b75 100644 --- a/Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs +++ b/Explorer/Assets/DCL/Minimap/SceneRestrictionsController.cs @@ -52,6 +52,7 @@ public void Dispose() private void OnMouseEnter() { + restrictionsView.ToastCanvasGroup.gameObject.SetActive(true); Vector3 toastPosition = restrictionsView.ToastRectTransform.anchoredPosition; toastPosition.x = restrictionsView.SceneRestrictionsIcon.transform.localPosition.x - (restrictionsView.SceneRestrictionsIcon.rect.width * TOAST_X_POSITION_OFFSET_ICON_WIDTH_SCALER); restrictionsView.ToastRectTransform.anchoredPosition = toastPosition; @@ -59,7 +60,7 @@ private void OnMouseEnter() } private void OnMouseExit() => - restrictionsView.ToastCanvasGroup.DOFade(0f, restrictionsView.FadeTime); + restrictionsView.ToastCanvasGroup.DOFade(0f, restrictionsView.FadeTime).OnComplete(() => restrictionsView.ToastCanvasGroup.gameObject.SetActive(false)); private void ManageSceneRestrictions(SceneRestriction sceneRestriction) { diff --git a/Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs b/Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs index 47abbcc6f7..8f8821796d 100644 --- a/Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs +++ b/Explorer/Assets/DCL/Minimap/SceneRestrictionsView.cs @@ -44,6 +44,7 @@ public class SceneRestrictionsView : MonoBehaviour, ISceneRestrictionsView private void Awake() { ToastCanvasGroup.alpha = 0; + ToastCanvasGroup.gameObject.SetActive(false); SceneRestrictionsIcon.gameObject.SetActive(false); ToastRectTransform = ToastCanvasGroup.GetComponent(); } From fead903b956d11d1695d48f117c0d3a9c6c2b525 Mon Sep 17 00:00:00 2001 From: davidejensen Date: Mon, 4 Nov 2024 13:01:43 +0100 Subject: [PATCH 24/24] fix: fixed suppress error in satellite map chunk download (#2704) --- .../Atlas/SatelliteAtlas/SatelliteChunkController.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Explorer/Assets/DCL/MapRenderer/MapLayers/Atlas/SatelliteAtlas/SatelliteChunkController.cs b/Explorer/Assets/DCL/MapRenderer/MapLayers/Atlas/SatelliteAtlas/SatelliteChunkController.cs index 29f44d6aec..929aee1953 100644 --- a/Explorer/Assets/DCL/MapRenderer/MapLayers/Atlas/SatelliteAtlas/SatelliteChunkController.cs +++ b/Explorer/Assets/DCL/MapRenderer/MapLayers/Atlas/SatelliteAtlas/SatelliteChunkController.cs @@ -2,6 +2,7 @@ using Cysharp.Threading.Tasks; using DCL.Diagnostics; using DCL.MapRenderer.ComponentsFactory; +using DCL.Utilities.Extensions; using DCL.WebRequests; using DG.Tweening; using System.Threading; @@ -64,10 +65,10 @@ public async UniTask LoadImageAsync(Vector2Int chunkId, float chunkWorldSize, Ca atlasChunk.MainSpriteRenderer.color = INITIAL_COLOR; var url = $"{CHUNKS_API}{chunkId.x}%2C{chunkId.y}.jpg"; - Texture2D texture = (await webRequestController.GetTextureAsync(new CommonArguments(URLAddress.FromString(url)), - new GetTextureArguments(false), GetTextureWebRequest.CreateTexture(TextureWrapMode.Clamp, FilterMode.Trilinear) - .SuppressExceptionsWithFallback(Texture2D.whiteTexture, reportContext: ReportCategory.UI), - linkedCts.Token, ReportCategory.UI))!; + var textureTask = webRequestController.GetTextureAsync(new CommonArguments(URLAddress.FromString(url)), + new GetTextureArguments(false), GetTextureWebRequest.CreateTexture(TextureWrapMode.Clamp, FilterMode.Trilinear), + linkedCts.Token, ReportCategory.UI); + var texture = await textureTask!.SuppressExceptionWithFallbackAsync(Texture2D.whiteTexture, SuppressExceptionWithFallback.Behaviour.SuppressAnyException, reportData: ReportCategory.UI)!; textureContainer.AddChunk(chunkId, texture);