Search Issue Tracker
By Design
Votes
0
Found in [Package]
1.0.0-preview.13
Issue ID
1305593
Regression
No
UI Controls are not visible when UI Document is added to scene programmatically
How to reproduce:
1. Open the user's attached to project "PaintEngine.zip"
2. Go to Assets > Resources > Layouts and select "DisplayTabs.uxml" file
3. Notice that tabs and texts are visible in the Inspector window's preview
4. Load the "SampleScene"
5. Enter Play mode
6. Observe the Game view
Expected result: Labels with text are visible in the Game view
Actual result: Labels with text are not visible in the Game view
Reproducible with: 1.0.0-preview.3 (2020.1.17f1), 1.0.0-preview.13 (2020.2.2f1)
Could not test with: 2018.4.31f1, 2019.4.18f1 (UI Toolkit is not introduced yet), 1.0.0-preview.13 (2021.1.0b3, 2021.2.0a2) (due to errors with Unity UI package)
Notes:
- Not reproducible when "PaintEngine.uxml" is assigned to UI Document GameObject
- Reproducible with Controls like Sliders, Text Fields, Buttons, Scrollers, etc.
- Reproducible when Zenject for Dependency Injection is used
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
- Skinned Mesh Renderer with multiple Animator Components does not render when "Optimize Game Objects" is enabled
- [iOS]Certain characters are not displayed when using iOS devices with 18 OS and newer
- Trees do not render in 'Unity Terrain - URP Demo Scene'
- Silent crash when clicking in Scene View in a specific project
- The Player renders black on a Quest headset when MSAA, Post Processing, and Spacewarm depth submission are enabled
Resolution Note:
We do not encourage the creation of PanelSettings assets programmatically, which usually leads to an empty style sheet setting and nothing gets drawn. We're adding a warning about that.
In any case if you really need to create the PanelSettings asset programmatically, you have to make sure the Default.uss style sheet from the package gets loaded into the themeStyleSheet property (and that can be complicated), which is why using an asset created on the project is best.
I used the one found in the root of the Assets folder on the given project and could see the UI without issues (I also had to load the UXML and set it as the visualTreeAsset on the UIDocument as the value was not being set, or I couldn't find where it was being done).
To sum it up, there doesn't seem to be any issues, it's just that the resources are not being put into place properly, therefore nothing shows up on the UI.