We have a custom “dependency injection” that initializes all registered systems from its Awake(), which has the highest script execution order.
Now the issue is, many of them need to access a visual element of UIDocument, ofc issue is, the UIDocument did not create its element yet, so the UIDocument.rootVisualElement is null during our system initialization.
Question here is:
is there any way how to either force UIDocument to create its UI, or to instantiate the visual asset tree and show it to UI from code outside of UIDocument?
I know I can brute force it via
document.GetType().GetMethod("RecreateUI", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(document, null);
But there has to be some cleaner and better way
Thank you