So for the past couple of days I've been trying out the new Unity UI Builder and I came across the following issue: Whenever you simply add a Vector3 field to the uxml and run the game the Vector3 field is scaled incorrectly. In the editor it looks like any Vector3 field would, just like the Unity Editor itself has. Below is an example image and the uxml.
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
<ui:VisualElement style="flex-grow: 1; position: absolute; height: 100%; width: 100%; justify-content: center; align-items: flex-start;">
<ui:VisualElement>
<uie:Vector3Field label="Vec3 Field" />
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML>
I have messed around with every field presented to me in the builder without any success. I could do away with the Vector3 field and create my own but that would take more time as I'd need to dive deeper into the source code. I hope someone can help me out. If the issue does seem to be common I'll report it to the Unity devs.
Thanks in advance!
If you're seeing UnityEditor.*
anywhere in your uxml then be aware that this panel won't work outside unity editor (exception on build). And since UnityEditor.UIElements.Vector3Field
is editor specific - it needs to be substituted with something else.
So far, my solutions to this are:
UnityEngine.UIElements.Label
instead (x1 or x3)UnityEngine.UIElements.Slider
x 3 (when input is needed) + EventSystem
with Event Generation
field set to IMGUI Events
PS: UIElements is still in development so this may change.