Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question UxmlChildElementDescription has no effect in UI Builder

Discussion in 'UI Toolkit' started by Windwalk_Rosco, Sep 27, 2021.

  1. Windwalk_Rosco

    Windwalk_Rosco

    Joined:
    Aug 10, 2020
    Posts:
    20
    Unsure if I am doing something wrong here but
    Code (CSharp):
    1.  
    2. public override IEnumerable<UxmlChildElementDescription> uxmlChildElementsDescription {
    3.         get { yield break; }
    4. }
    5.  
    seems to have no effect in UI Builder with a custom element. Neither does adding a child description like so
    Code (CSharp):
    1.  
    2. public override IEnumerable<UxmlChildElementDescription> uxmlChildElementsDescription {
    3.         get {yield return new UxmlChildElementDescription(typeof(Label));
    4. }
    5.  
    Unsure if this is just a limitation of UI Builder or a bug but no matter what it seems you can add any children to anything. It does seem to work with ListView but I'm not sure if this is just because ListView clears its children itself?
     
  2. HugoBD-Unity

    HugoBD-Unity

    Unity Technologies

    Joined:
    May 14, 2018
    Posts:
    492
    Hi @Windwalk_Rosco ,

    uxmlChildElementsDescription it's not enforced. It's only used to generate the uxml schema, which is used to help auto-completion in Rider and other IDEs.
     
  3. Windwalk_Rosco

    Windwalk_Rosco

    Joined:
    Aug 10, 2020
    Posts:
    20
    Ah, understood. Wish the docs were a little clearer about that