Search Unity

[UIBuilder] How to inheret pixel size of background image?

Discussion in 'UI Toolkit' started by TextusGames, Oct 7, 2019.

  1. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    429
    Is there a way?
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    We have the
    Image
    element for this but the UIBuilder does not currently support this element. You'd have to add it in code. You can use a dummy
    VisualElement
    in the UIBuilder to mark where the
    Image
    element should go and then it should be pretty easy to swap it in C#. This is a temporary issue.

    But I'd encourage you to try not using auto-sizing elements for your images. It means that some of your layout is not described in USS but instead it comes from a random file. If you resave your image with a different size, you can break your UI's layout without knowing. It's usually better to have the UI drive the size of the images it uses. But I say this without knowing your exact use case. :)
     
    marcospgp and TextusGames like this.
  3. marcospgp

    marcospgp

    Joined:
    Jun 11, 2018
    Posts:
    194
    @uDamian Any plans as to when the Image element will be visible in the UI Builder? I basically use it to check which elements exist and can be used even if I'm building the UI in code.