Search Issue Tracker
By Design
Fixed in 2022.1.X
Votes
0
Found in
2022.1.0b4
Issue ID
1397453
Regression
No
[UI Builder] UI element properties assigned via UI Builder can't be accessed from script
Steps to reproduce:
1. Open attached project (test-uitoolkit.zip)
2. Open SampleScene
3. Notice there's 2 buttons in the scene - one red, one green. Both added via UI Builder
4. Enter play mode
5. Check the console
Expected result: both buttons should have their background colors and tint colors printed. Height of the button should be printed as well.
Actual result: all colors are returned as black (or RGBA values all 0). Height is also returned as null.
Note: If I first assign a value to that property via script, then it starts to work fine. So seems like stuff created via UI builder is somehow not initialised at runtime.
Reproduced with: 2022.1.0b4
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
- Spot Light with 'Box' Shape stops working when it collides with Mesh
- Accepting Asset Store EULA endless loop in Package Manager window
- “InvalidOperationException: Sequence contains no matching element“ error when reenabling a custom Debug Draw Mode
- Prefab that contains a layout group is marked as changed by the Editor when opened
- Emission animation does not appear when the "Emission Map" parameter is set to black in a Lit material
Resolution Note (2022.2.X):
By design, to get inline styles set in the UI Builder you need to use resolvedStyle instead of style. Also, on Start of a MonoBehaviour the layout has not being calculated yet, so to be able to get an element's height it is necessary to wait until the first GeometryChanged event.