- Home /
.unity scene file size sudden increase after merge attempt. Contains deleted [SerializeField] data. How to clean the file?
Hi everyone!
TL;DR: Unity file size shot up 20x when trying to merge. Seems to contain deleted serialized data. How to clean/prevent in the future?
I'm quite new to Unity and coding in general and we've encountered this little issue suddenly with the physical file size of our .unity files.
We've been using Git as a way to keep some version control for our game which is a small puzzle game based entirely on canvas/UI elements. When we forked our code base to work on it separately, the size of the .unity file for our main scene was about 30kb. We each worked on our portion of the game a little bit then we attempted to merge. At this stage our unity scenes were about 40kb each.
We attempted several methods of merging our game, since we were both using the same scene, we attempted to merge with YAMLmerge and P4Merge. We couldn't get that to work so we attemped to discard the merge changes and try again with Tortoisemerge, but again we had no luck. We ended up just saving our scene under a different name, exporting it as a package, and importing it into the other copy of the game and copying everything relevant over.
After this process was complete, our .unity scene file size was 900kb. While it doesn't seem like much, compared to the 40kb sizes we were working with, there's some sort of sudden increase. We're also trialing Unity Collab now, and uploading 1mb scene files everytime you want to change a variable in a serialized field takes a while. I attempted to create a new scene, copy everything over and then save the new scene, but it was exactly the same size as before.
After investigating the .unity file with a text editor, I found lots of data belonging to variables that have been [SerializeField]. However, most of the variables in the .unity file were old and had been deleted long ago. I found a reference to a deleted array that we threw a huge bunch of data in, in the .unity file and deleted it, reducing the total file size to 470kb. There seems to be more but currently there are 15,000 lines of text in here in a not very human readable format.
There is a reference to YAMLmerge at the top of the file as well, so maybe it's some old merge data that hasn't been cleaned away, or we've done something wrong. Either way, this seems like a small issue now but it may become a larger one if we continue to make the mistakes that lead us to this point. What is causing the file size to bloat out? How can we prevent it? Is there a way to clean our current file back to exactly what the scene contains and no irrelevant data?
Thanks for your time!
Your answer
Follow this Question
Related Questions
Scenes weight 100mb , around 50% of the build 2 Answers
Size increasing everytime i add new level in seperate scenes 1 Answer
issue regarding image file sizes 0 Answers
How to merge scenes in Unity? 4 Answers
New Game Object Same Scene 1 Answer