Reproduction steps:
1. Open the attached “IN-90535.zip” project
2. Open the “TestScene” Scene (Assets > Scenes)
3. Open the “MainDocument.uxml” in the UI Builder (Assets > UIAssets > UxmlReference)
4. Click on the “custom-element” in the Hierarchy and observe the "Template" Attribute set to “Template.uxml”
5. Double-click on the set “Template.uxml” to open it in UI Builder
6. Enter the Play mode in the “TestScene”
7. Make any edits in the “Template.uxml” (like adding an empty Visual Element)
8. Save the “Template.uxml”
9. Exit the Play mode
10. Open the “MainDocument.uxml” again
11. Observe the Console and the “Template” Attribute reference
Expected result: No errors and reference to the Template is kept
Actual result: “ArgumentException: Object of type ‘UnityEngine.Object' cannot be converted to type 'UnityEngine.UIElements.VisualTreeAsset'." error and the reference to the Template is set to 'None’
Reproducible with: 6000.0.31f1, 6000.1.0a7
Couldn’t test with: 2021.3.47f1, 2022.3.54f1 ('UxmlElementAttribute' and 'UxmlElement' could not be found errors)
Reproducible on: Windows 11
Not reproducible on: No other environment tested
Notes:
- Reimporting the “MainDocument.uxml” appears to fix the issue as the “Template” reference is set again
- After performing all steps (Reimporting as well) and without entering the Play mode, editing and saving “Template.uxml” again and then opening “MainDocument.uxml”, makes the issue fully reappear