mapeditor/tiled

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Scripting: Assigned map.selectedLayers displays incorrectly #3451

eishiya posted onGitHub

When assigning to TileMap.selectedLayers, if the assigned array has its layers in any order other than ascending by layer ID and doesn't contain every layer in the map, the layers will be selected, but the Layers panel will only highlight the bottom-most layer. I confirmed that the layers were selected via Highlight Current Layer, and via tiled.activeAsset.selectedLayers.

Here for example, I selected all "Invalid" layers via script, in order from bottom to top (the same order they appear in map.layers). The layers are sorted by their ID (which I've added to their layer name, for convenience), so everything is highlighted correctly: image But here, I've switched layers 2 and 3, so they're no longer in ascending order, and thus only the bottom-most selected layer is highlighted (but all three layers are actually selected): image

Sorting the layers prior to assigning to map.selectedLayers works to correctly highlight all layers regardless of order:

invalidLayers.sort(function(a,b) {return a.id - b.id;});
map.selectedLayers = invalidLayers;

Selecting every layer in the map also highlights the layers correctly, regardless of their order in the array.


Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests