- Home /
Sprite Renderer changes visible position on being assigned to a sprite
Hey All,
I already posted this on the unity forums, but realized this may be a better place for this.
I'm currently working on a high score screen for my game and have into a problem I can't quite understand. The system works by taking the player's picture at the start with the kinect camera, saving that as a PNG for later, and then loading that picture and all the others at the high score screen as a texture which is then used to create a sprite and assigned to a sprite renderer.
I have all the elements of the display score (the score, the rank, the background) and the picture grouped under the same object in the hierarchy at the correct ratio I want, however, as soon as I press play, the picture element (and only the picture element) jumps up to the left a few coordinates. The displayed picture itself and the actual transform object do this same jump. This happens with every single score object I've created, and only to this one object. Even stranger, when I look in the inspector as I edit the scene and after I press play, the position visibly jumps, but in terms of transform coordinates doesn't move at all. The jump also seems to increase with the size of the renderer if it has been changed. The jump does not occur when the picture is never assigned, so it seems that this would be the cause. All the other sprite renderers are also being assigned at runtime, but with static pre-created sprites.
I've tried creating the sprite differently, set the position of the object and sprite renderer to where they were before, and all combinations of things. To create the sprite, I'm using what I think is a standard rectrangle (0, 0, tex.width, tex.height) and a (0,0) pivot. I've combed my code and for anything that might be offsetting position and found nothing. I'd rather not use a manual calculated offset as I am about to hand it off to the designer I'm working with who will be changing size and might want to change other elements. Any idea why this is happening and how to fix it?
Thanks in advance for your help.
After a lot of tinkering, it may have something to do with pivot point, but I still haven't solved it. Could it potentially be a problem with pixel vs. world coordinates for the pivot?
Your answer
Follow this Question
Related Questions
How change sprite animation texture?? 2 Answers
Gui.Box - Sprite 0 Answers
Gui Box - Texture - Spritesheet 0 Answers
Sprite Renderer is wrapping bottom pixel when it shouldn't be 1 Answer
RGB16 Sprites flickers Bug. 2018.1.x 0 Answers