I’ve started using the UI Toolkit 1.0.0 within Unity 2021.2.3f1 to build my game’s UI. I made the error to open the USS file in Visual Studio while editing the UI, upon which the editor quickly prompted me on save to avoid opening the files externally as it causes loss of data.
I then closed Visual Studio altogether and, just for good measure, restarted Unity completely to ensure any hanging handles are closed.
I then proceeded to edit the UI inside the editor, making sure no files were open in any external program, however, if I spend too much editing without saving, upon trying to do so, I still get the “modified externally” message and my changes are discarded. This issue seems to be mitigated by saving every few seconds.
Environment:
OS: Windows 11 Build 22000.318
Unity: 2021.2.3f1 Personal
UI Toolkit: 1.0.0
VCS: Plastic SCM
Is the file open in the UI builder? Visual Studio seems to be the external program that modifies the file currently opened in the UI Builder.
The UI builder modifies the data used by the editor directly in memory with the help of the live reload of the asset. That new information is then saved to file when you actually save in the UI builder. If you modify the data in the meantime, the editor will reimport and override the changes not yet saved in the Ui builder, and you can lose some modification.
Hey Simon. Thank you for your reply. I was thinking of that, thus me closing Visual Studio completely, and restarting Unity to ensure any hanging file handles are released.
When I first saw the error, I realised it’s due to the file being open in Visual Studio, however, this error seems to occur at random times even with no editor open, barring Uniy Editor itself.
EDIT: And yes, the file is open in UI Builder, but no other programs.
EDIT2: Could it be that Plastic SCM somehow holds a handle on the file, or occasionally does so, to do the diff with upstream?
When you have a file open with the uiBuilder, you just have to save the file there befor opening it with visual studio. You cannot edit files at the same time in both programs.
As stated multiple times above, I already realized this. The issue occurs while all other editors are closed except for UI Builder. Only UI Builder is open, and the error pops up.
I’m seeing the same problem - I’m getting the popup and losing work even though I am not changing the files anywhere.
This ‘external change’ behaviour has caused me to lose work on several occasions while learning to use the UI Toolkit. It’s really putting me off using the system.
I’m not using any external program to edit any files whatsoever
Even if I was, UI Builder should implement the standard behaviour seen elsewhere in Unity and other programs: tell me a modification occurred externally and ask me if I want to discard my changes OR overwrite the changes in the file. This would allow me to keep substantial work I’ve made in UI Builder vs some trivial file change.
Simply discarding the user’s work without any choice or input is not OK. Annoyingly, I can’t find a solid repro case, but the dialog should still ask me for my choice either way.
I’m running a git client, Fork. Perhaps it’s possible it touches the file, but certainly doesn’t modify it. I’m not using Plastic SCM.
Regardless - I would still expect the prompt to offer me a choice to overwrite the file with my changes instead of discarding my work.
Here’s an example of what I’d expect from UI Builder: this is the popup shown in the unity prefab workflow if I modify a prefab externally while editing it.
@sebastiend-unity I’m bumping this thread because this is still an issue in Unity 2022.2.5f1. Although I do not have a message saying
“File has been modified externally”, I do lose my changes if I do not save after each single modification.
For example if I add a button to a VisualElement, edit the text, change the font size and hit CTRL+s, that button will disappear. Now I need to add my button, save, edit the text, save, change the font size, save, etc. That’s really annoying and time wasting.
Anything we can test to solve that issue?
@sebastiend-unity I am also encountering this behaviour in Unity 2022.2.6f1. (Due to ECS-related incompatibilities I am not yet able to upgrade to the most recent version of the editor, so it is possible that it has been fixed.)
Frequently, when I save in the UI Toolkit editor, the file will immediately revert to the most recent saved state. I am not touching the UI Toolkit files with any other program. No popup or console message is displayed, but I found this thread when searching for others who had the issue.
It is unpredictable when this happens, so like other users in this thread, I have had to resort to hitting Ctrl-S after each tiny atomic change to minimise loss of work.
In case it is relevant, I am running Unity on Ubuntu 22.04 LTS.
Like Sam_Bear asked, is there anything I can do to provide useful diagnostic information and solve this issue? It is easy to forget to hit save after every action, and this makes any UI Toolkit work incredibly frustrating.