- Home /
Can I get the Cell X,Y from a sprite from a multi spritesheet?
First, some context:
I'm making a tiled based level editor tool in unity. I want to save my tiles to one large spritesheet, so I've created a texture containing 16x16 tiles, loaded it into unity and created a sprite with Sprite Mode: Multiple and slicing by pixel size. The editor works by grabbing all the sprites out of that texture, letting the user select one and paint the level with them. The problem lies in how do I go about saving which tile goes where?
I want to be able to save a level by making an object that says use this texture, and then has a 2D array containing which cell in the texture to use at that tile. The only problem is there doesn't seem to be a way to do this in Unity. Even getting all the sprites inside a multi sprite is cumbersome, requiring you to load every single sprite. To top it off, many of cells in my texture are empty and Unity automatically culls empty sprites. This means I cant use the index of the sprite array as that can change as I add more tiles to my texture.
I am almost certain I am going about this the wrong way. Is there a better approach to mapping a texture to a tile that doesn't require making hundreds of tile objects, or splitting the sprite sheet into individual sprites?
Your answer
![](https://koobas.hobune.stream/wayback/20220612133830im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D sprite renders a small part of another one with "Sprite Mode : Multiple" 0 Answers
How to double spirte/gameobject/prefab and control the result on those items? 0 Answers
two sided card that changes when flips 1 Answer
Is it possible to load Sliced Sprite (with .meta file) from OUTSIDE Packaged Data during runtime? 0 Answers