Cammin / LDtkToUnity

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

LDtkIntGridTile settings bug #28

Closed stickynoteme closed 2 years ago

stickynoteme commented 3 years ago

This seems like a bug.

In LDtk if you have 2 IntGrid Lyaers

Ground Water

and in unity you set these up to be:

Ground => LDtkIntGridTile_Ground Water => LDtkIntGridTile_Water

Then in LDtk you decide to add another IntGrid layer to the top:

Coulds_Oneway Ground Water

Then in unity you wind up with this:

Clouds => LDtkIntGridTile_Ground Ground => LDtkIntGridTile_Water Water => Default

Eg: All of your LDtkIntGridTile settings get offset and wind accounted with the wrong layers.

Cammin commented 3 years ago

Yeah, I understand why this bug in the importer inspector is happening. Behind the scenes, the IntGridValue ScriptableObjects that are assigned in the importer inspector are an array. When a new layer is introduced in LDtk, this array resizes and might end up shifting around the values due to the assigned fields maintaining the same array indexes.

A solution I was thinking of exploring to solve this is to detect an array resize, and see if we can shift around indexes to maintain proper assignments by correlating matching identifiers.

It's something I'll prioritise more now, thanks for letting me know 🙂

Cammin commented 3 years ago

Array index bug when inserting a new layer in LDtk

Cammin commented 2 years ago

I got onto this old bug. The next update should have this fixed. Adding/removing int grid value defs and entity defs should now be super reliable, and not shift indexes. Also, newly introduced values are now null as expected (Previously they would start out as the last object assigned). I'll notify here when the update is out in this issue before closing it 👍

Cammin commented 2 years ago

There was a new update earlier today that addressed this. Feel free to reopen the issue if you still have an issue with this particular bug.