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
- Crash on D3D12CommonShader::ApplyGpuProgram when attaching material which samples "_UnityFBInput0" to "Full Screen Pass Renderer Feature" Component
- SpeedTree meshes and objects count differs when comparing the numbers in the Player with the Editor
- Model and Prefab Preview icons are not updated after upgrading associated Materials to URP
- Game view is rendered white when viewing the Editor with HDR display and Post Proccesing is enabled on the Main Camera with 2D URP
- "GetPreferedValue" returns max value when using auto-sizing
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.