Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Scale sliced frame (decrease pixel per unity multiplier)

Discussion in 'UI Toolkit' started by SunnyValleyStudio, Dec 15, 2021.

  1. SunnyValleyStudio

    SunnyValleyStudio

    Joined:
    Mar 24, 2017
    Posts:
    67
    Hi!
    Is there an option like Pixel Per Unit Multiplier (in the previous ui system) to scale the 9-sliced frame that is too small?

    upload_2021-12-15_11-10-44.png

    In the previous system I used to decrease the Pixel Per Unit Multiplier to make the frame bigger (more visible)

    The sprite is sliced in the sprite editor (I get the same result of small frame when using the slice parameter from UIToolkit)

    I thought that there might be some css value but I'm not great with css just yet and in the UCSS documentation there is no indication of such parameter.

    Here is css:

    .hotbar {
    flex-direction: row;
    background-image: url('project://database/Assets/_Art/Dungeon%20UI/dungeonui.v1.png?fileID=1477132345&guid=8923ac6c9fb9a3e4eb3cf84c75d4ad5e&type=3#dungeonui.v1_10');
    margin-left: 5px;
    margin-right: 5px;
    margin-top: 5px;
    margin-bottom: 5px;
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
    -unity-background-scale-mode: scale-to-fit;
    -unity-slice-left: 0;
    -unity-slice-top: 0;
    -unity-slice-right: 0;
    -unity-slice-bottom: 0;
    flex-grow: 0;
    -unity-background-image-tint-color: rgb(255, 255, 255);
    background-color: rgb(144, 130, 130);
    scale: 1 1;
    }


    Thanks!
    -Peter
     
    Last edited: Dec 15, 2021
  2. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    183
    Unfortunately the only USS properties that can be used are the -unity-slice-* ones. I will ask around if the Pixel Per Unity Multiplier is available and used in UI Toolkit.
     
    SunnyValleyStudio likes this.
  3. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    970
    There's a fix coming in 2022.2 to apply the pixel-per-unit multiplier on VisualElement slices.
     
    SunnyValleyStudio likes this.
  4. SunnyValleyStudio

    SunnyValleyStudio

    Joined:
    Mar 24, 2017
    Posts:
    67
    Thanks a lot for the help!
     
  5. MrAkroMenToS

    MrAkroMenToS

    Joined:
    Nov 16, 2013
    Posts:
    41
    I also hit this roadblock, @mcoted3d thanks for the update! 2022.2 is a bit far away, what other alternatives do we have until it drops?

    There are a couple of (reasonable) suggestions in this thread: https://forum.unity.com/threads/how...fore-applying-9-slicing.1178857/#post-7549165
    - Use two elements outer (used for positioning), inner (used for visuals, this is a scaled 9-sliced sprite)
    - Scale the image to the final pixel size during design time.

    I'm going to assume that using the properly scaled image is the only real and nice solution we have until 2022.2, am I right?