Skip to content

Conversation

@WMsans
Copy link
Contributor

@WMsans WMsans commented Dec 13, 2025

Added layer sorting option

The user can customize the layer order through the main panel.
https://github.com/user-attachments/assets/7c999c31-eb16-473d-a19e-ba6579c577fd

@Cammin
Copy link
Owner

Cammin commented Dec 13, 2025

Code looks nice! I'll give it some more review and pull it in when I get to it 🙂

@WMsans
Copy link
Contributor Author

WMsans commented Dec 13, 2025

Thank you! I just realized that I forgot to delete a Debug.log() in LDtkSortingOrder.cs (Apologize).
Thank you again for this project!

@Cammin
Copy link
Owner

Cammin commented Dec 17, 2025

I looked at this and gave it a big makeover and assimilated it into the importer UI and architecture. It has a dedicated section in the importer inspector:
image

I changed how it works so that the sorting orders still decrement by 1 per entity or tilemap so that orderings are accurate.
But for the configured custom values per layer, the sorting order value "jumps" to a new number. Let me know if you think this has problems or defeats the purpose of the intent. But it feels like what is right is to cover as many various cases as possible.
Or I could offer another configurable value for this. Like maybe a ForceStrictValues option?

And to that end, I made the default values be in -500 increments.
Also, the array resizing is using the same system that the intgrid tiles and entities use, so that the entries are remembered more smartly if the definitions were to resize or change :)

I will make a push to this PR, and hopefully it shows up. I'm still learning when it comes to this stuff. Let me know what you think about it all once it shows up.

LDtkSortingOrder:
image

@Cammin
Copy link
Owner

Cammin commented Dec 17, 2025

I looked more into how the values decrement, and I think that I made a flaw in my observations. I assumed that the sorting order would decrement more than once per layer, because it used to do that in the far past.
But actually, the value decrements only once per layer occurrence. So it's simpler than I thought it would be, both in my documentation and in execution.
I'd like to talk to you over on the importer's discord about it if you have lots of feedback to talk about

@Cammin
Copy link
Owner

Cammin commented Dec 17, 2025

Check out this branch i pushed to. it works off of your own commit:
https://github.com/Cammin/LDtkToUnity/tree/pr/67

Give me feedback, and if it seems good, i'll merge it in!

@Speaker-Hornet
Copy link

Haven't checked the code, but this feature seems super useful! Does this sorting also include sorting layer or just the sorting number?

@WMsans
Copy link
Contributor Author

WMsans commented Dec 17, 2025

Hi,
I just imported the branch into my project and it worked smoothly, since the whole purpose is to allow the integer layer's auto layer to show in front of water:
image
image

The refactor code is a lot nicer than mine since I'm not familiar with Unity Editor stuff.
Thank you again for this project!

@Cammin
Copy link
Owner

Cammin commented Dec 17, 2025

@Speaker-Hornet

Haven't checked the code, but this feature seems super useful! Does this sorting also include a sorting layer or just the sorting number?

That's a good question; it only affects the number, but it might be convenient if the sorting layer can also be specified. The conflict, though, is that intgrid tile assets can have a sorting layer set also, so one would have to take precedence.

@WMsans
Awesome, I'll merge it in!
I might make the default values back to increments of -1 like you had, since there doesn't need to be a gap like I originally thought.
I've been pondering how to approach this feature for a long time, but didn't know how to do it right, but your pr helped push me in the right direction :)

There are other ponderings related to this for a menu that lists all layers, like a material field, a sorting layer field, etc. It would be great, but it would be a UI challenge to keep it clean

@WMsans WMsans closed this by deleting the head repository Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants