Search Unity

Official UI Toolkit 1.0-preview available

Discussion in 'UI Toolkit' started by benoitd_unity, Jul 8, 2020.

  1. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    The same was also said of ugui and after version 4.6 (2014) when it was released little else was known about new features or components other than fixes and very, very minor improvements to some components.

    The best thing that can happen to uitoolkit that is applicable to any Unity package is to be open source.
     
    Last edited: Mar 29, 2021
    Breathing, IOU_RAY and bashis like this.
  2. Kirsche

    Kirsche

    Joined:
    Apr 14, 2015
    Posts:
    121
    Please make this method public in VisualElement.cs. It's useful:

    private void MoveChildElement(VisualElement child, int currentIndex, int nextIndex)
     
  3. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    The way the API is set up today, you should use
    PlaceBehind(sibling)
    and
    PlaceInFront(sibling)
    . Any case we failed to cover with this API that motivated you to make this request? Thanks!
     
    Kirsche likes this.
  4. ltsc

    ltsc

    Joined:
    Mar 9, 2020
    Posts:
    4
    Hi guys. I loved UI toolkit but i guess it has still time to use on release builds. I had an issue with borders. I want to know if i am doing something wrong. Screenshot_1.png


    As you can see when i make radius higher number it starts to slice. Is there any way to make it smooth?
     
    Nexer8 likes this.
  5. Nexer8

    Nexer8

    Joined:
    Dec 10, 2017
    Posts:
    271
    They mentioned in a thread that they are working on a new way to render the elements, using signed distance fields. This would get rid the problem with the edges.
     
    MousePods and ltsc like this.
  6. Kirsche

    Kirsche

    Joined:
    Apr 14, 2015
    Posts:
    121
    Nope, your API is good enough already! But it would be nice to be able to move stuff around without having to worry about siblings:

    Code (CSharp):
    1. var index = container.IndexOf(visualElement);
    2. if (index == container.childCount - 1) return;
    3. var siblingIndex = index + 1;
    4. var sibling = container[siblingIndex];
    5. visualElement.PlaceInFront(sibling);
    Unity_hIaxtP4rCK.png
     
    Midiphony-panda and JuliaP_Unity like this.
  7. b4gn0

    b4gn0

    Joined:
    Jul 26, 2019
    Posts:
    119
    I had a similar problem when trying to mask the minimap (thread here: https://forum.unity.com/threads/how-to-show-a-renderer-texture.832402/ )
    Had to use vector images.
     
    ltsc likes this.
  8. Looping_co

    Looping_co

    Joined:
    Dec 10, 2016
    Posts:
    20
    Not sure if it's a bug or if I do something wrong.

    I use the Scale Mode "scale with screen size" and Screen Match Mode "Expand" with a Reference Resolution of 360 x 640.

    My UI document is then used in a 2436 x 1125 window. So it should not use the whole height of the screen. But my content is always stuck at the top of the screen (using Align/Justify Content/Top).

    Any idea?
    Thank you,
     

    Attached Files:

  9. DavidLe360

    DavidLe360

    Joined:
    Dec 24, 2018
    Posts:
    127
    Hi, thanks for the package.

    I have this error:

    Code (CSharp):
    1. The requested operation cannot be performed on a file with a user-mapped section open.
    2.         0 file(s) copied.
    3.  
    4.  
    (installed with: com.unity.ui)
    unity 2021.1.7f1, windows 10 64bit

    Tried to 'Reimport all', then unity editor was unable to open. It Unity.exe is in the task manger
     
    Last edited: May 27, 2021
  10. TeotiGraphix

    TeotiGraphix

    Joined:
    Jan 11, 2011
    Posts:
    145
    Naive Question: since Unity source code seems to be all over, is the source code for Label, Button in the UIElements framework online/opensource somewhere to study how to make low level custom components?
     
    Alex-Chouls and Nexer8 like this.
  11. dthurn

    dthurn

    Joined:
    Feb 17, 2015
    Posts:
    77
    Did something change about the layout algorithm in the 2021.2 version of UIToolkit? Upgrading from the package version in 2021.1, and some of my layouts are a few pixels off now. Using "scale with screen size" mode.
     
  12. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    547
    I have no idea what you're talking about. So the layout won't be adaptive? Will I need to create different layouts to different screen sizes?
     
  13. pjmei

    pjmei

    Joined:
    Mar 24, 2021
    Posts:
    2
    Hi, i'm new in the unity, i have take some lessons.
    I'm design for my studies a gallery, i need help for showing text near a object. i used the unitry script of gallery 3D, and works but i want something more beautiful, can you help, please?
    thanks
     
  14. angel_luis

    angel_luis

    Joined:
    Jun 26, 2016
    Posts:
    17
  15. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    I have unity 2021.1.11f1

    The UI Builder looks like is included with this version. I can open the UI editor create edit save.

    But how do I add it to the scene?

    Looking at tutorials on youtube they show a panel component/script called Panel Renderer. I don't have that. Also they have an option in the right click menu in the Scene view. Nothing there either.

    What is the deal with this?
     
  16. If I'm not mistaken in 2021.1 you still need to install the
    com.unity.ui
    package to gain access to runtime support. That only part of the engine in 2021.2.

    After that, add an empty game object, put a
    UI Document
    component on it and go from there.
     
    HugoBD-Unity likes this.
  17. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    That package is installed by default by unity.

    There is no Unity 2021.2 in unity hub, is only the beta one. I have enough problems with LTS versions of unity from 2019 and 2020. No way I mess with betas.

    So this new UI is pointless? We can't use it?
     
  18. I think you're mixing it up with
    com.unity.ugui
    which is the good ol' gameobject-based Unity GUI.
    As far as I know the UI Toolkit runtime is only in the engine in 2021.2 by default (which is currently in beta).

    I just told you, install the
    com.unity.ui
    package. If you want to use experimental stuff, you need to tinker, there is no way around it.
     
  19. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    doesn't work, I've tried adding the package using the name (it worked for progrids) this one doesn't work.

    downloading the newest version, we will see if this actually works. still don't understand why not including all the scripts
     
  20. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    Ok, this other version 2021.1.12f still doesn't have that script but this time adding the package by name as you have suggested worked and now I can add the UI to the scene.
     
  21. Just fired up a test in 2021.1, it is working for me. Exactly how I described.
    Because it is an experimental package and it will be part of the engine starting from 2021.2.
     
  22. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    it doesn't make sense to have the editor not be experimental and the game part experimental. Leave everything experimental and when ready release them. If one wants to check it will just download it.

    Like this is just to give the impression that you have it when you don't have it.

    Can you confirm that 2021.2 have the module out of the experimental stage? I mean, if you have this version installed. Just a curiosity, when will be ready for download I will check it
     
  23. If you would have taken the time to read the opening post in this very thread you would know why it is the case. The UI Builder and the in-editor support came first, so people could replace the IMGUI editor windows and property drawers with more advanced UI Toolkit-based ones. The runtime support is in-progress.
    It is built-in in 2021.2. It is still experimental (and beta, obviously), but you don't have to download anything in 2021.2, it's part of the engine.
     
  24. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    I'm asking because the 2021 versions that are not beta, don't have access to the experimental assets except by using the manual name as you have suggested. so if is there it must be at least in the "preview" stage.

    we will see in a few days
     
  25. angel_luis

    angel_luis

    Joined:
    Jun 26, 2016
    Posts:
    17
  26. angel_luis likes this.
  27. angel_luis

    angel_luis

    Joined:
    Jun 26, 2016
    Posts:
    17
    Why can't I edit the text input? The inspector is disabled.



    I just can edit the "filler text" label and change the font size in the root control. But I can't modify the background or the padding of the input.
     
    Last edited: Jun 24, 2021
  28. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Because that element is inserted by code at runtime. It is not something saved in the UXML document so no inline styles can be saved with it.

    You need to look at what style classes it use and then add your styling to those classes via USS (style sheet).

    example

    Code (CSharp):
    1. .unity-base-text-field {
    2.     white-space: nowrap;
    3.     --unity-selection-color: var(--color-primary-drk);
    4.     --unity-cursor-color: var(--color-primary-lit);
    5. }
    6.  
    7. .unity-base-text-field__input {
    8.     --unity-sync-text-editor-engine: true;
    9.     -unity-overflow-clip-box: content-box;
    10.     cursor: url('/Assets/GUI/Images/Cursors/text-32x32.png') 16 16;
    11.     flex: 1 1 auto;
    12.     padding: 0 5px;
    13.     height: 34px;
    14.     border-width: 1px;
    15.     border-radius: 3px;
    16.     border-color: var(--color-primary-drk);
    17.     background-color: var(--color-back-drk);
    18.     color: var(--color-txt-mid);
    19. }
    20.  
    21. .unity-base-text-field__input--single-line {
    22.     -unity-text-align: middle-left;
    23. }
    24.  
    25. .unity-base-text-field__input--multiline {
    26.     -unity-text-align: upper-left;
    27.     height: 100px;
    28.     white-space: normal;
    29. }
    30.  
    31. .unity-base-text-field__input:hover,
    32. .unity-base-text-field__input:focus,
    33. .unity-base-text-field:focus > .unity-base-text-field__input,
    34. .unity-base-text-field:hover > .unity-base-text-field__input {
    35.     border-color: var(--color-primary-mid);
    36. }
     
    angel_luis likes this.
  29. skazmierczak

    skazmierczak

    Joined:
    Feb 28, 2020
    Posts:
    9
    I'm having a hard time understanding the differences between the package version (available in 2020) and the built in 2021 version. I'm also not sure if this is supposed to be available on 2019 LTS? First post has no mention of 2019 support.
     
  30. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    331
    The package version will remain experimental and compatible with 2020 LTS and 2021.1, while the released and fully supported version is available in the core product in 2021.2.
     
  31. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,663
    Just to double-check, there will be no official release for 2020 LTS? So if we're developing an editor tool using UIToolkit for release, the minimum version would be 2021.2? Sorry if this has been covered elsewhere.
     
  32. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    398
    UIToolkit usage for editor workflows is available in unity 2019 LTS. UIToolkit for runtime usage is available using the preview package in 2020.3/2021.1 but comes in built-in with 2021.2.
     
  33. skazmierczak

    skazmierczak

    Joined:
    Feb 28, 2020
    Posts:
    9
    So if I'm on 2019, i can use UIToolkit for editor workflows but not have access to builder?


    2019 LTS
    - UIToolkit package for editor workflows

    2020 LTS
    - UIToolkit package for runtime
    - UIBuilder package

    2021
    - UIToolkit and UIBuilder built in
     
  34. Yakirbu

    Yakirbu

    Joined:
    May 7, 2015
    Posts:
    28
    Hi, any plans for RTL text support?
     
  35. oobartez

    oobartez

    Joined:
    Oct 12, 2016
    Posts:
    167
    @benoitd_unity After upgrading to 2021.2.0b7 we were finally able to enable Asian languages in our game and it no longer crashes which is great! Overall migrating from 2021.1 was relatively painless, it mostly consisted of adjusting our style sheets to the new default theme (we wish there was some "raw / minimal" theme).

    We have however hit another roadblock - typing in text fields does not work (case 1358063). It works with the default font, but the default font does not support Asian characters. As soon as we switch to a custom font using
    -unity-font-definition, it stops working - nothing happens when you type in a text field.

    Do you think that is something you would able to fix soon? It appears that that is the only thing stopping us from upgrading to 2021.2 beta.
     
  36. oobartez

    oobartez

    Joined:
    Oct 12, 2016
    Posts:
    167
    After further investigation it appears that the typing bug goes away after switching to Dynamic Atlas Population - not ideal but workable.
     
  37. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    331
    I believe the issue is still being triaged/verified. I'll follow-up once I have more informations.
     
  38. oobartez

    oobartez

    Joined:
    Oct 12, 2016
    Posts:
    167
    Just a quick update regarding case 1358063 (typing not working with static fonts). The bug has proven more troublesome than we thought. We can theoretically use dynamic fonts but those are a nightmare for the VCS - you end up with assets that are constantly changing when you play or build the game.
     
  39. HugoBD-Unity

    HugoBD-Unity

    Unity Technologies

    Joined:
    May 14, 2018
    Posts:
    499
    Hi @oobartez,

    We'll have a look at the case you logged. In the meantime, the "Clear Dynamic Data On Build" option on FontAsset resets the atlas every time you enter playmode, you build or close the Editor. Checking this option should help prevent polluting your VCS.
     
  40. oobartez

    oobartez

    Joined:
    Oct 12, 2016
    Posts:
    167
    @hugobd Thank you. We have "Clear Dynamic Data On Build" checked but it doesn't seem to work - the font assets change at random occasions. And people on our team regularly forget to roll them back before committing to git (and it's difficult to blame them).
     
  41. lookitsatravis

    lookitsatravis

    Joined:
    May 10, 2019
    Posts:
    4
    I'm suddenly getting this error today: "CS0246: The type or namespace name 'UIDocument' could not be found (are you missing a using directive or an assembly reference?)". I'm using 1.0.0-preview.17 inside Unity 2020.3.18f1 on macOS 10.15.7.

    My project builds successfully in Visual Studio, and all of the references I'm using to UIDocument work, and I'm able to use IntelliSense and all of that. But the Unity Editor presents that error during start up. The UIDocument components I have still kind of load, but none of the elements are visible. I can still click in the area of a button and see the debug log output for that button, but there is no button rendered on the screen.

    I've tried to uninstall UI Toolkit and UI Builder and reinstall them in Safe Mode which actually does make the error go away, but doesn't last through a restart, and doesn't fix the problems with invisible elements. If I make a simple change in the file referencing UIDocument (like adding a space in a string), then the error goes away and I can use the Play button in the editor, but still, none of the elements are visible.

    I'm new to this ecosystem, so maybe I'm missing a very simple step. Visual Studio on macOS has much fewer features than the Windows counterpart, so lots of suggestions I've seen I can't attempt because they don't seem available on this platform. Is there a better way to sort this type of thing out?
     
  42. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    Hello! You have to follow the steps on the migration guide to have an Assembly Definition on your project to guarantee compilation order is correct: https://forum.unity.com/threads/ui-toolkit-migration-guide.1138621/
     
  43. lookitsatravis

    lookitsatravis

    Joined:
    May 10, 2019
    Posts:
    4
    I hadn't yet seen that. Apologies for posting in the wrong place. I'll try it out. Thank you!
     
    JuliaP_Unity likes this.
  44. Kiloku

    Kiloku

    Joined:
    Mar 20, 2015
    Posts:
    4
    Running Unity 2021.1.23f1 I'm unable to install the UI Toolkit package when following the instructions at https://docs.unity3d.com/2021.1/Documentation/Manual/UIE-UITK-package.html. After adding the
    com.unity.ui
    package, the package manager just gets stuck saying "Please wait, installing a package..."
    The window shows no info on which step it's stuck at. It stayed there for over two hours until I had to cancel and finish up my day. An earlier attempt was cancelled after about 30 minutes.
     

    Attached Files:

  45. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    sometimes unity package installs randomly hangs and will never complete. restarting unity and or the computer MAY work.
     
  46. thedreamer

    thedreamer

    Joined:
    May 13, 2013
    Posts:
    226
    Will treeview be included in 2021.2?
     
  47. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    219
    Hi Guys, does this mean that the 2020 LTS "packaged" version will have the same support and periodic bugfixing and new feature updates than the 2021.2 "integrated" version? if we have a big project on 2020 should we even bother in using UI Toolkit, given that right now it's feature parity with UGUI is limited and many features are set as "planned" or "in research", will these future features come only in the 2021.2 integrated version or will come too as updates to the 2020 packages?

    thanks in advance.
     
  48. AndreasBroager

    AndreasBroager

    Joined:
    Jun 7, 2013
    Posts:
    5
    Hi.
    I have a custom unity package, that uses EditorWindow / OnGUI. I would like to port the UI to the new UI Builder.

    Does anyone, have a hint/link, on how I develop the Editor UI for my custom package using UI Builder?

    If I try to load an .uxml file from the package folder, for an embedded package, I get this error from UI Builder.
    UI Builder: Cannot load .uxml files outside the Project.

    It would be really sad if I had to copy/paste files back and forth.

    Setup:
    Unity 2019.4.32
    UI Builder: 1.0.0-preview.18
     
    JesOb likes this.
  49. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    Hello Andreas,

    It is indeed a limitation we have right now. There is no way to load and edit external (outside of the current project) UI documents. I am taking note of your feature request. Thanks!
     
    AndreasBroager likes this.
  50. AndreasBroager

    AndreasBroager

    Joined:
    Jun 7, 2013
    Posts:
    5
    @sebastiend-unity
    Would you be interested in at pull/merge request?

    Anyway, thanks for your time.
     
    Last edited: Nov 8, 2021