In this post, I will show how to scale background according to some text.

To make the background scale with text, follow the below steps:

  1. Make sure the Background and Text are in separate UI Objects.
  2. Nest the Text object inside the Background
  3. Add the following two components to the object with Background:
    Horizontal Layout Group and Content Size Fitter

Now the image will scale with the content inside it. Adjust the padding as needed.

Please leave a comment if there are better ways of doing this. Thank you!

Categories: Unity

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *