Image Collections

Create issue
Issue #26 open
Nitneroc created an issue

Image Collections Tilesets don't seem to be supported. Importing a map with such a tileset results in an immediate error, so I guess this feature is just not implemented.

I recently discovered this feature in Tiled, and it's a must-have in my opinion, and it makes some things much easier, especially when you make something big (house or something) behind which characters can go (so that you have to turn on "Make Unique Tiles").

Do you think this could be added someday ?

Comments (12)

  1. Guilherme Augusto Almeida Filo Maia repo owner

    Hey, I somehow forgot about this feature!

    I'll sure implement it, but it is another tileset-loading method, where each tile has it's own reference to an image. Unless I manually build a texture containing those tiles, this feature would only be supported by unique tiles.

    To achieve what you mentioned (big structures with tiles where a sprite/player would be behind them) I suggest using different layers (a ground and a foreground layer for example), but I'm open to suggestions regarding other methods (being sincere, I didn't understand why supporting this feature would somehow impact cases like this you've mentioned)

  2. Nitneroc reporter

    I'm not sure I understand exactly the technical problem here. Such an image collection doesn't look like tiles to me, isn't it just a big texture ? When you paste such an Image Collection into Tiled it's pasted to a single tile of the layer (the bottom-left one), but the image collection will of course be wider and taller than this tile. So I'm not sure i understand what you mean with "manually build a texture containing those tiles"

    Sorry if I wasn't clear about my specific problem above, I guess my english doesn't help either. Here are some (hopefully) better explanations :


    The tree is 5 tiles high, and the monster on the right is 2 tiles high. I agree the top 3 tiles of the tree can be on my upmost layer, the monster should never be able to go in front of it. But the two lowest rows have to be on the same layer as the monster, and it's the sorting order that will deal with them. Ideally those two rows should have the same sorting order, otherwise this will happen :


    The monster is behind the trunk because it's y value is higher, but it's in front of the 2 row of tiles.

    Please correct me if I'm missing something here, I'd be really glad if I were wrong !

    I'm a hobbyist and I don't know much about Unity's internals, but if I can help in some ways, I'd be glad to

  3. Guilherme Augusto Almeida Filo Maia repo owner

    About the technical details, the problem is performance, since an image collection is simply a way to use multiple images as tiles, which in Unity would generate 1 draw call per image, but that's an implementation problem.

    With your visual explanation I understood the problem you are facing, and it is not related to image collections but to the sorting order calculation, that was mentioned by issue #24

  4. Nitneroc reporter

    OK, thanks for your explanations. You'd probably have to create a texture atlas with all those image collections... Or maybe we can live with this performance downside if there is no easy solution.

    I considered this problem related to image collection since having only one big gameobject for this tree would mean only one sorting order value.

    Thank you very much for your feedback

  5. Nitneroc reporter

    Or maybe, you could avoid this atlasing problem at the cost of some work for the user : Those imageCollections could have to be a single texture ( loaded with Sprites > Multiple mode ) and each individual ImageCollection should follow Unity's Sprite naming convention, ie : TextureName_Number. This way, loading all the imageCollections would be rather easy

    Sprite[] textures = Resources.LoadAll<Sprite>("ImageCollection");

    and individual imageCollections could be accessed by getting what's on the right of the last underscore as the id (texture[id]). This is probably bothersome (if it works, I'm sorry I can't try it myself), but it would save you the trouble of texture atlasing...

  6. Guilherme Augusto Almeida Filo Maia repo owner

    I believe this proposed solution requires the user to pack the images himself, at least only unity pro automatically packs images. I'll try to implement a simple texture packer, but if I see it is going to take too long, I'll include this feature in v2 by loading each image separately and update it as soon as I can.

  7. Guilherme Augusto Almeida Filo Maia repo owner

    Turns out Unity free version allows to use Texture2D.Pack :)

    This feature was implemented by 019d5eb (trunkDev, will merge it into Unity2D with the remaining v2 features - hexagonal support, specially objects' coordinates, is slowing me down :X)

  8. Guilherme Augusto Almeida Filo Maia repo owner

    Forgot to say: to use this feature you must set the images as read/write enabled by setting their Texture Type as Advanced (unity's limitation to use the packer...)

  9. Guilherme Augusto Almeida Filo Maia repo owner
    • changed status to open

    Will let this as Open while I don't merge it into main branch.

  10. Nitneroc reporter

    Amazing ! You're really doing a great work here, thank you very much. Good luck and keep up the good job you're doing

  11. Log in to comment