Search Unity

Custom Element Attribute for TreeAsset ... possible?

Discussion in 'UI Toolkit' started by mrSaig, Sep 4, 2020.

  1. mrSaig

    mrSaig

    Joined:
    Jan 14, 2010
    Posts:
    68
    Hi,
    i have written a custom element, a dropdown for runtime ui and i really don't want to style it in a custom way inside the code to make it reusable ... so i thought maybe i can link a VisualTreeAsset ... so the code just takes it as a template and instantiates it for the "drop of the down" :D

    long story short ... will something be possible like the following code? (currently its not obviously)
    Code (CSharp):
    1. UxmlTypeAttributeDescription<VisualTreeAsset> dropDownMenuStyle = new UxmlTypeAttributeDescription<VisualTreeAsset> { name = "dropDownMenuStyle", defaultValue = null };
    so it'll be possible to drag and drop a visualTreeAsset into the attribute-field inside of UIBuilder?!

    or is there even a way already implemented that i totally overlooked?

    Cheers
     
  2. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    mrSaig likes this.
  3. mrSaig

    mrSaig

    Joined:
    Jan 14, 2010
    Posts:
    68
    Look interesting, i'll have a look thx!
    But due too the frequent updates for the ui package it might not be very satifiying modifing this over and over again :/
     
  4. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    698
    Hi @mrSaig , I'm not sure I understood what you're trying to accomplish correctly but is there any reason why you can't create your own VisualElement extending class that has their own UxmlTraits, similar to EnumField (which is Editor only)?
     
  5. mrSaig

    mrSaig

    Joined:
    Jan 14, 2010
    Posts:
    68
    The field shows up but with a string input field ... and not as i expected with a asset drag and drop field there i can set the uxml file.