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
- Create Node Menu is not closing and “NullReferenceException: Object reference not set to an instance of an object” error is thrown when Shader Graph window is closed
- Assert error is thrown when the Editor language is set to one of the experimental ones in an HDRP project
- A BatchDrawCommand is using a pass from the shader “Universal Render Pipeline/Particles/Lit” that is not SRP Batcher compatible
- The Scene does not get rendered in the Player when MSAA is enabled and more than one Camera is used
- Crash on mono_object_get_class when generating Font Atlas of a specific font file
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.