I’m not sure if this is the correct place, but in a few of my projects I’m having issues where Animator states and transitions are not saving between git branches.
The initial Animator state and transition creations seem to save fine and travel between branches, but if I checkout a new feature branch then add more states/transitions to those already created Animators, save and commit, then merge with the parent branch, the states are saved in the project Assets but are removed from the Animator. Which, I then need to drag and drop the states from the project Assets then re-setup the additional transitions.
Are you properly exiting Unity before committing? Or at a bare minimum doing Project-Save?
Unity is extremely lazy about actually calling fflush() on files, so unless you are confident in the function of Save Project, it’s always better to exit.
To see what I mean, change any asset property right now, such as a slider on a Material.
Without exiting Unity, note that in git there are no changes.
Note if you now switch branches that cause a change to that underlying asset, you are now in this limbo where Unity has changes you made not committed to disk, and git has changed the target underlying asset out.
I wish Unity would fix this and just freakin’ fflush() all files immediately. This half-broken half-commit system has never saved a single person any lost work. This is 2021, everybody should be using source control already.
If I’m understanding you correctly, I notice that as well. So normally what I do is switch branches and bring Unity to back into focus, which usually prompts a reload of the scene. When I didn’t do this in the past, I get merge conflicts with the scene meta, which is not always recoverable. Only after reloading the scene do I merge branches. Is that what you mean?
Scenes get written when you press Save Scene, and usually that also saves other assets. Usually.
Always safest to close Unity utterly before doing anything in git. Slower and annoying, but safer.
I also try to never merge scenes or prefabs, which is easier said than done on a larger team, especially with longer-lived branches.
Additive smaller scene chunks and more prefabs can help guard against this, and also for a long-lived prototype feature, it can be better to clone scenes/prefabs in the new feature, allowing main branch to work against the original scenes/prefabs, until you’re ready to bring the feature back in, but that has costs too.
Yeah, I get what you mean, but I have zero problems outside of Animators with git and Unity; scene data, prefabs, materials, etc. all save/commit just fine, just those pesky Animators.
I’ll try closing Unity completely to see if that works and let you know.
Thanks for the suggestion!
@Kurt-Dekker Yep, saving the scene then closing Unity before committing seems to work, thank you! That’s ridiculous and is a pain, but at least I don’t have to try to reapply states and transitions. Thanks again!
Can confirm, same problem, closing Untiy and all of sudden git registeres the changes. That might be the root of more than a few problems we had during dev… Thanks.