So Im new to unity and saw that in the UI Builder you can add existing ui documents as visual elements in a different ui document and I was wondering how I would do this in code, for example say I had a ui document with a visual element called DataBox and a different ui document called UIDocument2 how would I set the visual element to be UIDocument2 in code. Say if I were to change it in a method with C#?
I’m not sure I understand the question, but one way would be to retrieve the ui document asset, which is of type VisualTreeAsset. Then you can call VisualTreeAsset.Instantiate() on it to get a VisualElement instance.