Search Issue Tracker
By Design
Votes
0
Found in [Package]
0.5.7-preview, 0.10.0-preview
Issue ID
1216843
Regression
No
[UIElements] Incorrect Element Position when it is Absolute
How to reproduce:
1. Open the attached project
2. Open the UI Builder (Window->UI->UI Builder)
3. Open the NewUI.uss in UI Builder Window
4. Inspect the "Submit" Button's Position values
5. Open the "NewUI" Window (Window->NewUI)
6. Observe the opened Window
Expected result: There's a Button drawn in the bottom-right corner of the Window
Actual result: Button doesn't appear in the Window and needs to be offset, in order, to be seen
Reproducible with: 2019.2.20f1, 2019.3.0f6, 2020.1.0a22 (0.5.7-preview, 0.10.0-preview)
Couldn't test with: 2017.4.36f1 (Package Manages does not exist), 2018.4.17f1 (Script compilation errors)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Assets are created in the Package folders when creating assets via custom buttons in the Inspector window or other windows
- “Select” windows are named differently on Windows and macOS
- [Windows] No minimum “Select” window size
- Enabling “Editor Extension Authoring” in UI Builder doesn’t dirty the document and saving with shortcut doesn’t persist the state
- WebRequest.Create() function fails with "URI prefix is not recognized" errors when the project is built for Linux Standalone or Windows Dedicated Server
Resolution Note:
Absolute position should not be used often as it comes with a lot of pitfalls like this. The UI Builder "canvas" area is flex-grow:1 by default, so absolute-positioned elements in the root of the UXML document are offset based on the full size of the canvas. But when you CloneTree(), the TemplateContainer produced containing all your UI in the UXML does not have flex-grow:1 so anything that was offset will not be wrongly offset.
But "solving" this is quite hard in the general case because we can't just switch all default TemplateContainers to flex-grow:1 because that will break a whole bunch of other use cases.
While the current workflow and UX can be improved to communicate this issue better when using Absolute position, this is by design. You can quickly fix this, use asset.CloneTree(rootVisualElement), instead of CloneTree(), which will avoid creating the TemplateContainer. Or, give your "root" element (which is a TemplateContainer) .style.flexGrow = 1.