How do I access a texture slice's rect via scripting?

Hi, I need to get the rect with the coordinates for each of the slices in a texture that’s already been sliced in the sprite editor. Couldn’t find any reference to slices in the scripting docs. Is there a way to access those “sub-images” directly?

(I’m assuming here that those sub-images are kept in some sort of texture atlas, and what I need are the coordinates of those slices in the atlas).)


I figured it out. It’s pretty obvious, actually.

Sprite.rect returns a rectangle that points to the location (in pixels) relative to the original texture. To use it as 4 UV coordinates, one for each corner, simply divide rect.xMin (cast as a float) by the image’s width, rect.yMin by the image’s height, rect.xMax by the image’s width and rect.yMax + rect.height by the image’s height again.