The docs state, that a Button control may not contain child elements and my UXML also shows me a warning:
The element Button cannot contain child element Bla because the parent element’s content model is empty.
However, visually, this seems to work. I have a button with an icon.
Am I doing something wrong or is this warning misleading?
<?xml version="1.0" encoding="utf-8"?>
<engine:UXML
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:engine="UnityEngine.UIElements"
xmlns:editor="UnityEditor.UIElements"
xsi:noNamespaceSchemaLocation="../UIElementsSchema/UIElements.xsd"
>
<engine:Label text="Time Scale"/>
<engine:Slider/>
<editor:FloatField name="Time"/>
<editor:FloatField name="MaxTime"/>
<engine:Button name="Reset">
<engine:VisualElement name="ResetIcon"/>
</engine:Button>
</engine:UXML>
Hello Xarbrough!
Would you be able to tell me what version are you using?
2019.3.0f5. Thanks for looking at this!
The warning is just a suggestion as nothing really forbids you from doing it further down the line. We’ll update the generated schema to reflect this.
1 Like
It doesn’t seem like I reproduce the issue on 2019.3.0f6 using your UXML snippet.
Could you try to upgrade to the latest version and let me know if you still have this problem?
1 Like
I checked my project in 2019.3.0f6 and indeed, the IDE warnings about buttons not allowing children have disappeared. 
I’m on 2019.3.0f6 and still seeing this warning in Visual Studio, but not in Unity. Anything I can do to get rid of this?
@StephanieRowlinson : See this thread . It’s a small issue in the schema generation code and will be fixed in the future.
1 Like
@Xarbrough_1 Glad to see it is also fixed for you!
Thanks for letting me know!