From 9122ec1a763250b1f3d9c67731519005de3d33ca Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 23 Oct 2023 01:00:20 -0700 Subject: [PATCH] fixed bug for deserialize attempt on a blank project containing nullable values --- Assets/LDtkUnity/CHANGELOG.md | 2 ++ Assets/LDtkUnity/Runtime/Data/Extensions/LdtkJson.cs | 2 +- Assets/LDtkUnity/Runtime/Data/Schema/LdtkJson.cs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Assets/LDtkUnity/CHANGELOG.md b/Assets/LDtkUnity/CHANGELOG.md index 85edc5075..1bbc56cf8 100644 --- a/Assets/LDtkUnity/CHANGELOG.md +++ b/Assets/LDtkUnity/CHANGELOG.md @@ -18,6 +18,8 @@ - Updated docs to instruct that a texture should be RGBA32 compression - Made the LDtkComponentLayer ordered before the LDtkIid component - Fixed a possible exception during initialization of LDtkFields +- Fixed a deserialize exception when making a blank LDtk project whereby `defaultEntityWidth` and `defaultEntityHeight` are null when they shouldn't be + - This is a temporary measure and LDtk will fix this problem for LDtk 1.5 ### Breaking Changes - Removed the "De-parent in Runtime" feature from the project importer diff --git a/Assets/LDtkUnity/Runtime/Data/Extensions/LdtkJson.cs b/Assets/LDtkUnity/Runtime/Data/Extensions/LdtkJson.cs index 6e521b711..4574b9bfa 100644 --- a/Assets/LDtkUnity/Runtime/Data/Extensions/LdtkJson.cs +++ b/Assets/LDtkUnity/Runtime/Data/Extensions/LdtkJson.cs @@ -24,7 +24,7 @@ public partial class LdtkJson : ILDtkIid /// /// Default size for new entities /// - [IgnoreDataMember] public Vector2Int UnityDefaultEntitySize => new Vector2Int(DefaultEntityWidth, DefaultEntityHeight); + [IgnoreDataMember] public Vector2Int UnityDefaultEntitySize => DefaultEntityWidth != null && DefaultEntityHeight != null ? new Vector2Int(DefaultEntityWidth.Value, DefaultEntityHeight.Value) : Vector2Int.zero; /// /// Default pivot (0 to 1) for new entities diff --git a/Assets/LDtkUnity/Runtime/Data/Schema/LdtkJson.cs b/Assets/LDtkUnity/Runtime/Data/Schema/LdtkJson.cs index db3d2921a..f1bec3ce2 100644 --- a/Assets/LDtkUnity/Runtime/Data/Schema/LdtkJson.cs +++ b/Assets/LDtkUnity/Runtime/Data/Schema/LdtkJson.cs @@ -76,13 +76,13 @@ public partial class LdtkJson /// Default height for new entities /// [DataMember(Name = "defaultEntityHeight")] - public int DefaultEntityHeight { get; set; } + public int? DefaultEntityHeight { get; set; } /// /// Default width for new entities /// [DataMember(Name = "defaultEntityWidth")] - public int DefaultEntityWidth { get; set; } + public int? DefaultEntityWidth { get; set; } /// /// Default grid size for new layers