How do I create the center of TouchScreenButton texture in the center of the TouchScreenButton position along with it's shape?

Viewed 215

So, if I create a button using TouchScreenButton and assign a texture to it, the texture will be displayed on the left bottom of the TouchScreenButton position (See image below)

enter image description here

The TouchScreenButton position is in the top left corner of the rectable

When I don't assign a texture and instead I create a sprite as the child node and assign a texture to it, it will display the texture in the center of TouchScreenButton.

enter image description here

But the shape is still follows what I have said earlier.

My question, How do I create the center of TouchScreenButton texture in the center of the TouchScreenButton position along with it's shape? I want the TouchScreenButton is in the middle of the TouchScreenButton texture.

1 Answers

Solution 1. Go to your Sprite node and in the inspector disable Centered property in the offset section. This way though you should keep sprite and shape sizes for centers of the area and the texture to match, coz now both the Sprite and Shape will be to the right bottom of the origin coordinates of the button.

Solution 2. Go to your TouchScreenButton node and in the inspector enable Shape Centered property in the main section. This way you will make both the shape and the sprite to be centered in the origin of the button.

Related