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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Custom UI elements in UI Toolkit in 2023.2.0a9

Discussion in 'UI Toolkit' started by dlorre, Apr 10, 2023.

  1. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    In the features list of this alpha version one can read:

    What does this mean exactly? I have imported one of my custom elements in a new project created with 2023.2.0a9 and it seems to work the same. How are you supposed to create a custom element with this version?
     
    oscarAbraham likes this.
  2. oscarAbraham

    oscarAbraham

    Joined:
    Jan 7, 2013
    Posts:
    431
    I imagine that instead of using traits and factories, one can add the UxmlElement attribute to the class and the UxmlAttribute attribute to each property that should be available as an attribute in UXML. It seems very nice. I don't know how drawers work for this yet.
     
  3. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,876
    Last edited: Apr 12, 2023
    Onigiri, huwp, spaceemotion and 4 others like this.
  4. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    Thanks, it looks cleaner.
     
    karl_jones likes this.
  5. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    236
    This is a very very good step forward : the public properties + UxmlFactory + UxmlTraits were hard to grasp, and it was easy to fail making a proper custom VisualElement.

    Stating a property is an UxmlAttribute, via a simple C# attribute, is super clean :)
     
    karl_jones likes this.
  6. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    413
    Wow awesome! I hope new data binding will get into 2023.2 too
     
  7. ChebanovDD

    ChebanovDD

    Joined:
    Mar 27, 2022
    Posts:
    7
    You don't have to wait for Unity 2023. You can use UnityMvvmToolkit to get data-binding support, and UnityUxmlGenerator to get attributes support. ;)
     
    Midiphony-panda and Hellfim like this.