I’m working on an Editor window. It seems that, given the approach I’ve found to loading the UXML, I need to close and reopen my editor window every time I change the contents of the UXML file, to get it to reload. That’s really inconvenient. Is there another way to do this? I’m following the approach that’s built into the Create → UI Elements → Editor Window, which does something like this in OnEnable:
var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Code/Editor/Windows/TelemetryEditorWindow.uxml");
VisualElement labelFromUXML = visualTree.CloneTree();
root.Add(labelFromUXML);
It seems that any changes I make to the UXML won’t take effect until I close and reopen the window. What can I do to streamline this to avoid the constant window opening/closing?
In 2020.2, if you use the latest version of the package, you can enable Live Reload by clicking on the … on the upper right of the editor window.
To my knowledge, I’m not using a package at all for UIElements. It’s just part of the engine? I’m on 2019.4. Did you change it into a package for later versions? Is live reloading possible under 2019.4? I don’t see an option in the … menu:
unfortunately, Live Reload is only available from 2020.2.
If you use the UI Builder you can see what the UXML looks like in there, so it could hopefully minimize the amount of times you’d have to reopen your view.
Thanks, I’ll take a look.
Another thing I realized is I could just assign a key binding to open my editor window, making it pretty easy to reopen. I don’t think there’s a way to close it via a key binding. But it seems that as I’m bouncing between Unity and Visual Studio, working on the editor window, it’s pretty typical to return to Unity to find the editor window has closed. (Maybe due to recompilation?) In which case, I just press the key binding to open it again. Pretty easy.