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!

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.