Skip to main content
added 118 characters in body
Source Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345
  1. Make sure the image is imported as an UI sprite. You might want to slice the image in 3x3 divisions to control how it stretches.
  2. Set the image as a background of a panel.
  3. Make the score text a child of the panel
  4. Add a content size fitter to the panel with "preferred fit" on horizontal and/or vertical (depending on which you want to adjust automatically, set to "Unconstrained" to switch off resizing on one axis).
  5. Add horizontal (or vertical) layout group to the panel. It doesn't matter which one, unless you add more than one child.

It will then adapt to the size of its child.

This technique is also described in the Unity manual under "UI -> UI How Tos -> Making UI elements fit the size of their content".

  1. Make sure the image is imported as an UI sprite. You might want to slice the image in 3x3 divisions to control how it stretches.
  2. Set the image as a background of a panel.
  3. Make the score text a child of the panel
  4. Add a content size fitter to the panel with "preferred fit" on horizontal and/or vertical (depending on which you want to adjust automatically, set to "Unconstrained" to switch off resizing on one axis).
  5. Add horizontal (or vertical) layout group to the panel.

It will then adapt to the size of its child.

  1. Make sure the image is imported as an UI sprite. You might want to slice the image in 3x3 divisions to control how it stretches.
  2. Set the image as a background of a panel.
  3. Make the score text a child of the panel
  4. Add a content size fitter to the panel with "preferred fit" on horizontal and/or vertical (depending on which you want to adjust automatically, set to "Unconstrained" to switch off resizing on one axis).
  5. Add horizontal (or vertical) layout group to the panel. It doesn't matter which one, unless you add more than one child.

It will then adapt to the size of its child.

This technique is also described in the Unity manual under "UI -> UI How Tos -> Making UI elements fit the size of their content".

added 118 characters in body
Source Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345
  1. Make sure the image is imported as an UI sprite. You might want to slice the image in 3x3 divisions to control how it stretches.
  2. Set the image as a background of a panel.
  3. Make the score text a child of the panel
  4. Add a content size fitter to the panel with "preferred fit" on horizontal and/or vertical (depending on which you want to adjust automatically, set to "Unconstrained" to switch off resizing on one axis). It will then adapt
  5. Add horizontal (or vertical) layout group to the size of its child(ren)panel.

It will then adapt to the size of its child.

  1. Make sure the image is imported as an UI sprite. You might want to slice the image in 3x3 divisions to control how it stretches.
  2. Set the image as a background of a panel.
  3. Make the score text a child of the panel
  4. Add a content size fitter to the panel. It will then adapt to the size of its child(ren).
  1. Make sure the image is imported as an UI sprite. You might want to slice the image in 3x3 divisions to control how it stretches.
  2. Set the image as a background of a panel.
  3. Make the score text a child of the panel
  4. Add a content size fitter to the panel with "preferred fit" on horizontal and/or vertical (depending on which you want to adjust automatically, set to "Unconstrained" to switch off resizing on one axis).
  5. Add horizontal (or vertical) layout group to the panel.

It will then adapt to the size of its child.

Post Undeleted by Philipp
Post Deleted by Philipp
added 141 characters in body
Source Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345
  1. SetMake sure the imageimage is imported as a background of a panelan UI sprite. You might want to slice the image in 3x3 divisions to control how it stretches.
  2. Set the image as a background of a panel.
  3. Make the score text a child of the panel
  4. Add a content size fitter to the panel. It will then adapt to the size of its child(ren).
  1. Set the image as a background of a panel. You might want to slice the image to control how it stretches.
  2. Make the score text a child of the panel
  3. Add a content size fitter to the panel. It will then adapt to the size of its child(ren).
  1. Make sure the image is imported as an UI sprite. You might want to slice the image in 3x3 divisions to control how it stretches.
  2. Set the image as a background of a panel.
  3. Make the score text a child of the panel
  4. Add a content size fitter to the panel. It will then adapt to the size of its child(ren).
Source Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345
Loading