Search Unity

Official UI Toolkit 1.0-preview available

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

  1. Refeas

    Refeas

    Joined:
    Nov 8, 2016
    Posts:
    192
    Have been playing around with the new package for a bit and really like the new workflow. I have some additional questions/feedback:
    1. Selectbox is really missing in the basic components as it's an essential one for any UI. Will it be available any time soon?
    2. Is there any alternative to CSS background-repeat and background-position properties? Couldn't find these in the UI Builder.
    Thanks!
     
  2. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    Tested an empty project with the package list and version mentionned by @Chris-Trueman could not add the UI Document.
    Tryed remoing hte input package and then I could add the UI Docmument.
     
  3. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    Do you mean this?
    https://www.w3schools.com/tags/tag_select.asp
    If so, in UI Toolkit, the equivalent is PopupField.

    We don't have a repeat background property yet. It's in our backlog.
     
  4. Refeas

    Refeas

    Joined:
    Nov 8, 2016
    Posts:
    192
    Thanks for the quick reply!
    Yes, I mean the Select tag. I know in editor it's called PopupField and I've been using it already. I was asking more about the runtime version of the popupfield as it's not visible in the components. If I check the Editor authoring checkbox and then drag the PopupField to the canvas, will it work properly in runtime?
     
  5. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    We don't yet support any dropdown-like control at runtime. The ones in the Editor rely on OS-native popups and will not work at runtime. But this task is in our backlog to add runtime support for PopupField and EnumField.
     
  6. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    I tried this, and while I was able to get a UIDocument added to the scene, it caused far to many errors to be usable. At first it was cyclic reference errors when I added the InputSystem back in(had 102 compiler errors because of the missing InputSystem).
    Code (CSharp):
    1. Assembly with cyclic references detected (Packages/com.unity.2d.animation/Tests/Editor/Unity.2D.Animation.EditorTests.asmdef)
    2. (Filename:  Line: 0)
    3.  
    4. Assembly with cyclic references detected (Packages/com.unity.ui/Core/UnityEngine.UIElementsModule.asmdef)
    5. (Filename:  Line: 0)
    6.  
    7. Assembly with cyclic references detected (Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef)
    8. (Filename:  Line: 0)
    Then I got a whole bunch of "The referenced script (BlaBla) on this Behaviour is missing!" Which looking at each one said to fix compiler errors, which there were none.

    I removed UI Toolkit and the missing script errors went away, but I ended up loosing some of my references. Not a big deal to drag them back in. I had restarted the editor to see if it would fix the missing script warnings which may have caused it to loose some of the references, it may have only been on the GO's that I looked at before restarting.

    I'll wait for the next version to test it out in this project, so I don't run into any more incompatibility issues. Any eta on that drop?(I know, I know you just dropped this one :D)
     
    lclemens likes this.
  7. PedroGV

    PedroGV

    Joined:
    Nov 1, 2010
    Posts:
    415
    Ok, but how do you assign the font with the needed characters, say for Japanese? Similarly to TextMesh Pro?
     
  8. The-Wand3rer

    The-Wand3rer

    Joined:
    May 14, 2019
    Posts:
    33
    What is the proper way to move visual elements to a specific position?
    I would like a panel to appear in a specific location after I click on another element. I have:

    Code (CSharp):
    1.  
    2. var v3 = new Vector3(Screen.width - container.layout.width, Screen.height - container.layout.height, 0);
    3. Debug.Log(v3);
    4. //container.transform.position = new Vector3(v3.x, v3.y, 0 );
    5. container.transform.position = new Vector3(1367.1f, 394.2f, 0);
    6.  
    If I assign the exact values as "numbers", the panel is correctly translated. If I assign the vector, which contains the same exact values, the panel disappears. What am I doing wrong?

    By debugging I have also noticed that right after enabling the UI, layout.* is NaN. Is there like a "layout ready" event or something? Maybe that is breaking the panel? If so where should I get the desired size?
     
  9. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    I would set the style position to absolute with the pixel coordinate I want.
     
  10. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    As the original post for this thread mentions, TextMesh Pro support will come in a future version of the package. For now, you'll need to use a font that supports all characters you need, or switch the font at runtime. To assign a font, in USS:
    Code (CSharp):
    1. -unity-font: resource("myfont");
    C#:
    Code (CSharp):
    1. myElement.style.unityFont = fontAsset; // As loaded from AssetDatabase or Resources
     
    PedroGV likes this.
  11. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    Here's some untested code that should shed some light on how to position an element based on another element:

    Code (CSharp):
    1. void CreateElementBeside(VisualElement targetElement)
    2. {
    3.     // To make sure targetElement has layout computed, wait for the first GeometryChangeEvent.
    4.     // You can do a quick check to see if the targetElement.resolvedStyles.top is NAN and only do this trick in that case.
    5.     targetElement.RegisterCallback<GeometryChangedEvent>(CreateElementBesideCallback);
    6. }
    7.  
    8. void CreateElementBesideCallback(GeometryChangedEvent evt)
    9. {
    10.     var targetElement = evt.target as VisualElement;
    11.  
    12.     var newElement = new VisualElement();
    13.     newElement.style.position = Position.Absolute;
    14.  
    15.     newElement.style.top = targetElement.worldBound.y;
    16.     newElement.style.left = targetElement.worldBound.x;
    17.    
    18.     // It you only care about the first GeometryChangeEvent, so unregister from it for all future ones.
    19.     targetElement.UnregisterCallback<GeometryChangedEvent>(CreateElementBesideCallback);
    20. }
    There's no explicit event for this but you can use the GeometryChangeEvent. It gets sent every time the size/shape changes but the by the time the first one is set, all layout should already be computed.

    As a friendly reminder, please start new threads on the forum for such specific questions instead of using this announcement thread.
     
  12. MdoobM

    MdoobM

    Joined:
    Jan 4, 2018
    Posts:
    2
    Is there any plan for multi-screen support?
     
  13. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    No plans specifically for UI Toolkit, beyond what Unity already support.
     
  14. CabinIcarus

    CabinIcarus

    Joined:
    May 24, 2017
    Posts:
    72
    upload_2020-7-13_22-47-57.png upload_2020-7-13_22-48-43.png

    sPanelSettings`
    upload_2020-7-13_22-49-54.png

    I added the 1.0 package in 2020.2.0a17, it cannot be used normally, when will the preview package 4 be updated =-=
     
  15. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    Please create a new thread so we can help you better. This thread should be kept to questions about the UI Toolkit 1.0 package announcement.
     
  16. CabinIcarus

    CabinIcarus

    Joined:
    May 24, 2017
    Posts:
    72
    ok
     
  17. DrSeltsam

    DrSeltsam

    Joined:
    Jul 24, 2019
    Posts:
    101
    Probably it's always great to have various options, however, I want to emphasize that I personally love the way how authoring works in UI Toolkit, and I very much prefer it over the old canvas authoring way. Despite the bugs, the UI builder and the flex layout are awesome. I just wanted to mention that :D
     
    sebastiend-unity likes this.
  18. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    331
    Hey thanks for the feedback, I'll forward it to the team.

    And we'll build on that. We also believe the UI Builder should be at the center of the UI authoring workflows, we just want to make sure it supports the creation process, from conception to release.
     
    Tanner555 and DrSeltsam like this.
  19. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    864
    Following up on the multi display question by @MdoobM ... Currently, when using UnityEngine.UI to render to another display, you just change the TargetDisplay property on Canvas component. What is the equivalent in UI Toolkit?
     
  20. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    No equivalent yet. Should come in a future release.
     
  21. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    The new UI package could possibly be the cause of my editor and player hanging. More info here: https://forum.unity.com/threads/edi...rsing-profiler-data-0-xxxkb-processed.929217/
    Debugging the Player made me become suspicious of the UI Toolkit package

    Disregard this post. The issue was NativeArrays allocated with TempJob but not deallocating fast enough, these would hog up threads for some reason eventually stopping all threads, which is why at one point the debugger was indicating a UI Toolkit related thread hanging, it was just a coincidence as all threads were stopped.
     
    Last edited: Jul 17, 2020
  22. chaaaddd

    chaaaddd

    Joined:
    Nov 9, 2019
    Posts:
    6
    Can't test this out yet because I use the new input system, but...

    This is easily the best sample project I've seen from Unity. Not just for UI Toolkit things too. It's complete as far as I can tell and it's not overly complicated.Well done.
     
    cirocontinisio and benoitd_unity like this.
  23. blai30

    blai30

    Joined:
    Aug 18, 2015
    Posts:
    9
    I held off on investing too much work into the UI in my project with UGUI because I was waiting for this. Unfortunately since I use Input System, I can't use UI Toolkit just yet. I'm very excited for this!
     
    lclemens likes this.
  24. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    There is a bug with your UnityRoyale-TowerDefence-UIToolkit demo, the font in preview all broken. The issue apparently is that the preview windows reports dimensions of a preview frame which are very small but not downscaled properly.
    Match Game View does not fix the issue as well since it just resizes the preview frame.

    upload_2020-7-17_21-47-13.png
     
    Last edited: Jul 17, 2020
  25. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    Hey, we're working on improving the example resources but what's happening is that the canvas size on the UI Builder is not big enough to fit everything looking good. If you increase the size it should get a bit better! You can do that by selecting the "TitleScreen.uxml" (top item) on the Hierarchy portion of the UI Builder.
     
    Tanner555 likes this.
  26. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    I'm not talking about the background, I'm talking about font scaling.

    And honestly, why not use `zoom` to handle that? It will scale viewport properly and it should be good for preview.
     
  27. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    Yes, font size is too big given the size of the default UI Builder Canvas in the UI Builder. Most other elements resize themselves based on the size of the screen, but the font size does not. That's why the text looks really large in the Builder.

    Main problem is that the UI Builder Canvas size in the UI Builder is a setting that is just a Builder-only preference, used at edit time only, and not stored with the asset. So when open any UXML in a fresh project clone, you might get UI Builder Canvas sizes that are too small for the intended UI they contain. We'll work on improving this workflow but we'll also fix the sample to work properly with the default UI Builder Canvas size.
     
    Tanner555 likes this.
  28. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    Yeah, some way to store reference resolution data would be nice.
     
  29. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    Last edited: Jul 18, 2020
  30. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Yeah, don't be like that. People don't deserve to be fired due to introducing a single bug. That's a super toxic attitude!
     
  31. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    That is not even a bug, it's the correct way to define the margin in CSS (there is no reason to not match that in USS) and the values from the ui builder are put in there correct spot in the uss file.
    The only improvment that could be made is to rearange the order of definition in hte UI builder to match the CSS definition order which is clock wise starting from the top (top -> right -> bottom -> left)
     
  32. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    Dont be ridiculous nobody was unironically saying someone should be fired over this, but the fact such issue even exist is kinda ridiculous as well. But then again, this is Unity, can't really say I expected something different.


    After playing with the preview for few days I'm utterly disappointed. I was ready for USS to be limited in some aspects, mostly because of performance and rendering reasons (web usually tries to target 60fps, Unity has to consider higher targets) and I expected it to ditch a few thing due to its own layering and compositing but good lord I did not expect USS to be THIS bare. It is like we are back to the earliest days of CSS where we have some very basic sizing and positioning but with the luxury of Flex. And because of their different implementation of the rendering you cant even apply some old performance wisdoms from web CSS.

    A lot of people who were excited gonna be dissapointed when first release of UI Tooklit comes with Unity 2020. And, judging by how long initial release took, it most likely will take literally YEARS before this UI framework will be expanded to something comfortable and better than current Unity UI.
     
  33. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    Alright, I give up:

    upload_2020-7-18_23-52-57.png

    Guys, this isnt 1997, adding flex means jack sh*t. On its own it is unusable, it is suffering and misery when the rest of StyleSheet capabilities isnt just on par. I dont even remember when I last time had to pad an inline-element to get border right, jesus.

    My suggestion: take another year or two and expand the team with people who have experience with WEB design. Do not try to aim for 2020, even as a public open preview. It just bad.
     
  34. I knew it was a mistake introducing another web related tech in Unity. It is just like back in the UnityScript days. Call it Javascript and all the wannabe web-developers will mistakenly think they know what they are doing. It is the same with this. Just this time with the styling system.
     
    JoNax97 likes this.
  35. unity_4-cpGPp_cAIdrA

    unity_4-cpGPp_cAIdrA

    Joined:
    Apr 9, 2020
    Posts:
    2
  36. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    This isnt a thread about other UI frameworks/libs, also, that framework integrated wont be on par with performance.
     
  37. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    792
    Of course, one should not expect that the knowledge about browsers can be transferred to Unity. They also use the name USS and not CSS to clearly distinguish that it is not the same.
    Unity could have used Chromium, but that would increase the size of each Unity game and create an overhead. Size and overhead might not be noticeable on a gaming-PC, but on low-end devices.

    what's wrong with that? CSS / USS padding / margin are always arranged clockwise (top-right-bottm-left). But that doesn't mean that it has to be that way in the editor, since it seems to group logical left-right and tob-bottom. But it could be confusing for people switching between builder and USS or people with web origin.
     
  38. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    331
    Please change your tone. I'm sure you can find ways to share constructive feedback without being disrespectful.
     
    Last edited: Jul 20, 2020
    loptrinho, adammpolak, Vharz and 8 others like this.
  39. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    So...I'm that guy. :) And maybe I'll fix this margin ordering thing in a future release, once the UI Builder can actually write out compound properties like `margin: 1px 2px...` (it cannot right now). But until then, we have bigger fish to fry. As you and others pointed out, we are working our way up to what the web has had for years. It's a lot and it will take time. In the meantime you are free to use Unity's extensibility features to integrate any other UI solution of your choice, and you are more than free to continue using uGUI (Unity UI).

    We are doing all this to strive a balance between:
    - the power, flexibility, and familiarity of web UI,
    - while also having a solution that is deeply integrated into every feature and system in Unity and works well within Unity's rendering pipelines for the best performance.

    We felt that Unity's previous UI solutions lacked the former, while third-party engine-agnostic UI solution lacked the latter.
     
  40. etienne_unity

    etienne_unity

    Unity Technologies

    Joined:
    Aug 31, 2017
    Posts:
    102
    Quick UITK implementation of the main menu use case from the comments above.

    upload_2020-7-20_11-50-56.png
     

    Attached Files:

    JohngUK, lclemens and Tanner555 like this.
  41. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    I did not mean to to offend, it was off-hand joke mostly.
    Here is the problem though Damian:
    Nobody likes UnityUI. I can go into any Unity community and there will be 1:10 people who like and hate it, just point fingers and they will tell telltales about it. This one of the biggest reasons a lot of people I've seen were exceptionally excited about UI Tookit. It was a promise to finally end the suffering.

    That's what I'm saying - TAKE more time instead of underdelivering or you get the same disappointed response and feedback as with new Input System where people eventually would shrug and go back to Rewired.

    Implementation isnt the problem, problem is how many workaround and compromises I have to construct. After working with CSS3.x before and such luxuries as fit-content/max content it just does not feel very good. I still can do whatever I want but it is a letdown and unnecessarily complexity.
     
    Last edited: Jul 20, 2020
  42. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    None taken. I get the frustration. I'm also a user of other people's software and often baffled as how anyone could have made one choice or another. But I try to remember that there's very likely other concerns that I'm not aware of that contributed to any decision.

    It's again, a balance. If we spend 10 years rebuilding the web inside Unity, in isolation, until it's perfection, the world of games, software, and even of Unity, won't pause for us to finish. That would be 10 more years of uGUI extensions, improvements, and refinements (out of necessity). 10 more years of custom UI solutions chugging forward and becoming better.

    If my math is right, we're now into our 4th year of UI Toolkit development, going onto 5 years. It's not polished in a lot of ways but it's definitely in a place where you could build a complete game UI with it. We've done it. The loop is complete. Now we just need to incrementally improve this loop and make it more and more capable and easy to work with.

    uGui's most glaring problems only show up when you start having more complex UIs. So with UI Toolkit, we focused on that late-game complexity first - getting to a point where you can build a functional UI with a lot more flexibility than before. Now, going forward, we'll focus more and more on taming this complexity behind better workflows. You have to have to start with the complex in order to abstract it.
     
  43. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    It was a lot to read to get to this point, and I know it's been discussed, but I feel like Digika's points could have been made in a less dramatic way. We have been fortunate enough in this forum to keep a constructive tone, and I would it to keep it this way. Your points are valid and very well understood; while we are aware of what problems this brings, there is also a great deal of benefits to release early (yes I call it early, considering the amount of work ahead of us). While there are many developers working on Unity, we are a small group of individuals who try our best at delivering an alternative to UGUI and other UI systems that have presented some problems over the years. The UI Builder's staff especially is small and we are incredibly fortunate to have Damian on our side ;) Remove Damian and you've got half the responses on this forum alone ;) I know you were joking, we all got that, this is, after all, a public forum! But we need the input and feedback from users like you, we take everything you say into account. There are so many ways to present that feedback. We are not releasing version 5.4 of the UITK, we're putting it out for the first time. We need to know we're going in the right direction. So we'll take all the feedback, especially the negative feedback, as long as it's constructive. Fortunately there is a lot of that in your communication, Digika. Thanks for that. Keep it coming. The right way :) Please keep in mind we're not in a complete state yet & we do have more coming your way.
     
    PygmyMonkey likes this.
  44. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    Speaking of feedback you probably should open up an issue tracker, forums are terrible for this
     
  45. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    We use the regular issue tracker that Unity uses. Just report bugs using Unity's built-in Bug Reporter and we'll get them.
     
    Tanner555 likes this.
  46. Tanner555

    Tanner555

    Joined:
    May 2, 2018
    Posts:
    78
    I wouldn't put all the blame and frustration of current Unity on some of these hard working engine developers and community managers. It's mostly the top most upper management, and the lead directors, as well as human resources that has the biggest impact on prioritizing certain things over others. UI Toolkit looks awesome, I can't wait for the packages to be production ready.

    It's just that Unity over promises, hypes up unnecessary features (like Unity Collaborate), and then abandons those features when teams really start implementing them. Unity needs to focus on core essential features that'll impact the future of game development, and abandon all the tech demos and features that most developers don't care about. It's about prioritizing essential features like the Input System, DOTS, UI Toolkit, and Rendering, while cutting out the fat, like Unity Collaborate, Unity Mars, Unity for Architecture, all these unnecessary tech demos where the models can't even be used in commercial products.
     
  47. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    I will pass your message along, Tanner555.
     
    Tanner555 likes this.
  48. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    @sebastiend-unity

    Please don’t think we all feel this way. In my instance, my friend and I use Collab everyday. I love it (even though it has some issues) and removing it would be a detriment to our development as my friend is not technical at all.

    Thanks for all the hard work, and I cannot wait for UIToolkit!
     
    Tanner555 likes this.
  49. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    No worries, I was talking more about the need to keep core/essential features at the center of our investments/efforts :)
     
    Tanner555 and MousePods like this.
  50. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    New around here?

    There was a suggestions site, it was such a garbage fire of horrible that it got shut down. The forums are much better for this kind of thing, since, if people are polite, we can have constructive discussions about things instead of just throwing suggestions into the void.


    UI Toolkit is absolutely amazing this far for editor UI. I'm having a real great time rewriting a imgui based system to UIT. I hate UGUI with such a passion that I'd accept pretty much anything, so I'm looking forward to starting to write in-game UI's with UIT.

    To be fair, I have a ton of frustrations when working with UIT, but almost all of them are simply that SerializedObject/Property is a pretty S***ty API, so Bindings end up inheriting that S***tyness. Hey, you removed an array element? Well, now all the bindings for later array elements are off by one, and have to be rebound! Not much to do about that for now.

    Collaborate was a failure of product management the second that it was decided to be made, and it's been a continual failure since. What makes me worried about Unity is that most of the core stuff that's delivered for free with Personal is great, and every single service that you have to pay for is bad. Some of the more recent integrations might be worthwhile (Havoc), but Collaborate manages to be easily the worst source control system ever made, and stuff like cloud build or analytics are easily replaced with free services or just knowing how to send data to a server.
     
    benoitd_unity and Tanner555 like this.