Search Unity

Bug PropertyField is invisible when added from code or UXML

Discussion in 'UI Toolkit' started by bloodthirst69, Sep 12, 2019.

  1. bloodthirst69

    bloodthirst69

    Joined:
    Oct 1, 2017
    Posts:
    28
    Hi , i am having an issue with the PropertyField in UIElements that i am trying to use in a EditorWindow, basically it just doesnt show on the editor , it takes place in the root visual element by doesnt render anything to the window , i tried to both add the PropertyField from inspector and from code , same issue , screenshot down below shows where it is supposed to be showing
     

    Attached Files:

  2. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    398
    To display something, a property field first needs to be assigned a property path through the binding-path parameter. Then, either the property field or one of it's parent elements must be bound to an instance of a SerializedObject. When bound, the property field will then create proper VisualElements depending on the property value type.
     
  3. DarkPrinceZen

    DarkPrinceZen

    Joined:
    Aug 31, 2020
    Posts:
    1
    Hello, I am having the same issue where I am trying to display a List<GameObject> via the PropertyField using UXML. I was wondering if there was any update to this issue or whether an example could be provided on how to correctly bind and serialize the properties.
     
  4. CxydaIO

    CxydaIO

    Joined:
    May 12, 2014
    Posts:
    61
    Hey, as uMathieu already mentioned you need to set the BindingPath and you also need to Bind() the PropertyField to a SerializedObject.
    Some binding examples can be found here