Button to the same size as text at runtime

Hi, I was wondering how would I go about in doing a button change to the size of the text.
Imgur
See in the image how the buttons are bigger than the text. I want the button the same size as the text just like that hidden object game stater on the asset store. I’m not doing any scripts I am just using Adventure creator to make this game. I have gone through the manual but it hasn’t worked or maybe I just didn’t understand it.
https://docs.unity3d.com/Manual/HOWTO-UIFitContentSize.html
Any help would be much appreciated.

I achieved the results I think you want in a simple test:
On the button, do these…

  1. add a horizontal layout component. (include any padding you’d like)
    1b) set middle centre + child controls size (width & height) + uncheck the other 2.
  2. add a content size fitter with width = preferred size.
1 Like

Na that didn’t work it just stretched my button out so I can’t resize it.
Imgur
Every time I use content size fitter on the button it does this but if I use content size fitter on the text it encloses the text like it should but it just makes my button larger instead.

Strange, did you remove the content size fitter (if you had one) from the text, before trying my solution?
I just double checked and it’s working perfectly for me.

Yeah, I removed it first before doing your solution. I tried with just the proper UI button and that works but it doesn’t with my image I am using which is strange.
Imgur
The top button is using UISprite without padding but when I use the Blue cartoon UI it stretches out.

Ah okay, sorry I’m not sure how I would test that? :slight_smile:

I worked it out now thanks for the help it was a very simple thing I had the button set to simple instead of sliced.

Ah, great. Glad ya fixed it. :slight_smile: