- Home /
Problem with Aligning and Scaling of UI Elements
HI, I am making a game with pixel art UI. I am trying to make an inventory and want to use the grid layout to align images to the background sprite. I am using the right values, but it seems all the images are off by a tiny amount
When I change the value it seems that they snap to something and I can't ever get them to align. Bellow you can see a close up that shows that the container that houses the image is off a tiny amount form the background, and the image component itself is off from the containing gameobjects boundaries.
Does anyone know what causes this? Also, I have observed that when instantiating prefabs and duplicating objects changes the alignment and scale by a tiny amount. I don't think it's relevant to this issue, but It's frustrating anyway. And finally, I am using a canvas scaler with "scale with screen size" and "Match Width or Height"
I wonder if adjusting your anchors and pivot would help. I usually set $$anonymous$$e to X:0 and Y:1 for both anchors and pivot point, that way the Top-Left corner is the position of the UI element and I can just specify width and height of it. Also, with pixil art in the UI, have you tried changing the texture's AND the canvas's pixil per unit to 1?
Your answer
