I wonder what the difference between Sprite.rect and Sprite.textureRect is?
According to the documentation:
rect - Location of the Sprite on the original Texture, specified in pixels.
textureRect - Get the rectangle this sprite uses on its texture. Raises an exception if this sprite is tightly packed in an atlas.
I’m a bit unsure what that atlas thing is, but since it’ll throw an exception if it’s in one, and since rect returns the rectangle from the original texture, it seems to me that they both return the same thing?
If you have e.g. 4 separate textures which are supposed to be used as sprites, Unity may combine those textures into just one texture, the texture atlas. Under the assumption that those are specified to be rectangular and not tightly packed, you are going to get different results for rect and textureRect.
The results will only be different after the texture atlas was actually created.
Ah, ok. Hmm… I take it that Unity only do the combining when creating an executable? The result from calling .rect or textureRect will always be the same when working in editor mode, as long as we don’t do any atlasing ourselves?