Unity 4.6 - UI button to sprite size

Hi all,

I’m having a bit of trouble with the UGUI system. I’m building a 2D game with a board made up of squares. Each square has a 40-pixel sprite. I’d like to be able to instantiate buttons that are exactly the size of the board squares.

To achieve that, I created a new 40-pixel sprite for the buttons. In testing, I’ve found that the buttons work correctly . . . but they’re too big. It’s as though 40 pixels for the UI system is bigger than 40 pixels for a gameobject.

I can resize the buttons by hand, but I end up with an inexact fit. Is there a way to force a UI button to match the size of its sprite?

For reference, my settings:

44635-settings1.jpg

Each individual button has RescueLocation as its sprite. Any help appreciated!

Try to set the Canvas Scaler (script) to a fixed screen resolution “scale with screen size” and set the pixels per unity back to 100. I think this should help.

I figured out the solution.
My sprite pixel per unit was set to 190, while my Canvas reference pixel per unit was 100.
If they are set to the same number, the Button will have the same sprite size.