UI code in 2d-space-shooter sample

I see in ui-toolkit docs that all code that interacts with ui should be inside the OnEnable method, yet the sample has it in Awake method.
It’s confusing right now for someone following the official sample.

I don’t understand what your question is.

Yet, it doesn’t matter where you put your UITK code. It depends on your needs ; you may use it once at Start/Awake/OnEnable if you want, but you could totally Query() your elements at anytime anywhere.

For example: you could make a routing system that instantiate views at runtime. Then, you will retrieve your UIElements in a specific method that isn’t a Unity native method.

The docs page says:
“Unity loads a UI Document component’s source UXML when OnEnable is called on the component. To ensure the visual tree is loaded correctly, add logic to interact with the controls inside the OnEnable method.”

This means if you do it in Awake() it might not work correctly.