Cammin / LDtkToUnity

Unity importer for the LDtk level editor
https://cammin.github.io/LDtkToUnity
MIT License
388 stars 39 forks source link

Failed to unmarshal type TileRenderMode #4

Closed sammysheardev closed 3 years ago

sammysheardev commented 3 years ago

Not sure what to do with this error. I figured I would try out ldtk for my newest game, but I can't seem to get it working because of this exception.

Cammin commented 3 years ago

Hi, thanks for letting me know about this, I'll look into it. :)

What sort of steps did you take so that this happens? It is much appreciated If you can send me some reproduction steps. Also, see about sending me the entire error in the console log.

sammysheardev commented 3 years ago

I created a new project in Ldtk, put it in the unity game's directory, created a new project asset, but it fails to set the project file field to the actual project file. If I'm missing something obvious please let me know! I have not checked with a different project file to see if I could reproduce it, but I might try that. The full error is a bit long, but here it is:

Exception: Cannot unmarshal type TileRenderMode LDtkUnity.TileRenderModeConverter.ReadJson (Newtonsoft.Json.JsonReader reader, System.Type t, System.Object existingValue, Newtonsoft.Json.JsonSerializer serializer) (at Library/PackageCache/com.cammin.ldtkunity@1.2.15/Runtime/Data/Schema/Converter/TileRenderModeConverter.cs:21) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable (Newtonsoft.Json.JsonConverter converter, Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Object existingValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2175) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:1035) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2415) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:493) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:300) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (System.Collections.IList list, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:1697) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:877) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:302) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:1039) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2415) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:493) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:300) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:1039) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2415) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:493) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:300) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:202) Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at /root/repo/Src/Newtonsoft.Json/JsonSerializer.cs:907) Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at /root/repo/Src/Newtonsoft.Json/JsonSerializer.cs:886) Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) (at /root/repo/Src/Newtonsoft.Json/JsonConvert.cs:837) Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) (at /root/repo/Src/Newtonsoft.Json/JsonConvert.cs:792) LDtkUnity.LdtkJson.FromJson (System.String json) (at Library/PackageCache/com.cammin.ldtkunity@1.2.15/Runtime/Data/Schema/LdtkJson.cs:125) LDtkUnity.UnityAssets.LDtkProjectFile.get_FromJson () (at Library/PackageCache/com.cammin.ldtkunity@1.2.15/Runtime/UnityAssets/Json/LDtkProjectFile.cs:7) LDtkUnity.Editor.LDtkProjectEditor.AssignJsonField (UnityEditor.SerializedProperty textProp) (at Library/PackageCache/com.cammin.ldtkunity@1.2.15/Editor/CustomInspector/LDtkProjectEditor.cs:221) LDtkUnity.Editor.LDtkProjectEditor.ShowGUI () (at Library/PackageCache/com.cammin.ldtkunity@1.2.15/Editor/CustomInspector/LDtkProjectEditor.cs:47) LDtkUnity.Editor.LDtkProjectEditor.OnInspectorGUI () (at Library/PackageCache/com.cammin.ldtkunity@1.2.15/Editor/CustomInspector/LDtkProjectEditor.cs:20) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <b45c30541531431286ef0e6e52b4f09c>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

sammysheardev commented 3 years ago

Just to confirm, this occurs when I try using the sample 2d platformer from Ldtk as well.

sammysheardev commented 3 years ago

Just a little addendum to the issue, when using any of the ldkt files from the samples for the package, it runs perfectly, which makes me think it's something wrong with the actual ldkt file. Is it possible it is a version conflict?

Cammin commented 3 years ago

Yeah, that's correct now that I think about it. LDtk version incompatibilities would be the reason. LDtk has been receiving plenty of updates with new types of values (particularly enums in this case), and the JSON deserializer may be trying to get a new enum value that was not set up for this package's version. A massive update is on its way that may fix this. Just making sure it's stable and works correctly. 👍

Tons of reworks for a simpler experience, cleanup, updated to newer ldtk project data, and the rework of building levels in edit mode instead of in runtime. The update should come pretty soon 😃

Cammin commented 3 years ago

I've seen this issue happen with someone else in the new major update. It's a Json deserialization issue, so I'll try updating the json schema files from 0.8.0 to 0.8.1

Cammin commented 3 years ago

Yes, it was a bug due to outdated JSON schema files. All good. Going forward, I'll try to update the JSON schema files ASAP when there is a new update to LDtk. 👍 image