Skip to content

Commit 3e915d4

Browse files
authored
Hotfix: NullRef for screenshots in worlds (#5647)
## What does this PR change? Fixes: On desktop pictures taken with Camera Mode are not saved when taken in a World (`NullReferenceExpection` appears in the console). Does not occur on catalyst realms ## How to test the changes? 1. Take screenshot in World 2. Observe it is loaded to Camera Reel ## Our Code Review Standards https://github.com/decentraland/unity-renderer/blob/master/docs/code-review-standards.md ## Copilot summary <!-- copilot:summary --> ### <samp>🤖 Generated by Copilot at 847d8f7</samp> Enhance `ScreenshotMetadata` class with new properties, better scene name logic, and simplified variables. This improves the readability and consistency of the code that handles screenshot metadata.
1 parent d54f0c4 commit 3e915d4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

unity-renderer/Assets/DCLServices/CameraReelService/ScreenshotMetadata.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public class ScreenshotMetadata
1717
public Scene scene;
1818
public VisiblePerson[] visiblePeople;
1919

20+
private static bool isWorld => DataStore.i.common.isWorld.Get();
21+
private static string realmName => DataStore.i.realm.realmName.Get();
22+
2023
public static ScreenshotMetadata Create(DataStore_Player player, IAvatarsLODController avatarsLODController, Camera screenshotCamera)
2124
{
2225
Player ownPlayer = player.ownPlayer.Get();
@@ -27,10 +30,10 @@ public static ScreenshotMetadata Create(DataStore_Player player, IAvatarsLODCont
2730
userName = UserProfileController.userProfilesCatalog.Get(ownPlayer.id).userName,
2831
userAddress = ownPlayer.id,
2932
dateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(),
30-
realm = DataStore.i.realm.realmName.Get(),
33+
realm = realmName,
3134
scene = new Scene
3235
{
33-
name = MinimapMetadata.GetMetadata().GetSceneInfo(playerPosition.x, playerPosition.y).name,
36+
name = isWorld? $"World {realmName}" : MinimapMetadata.GetMetadata().GetSceneInfo(playerPosition.x, playerPosition.y).name,
3437
location = new Location(playerPosition),
3538
},
3639
visiblePeople = GetVisiblePeoplesMetadata(
@@ -45,11 +48,9 @@ private static VisiblePerson[] GetVisiblePeoplesMetadata(List<Player> visiblePla
4548
var visiblePeople = new VisiblePerson[visiblePlayers.Count];
4649
UserProfileDictionary userProfilesCatalog = UserProfileController.userProfilesCatalog;
4750

48-
UserProfile profile;
49-
5051
for (var i = 0; i < visiblePlayers.Count; i++)
5152
{
52-
profile = userProfilesCatalog.Get(visiblePlayers[i].id);
53+
UserProfile profile = userProfilesCatalog.Get(visiblePlayers[i].id);
5354

5455
visiblePeople[i] = new VisiblePerson
5556
{

0 commit comments

Comments
 (0)