- Home /
Getting the sprite borders from a Texture2D?
I'm making a little tool to make my life easier when it comes to spritesheets. In order to get it working I would like to get the positions and borders and maybe pivots that are generated when slicing a spritesheet so I can use them to modify the sprites through scripting.
Since this is a tool I'm fine with using UnityEditor, I'm just unaware of how I could achieve this. I've been unable to figure it out even after a lot of googling! I figured that since these values were already generated by the SpriteEditor it would be easier to grab those than to try and generate them myself
TLDR: How do I get the positions/borders/pivots from a multi-sprite texture.
Thanks for taking a look at this post, please let me know if you have any solutions!
Answer by FlaSh-G · May 06, 2020 at 04:17 AM
I haven't tested it, but I think you should be able to get the sprites of a texture asset by using AssetDatabase.LoadAllAssetsAtPath, as sprites are imported as child assets of the texture asset.
This was part of the solution. The data I was looking for was stored in Sprite.textureRect and Sprite.pivot. I loaded the Texture2D in using your method, then cycled through the Sprites to get this data! Thank you!
Your answer
Follow this Question
Related Questions
Help with Custom Editor GUIStyle - Loading custom textures from Resources 0 Answers
Compressing in OnPostprocessTexture yields "Not yet compressed" 1 Answer
Request Help: Sprite Editor not Automatically Slicing Sprite Sheet 0 Answers
Texture2D on Property Drawers. 0 Answers
Very bad slicing of a sprite sheet... 0 Answers