Skip to content

Commit

Permalink
Add a null check
Browse files Browse the repository at this point in the history
  • Loading branch information
andybak committed Dec 6, 2024
1 parent d3bd8a8 commit dea8e6f
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -372,6 +372,7 @@ public static bool ParseAsset(JToken asset, out ObjectStoreEntry objectStoreEntr
/// <returns>A string of three float values separated by spaces that represent the camera forward.</returns>
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.
Expand Down

0 comments on commit dea8e6f

Please sign in to comment.