I’m having a problem in the editor that saving isn’t working (I’m using the Linux version). I can see a “*” in the title bar indicating I have unsaved “something”. I Press Ctrl+S and nothing happens. I choose “File | Save Project” and the star doesn’t go away.
When I exit I get asked if I want to save, but sometimes that doesn’t save everything. As this morning I reopened my project and something I did last night is gone.
Places like the UI Builder also don’t appear to have a save option. I have no choice but to close the window and say “Yes” to wanting to save.
This is driving me crazy, and leading to data loss. How can I reliably get everything to save?
This has happened to me before, and the result has been some script running in edit mode that modifies a value of something in the scene. So, your scene is probably getting saved, but then some other code is immediately modifying something in the scene, causing the “*” to show up again.
As for actually tracking that down… Version control might tell you if a value has changed? Look for scripts in your scene with ExecuteInEditMode on them, to see if they’re modifying a value?
Hmm. It kind of sounds like everything’s working as expected, actually.
Regarding your first item, about closing while in Play mode, that’s expected. Nothing is saved if you’re in Play mode. Any changes you make in play mode are 100% lost. And the scene won’t necessarily show an “*” in those cases, as it won’t consider the scene to have changes if it’s in play mode.
Regarding editing a prefab, if you have changes to your scene, then you open a Prefab to edit it, saving the prefab will not save the changes to your scene as well. When in Prefab editing mode, saving only saves the prefab. Only after leaving prefab mode will you be able to save the scene.
But if you’re editing the scene itself, and saving doesn’t do anything, I’d check to make sure you have write permission on the directory the scene is in. Create a text file there as a test, and edit it. Make sure you can actually write to that directory.
I’m not making changes in play mode, the changes were made outside of play mode. It’s just once in play mode there appears to be no way to save the changes, and exiting the editor will lose those changes.
I can understand that saving in a prefab saves the prefab, but isn’t there a “Save All” option? Is there actually a way to “exit prefab mode” other than finding a scene and opening it?
What version of Unity are you on? Here’s what it looks like when I edit a prefab. I can just click the little arrow to get out of prefab edit mode, and back to the normal scene:
Also, entering play mode when you have unsaved changes in the scene is risky. I know that’s kind of what this is all about, but you should ideally ensure you’re saving every time before entering play mode, unless you are okay with losing changes due to crashes.
So, the question remains: Are you Edit Mode changes actually saving. I’d test the following:
Open a scene, any scene, in your project.
Add a new cube to it. Doesn’t matter where, as long as you can tell it’s there.
Save the project. (Ctrl-S, or File->Save)
Close Unity.
Reopen Unity. See if that Cube is still in the scene.
If that cube is still there, then saving is working.
Thanks, I don’t think I would have seen that little arrow there, or known what it does. I can leave the Prefab mode.
Yes, things are saving if I’m in the main scene. I suppose I’m just not used to not being able to save whenever.
I’m not intentionally running without saving. But if I’m working on a prefab, there’s no way to run without saving, unless, as you showed, I first leave the prefab, save then run. But then I have to renter the prefab if that’s what I’m working on.
It sounds an awful lot like you are not properly using source control. You are one millisecond from complete disaster in this case, and NOBODY in the year 2022 (nearly 2023) should be forced to live like this.
Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.
Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).
You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.
As far as configuring Unity to play nice with git, keep this in mind:
I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.
Here is how I use git in one of my games, Jetpack Kurt:
Using fine-grained source control as you work to refine your engineering:
Share/Sharing source code between projects:
Setting up an appropriate .gitignore file for Unity3D:
Generally setting Unity up (includes above .gitignore concepts):
It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It’s simply ridiculous not to back up.
If you plan on joining the software industry, you will be required and expected to know how to use source control.
“Use source control or you will be really sad sooner or later.” - StarManta on the Unity3D forum boards
@Kurt-Dekker I don’t know how source-control factors into this discussion. It’s irrelevant which tool I’m using (git) if the environment isn’t saving when I expect it to save.