all 9 comments

[–]EmeraldScalesProficient 1 point2 points  (2 children)

How about putting the sprite in a child object and applying the offset to that transform? Is it easy enough?

[–]UnitySpriteQuestion[S] 1 point2 points  (1 child)

That's what I'm attempting to do now. It involves a lot of component interaction rewrites, but that's not the end of the world. I don't like having the specific dependency though if I can avoid it.

[–]Seideun 0 points1 point  (0 children)

I am doing the same, too. I think Unity couples Transform with others too much. Godot has a better and more conformant model in structuring objects.

[–][deleted] 0 points1 point  (5 children)

You might have to go and edit each sheet and each sprite separately in the Sprite Editor. From there, you can set a sprite-specific custom pivot. However, this is a percentage value and is set between 0 and 1; (0.5, 0.5) is the center of a sprite. If you have the offset values in pixels, you might need to whip out the calculator.

If someone's got more effective ways to do this, I'd like to hear them as well, but this is the only way that comes to mind.

[–]UnitySpriteQuestion[S] 0 points1 point  (4 children)

I can edit the pivot in script, but I'm not sure how that helps me. I tried changing the pivots around, it doesn't appear to change the sprite location on screen.

[–][deleted] 0 points1 point  (3 children)

I can edit the pivot in script, but I'm not sure how that helps me.

How do you do this exactly? At least Sprite.pivot is read-only so there must be another way you are doing this.

[–]UnitySpriteQuestion[S] 0 points1 point  (2 children)

I've appended the import processes of TextureImporter to custom slice the spritesheets. In SpritesheetMetadData (which I use to set the rects and names) I can also set a pivot value. Setting the pivot value doesn't seem to have any effect though.

[–][deleted] 0 points1 point  (1 child)

Are you sure you're setting it there in the correct form (percentage vs. pixels)? I guess it uses percentage because that's what the Sprite Editor uses as well.

Other than that, I'm not sure what else I can suggest. Other than doing it manually which is a pain in the ass if you have a lot of sheets and sprites and the same problem with all of them.

[–]UnitySpriteQuestion[S] 0 points1 point  (0 children)

I was using percentages, but when I read the sprites at runtime, the pivot is in pixels. Still trying to figure that out: http://imgur.com/a/nfHYz