I was having trouble where Git shows a lot of changes (for my case, about ~3000 diff change since I have many objects in the scene) after saving scene (.unity file) in Unity3D, even though there are no changes made on the scene file (.unity file).

enter image description here enter image description here

Upon checking, I noticed Unity3D recompiled the scene file and some values are just in a different order.

How do we prevent this from happening?

Steps to reproduce:

  1. Open the scene file.
  2. Disable and enable back any GameObject (just to trigger Unity to think there're changes, so you can save the scene file).
  3. Save the scene file.

As far as I know, this is caused by a bug or design flaw in the Unity Editor. When you add UI prefabs to a scene, the Editor is very aggressive about generating property overrides for most properties on your UI prefabs, even when those overrides aren't actually needed. Not only does this increase the size of the scene file, it can completely break your UI if you make changes in the prefab and those changes don't show up correctly in the scene because of undesired overrides. IIRC this problem has gotten worse in newer versions of Unity.

If you have a simple, 100% reproducible example, I'd suggest reporting this to Unity as a bug.

  • \$\begingroup\$ Can't reproduce in a new project. Occasionally I will get that when there're more changes. I'm suspecting it could be upgrading to newer unity version where it might need to upgrade the existing scene file as well \$\endgroup\$ – kkl Jul 30 '20 at 9:15
  • \$\begingroup\$ @kkl I was able to reproduce in a new project and reported it to Unity. \$\endgroup\$ – Kevin Jul 30 '20 at 17:05
  • \$\begingroup\$ @kkl I think this issue has been fixed or at least partially mitigated in the last few Unity updates. \$\endgroup\$ – Kevin Dec 25 '20 at 2:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.