Which are the corresponding parameters for rect and pivot in exporting an editor defined sprite, to be re-created using Sprite.Create?

Which are the corresponding parameters for rect and pivot in exporting an editor defined sprite, to be re-created using Sprite.Create?

I've tried both .rect and .textureRect for storing the editor defined rect for a sprite and also .pivot, but it seems Sprite.Create is not able to re-create the sprite properly(?)

• What sprite are you trying to recreate, how are you trying to recreate it, and how do the results you get differ from what you get in-editor? Show us screenshots and code that demonstrate your problem. Sep 26 '21 at 11:21
• it appears to be a unit mismatch between sprite.pivot and the pivot used in Sprite.Create
– ina
Sep 27 '21 at 7:43

It appears that Sprite.Create takes a non-pixel based unit value for pivot and sprite.pivot is a pixel based unit.

For example, sprite.pivot for a (1000x500) image would be (500,250) but Sprite.Create wants (0.5,0.5)

• Helpfully, this is explicitly described in the documentation: "The third argument pivot determines what becomes the center of the Sprite. This is a Vector2 relative to the rect where Vector2(0.0f, 0.0f) is the bottom left and Vector2(1.0f, 1.0f) is the top right." Sep 27 '21 at 11:14
• sprite.pivot should be in the same units
– ina
Sep 28 '21 at 8:24
• Not according to the documentation: "Location of the Sprite's center point in the Rect on the original Texture, specified in pixels" Sep 28 '21 at 11:49
• well, this discrepancy is quite annoying
– ina
Sep 30 '21 at 0:28
• Don't forget to mark your answer as Accepted if it worked for you. Oct 27 '21 at 12:11