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

UI Builder

-

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

  1. 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.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.