From dea8e6f4a61f3179f9e200062f33a36798aaf1ef Mon Sep 17 00:00:00 2001 From: Andy Baker Date: Fri, 6 Dec 2024 11:30:55 +0000 Subject: [PATCH] Add a null check --- .../api_clients/assets_service_client/AssetsServiceClient.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/api_clients/assets_service_client/AssetsServiceClient.cs b/Assets/Scripts/api_clients/assets_service_client/AssetsServiceClient.cs index dff6a1b1..7f294bbb 100644 --- a/Assets/Scripts/api_clients/assets_service_client/AssetsServiceClient.cs +++ b/Assets/Scripts/api_clients/assets_service_client/AssetsServiceClient.cs @@ -355,7 +355,7 @@ public static bool ParseAsset(JToken asset, out ObjectStoreEntry objectStoreEntr objectStoreEntry.title = asset["displayName"].ToString(); objectStoreEntry.author = asset["authorName"].ToString(); objectStoreEntry.createdDate = DateTime.Parse(asset["createTime"].ToString()); - objectStoreEntry.cameraForward = GetCameraForward(asset["presentationParams"]["orientingRotation"]); + objectStoreEntry.cameraForward = GetCameraForward(asset["presentationParams"]?["orientingRotation"]); return true; } @@ -372,6 +372,7 @@ public static bool ParseAsset(JToken asset, out ObjectStoreEntry objectStoreEntr /// A string of three float values separated by spaces that represent the camera forward. private static Vector3 GetCameraForward(JToken cameraParams) { + if (cameraParams == null) return Vector3.zero; JToken cameraMatrix = cameraParams["matrix4x4"]; if (cameraMatrix == null) return Vector3.zero; // We want the third column, which holds the camera's forward.