Search Unity

[Source Control] Prefab overrides changing order spontaneously.

Discussion in 'Prefabs' started by Adrien-Ninpo, May 9, 2019.

  1. Adrien-Ninpo

    Adrien-Ninpo

    Joined:
    Oct 2, 2018
    Posts:
    17
    Hi,

    This is not an issue that causes bugs or odd behaviours in Unity, but rather an issue with source control :
    Screenshot_1.png

    A chunk of data was moved around in the file. The data itself has not changed, the prefab itself has not changed, nothing in its behaviour has changed... Unity just decided it wanted to save the thing in a different way.
    If I discard these changes, Unity will do them again the next time i has the opportunity; if I keep them, Unity might still decide to change things again another time.

    This becomes an issue when manipulating large scenes or prefabs; it becomes hard to tell which changes are actually relevant to a commit, which are not, and keeping them makes us much more suceptible to getting obscure merge conflicts.

    From what I observed, this only happens to overriden properties of a prefab; files suceptibles to spontaneous changes are Scenes with prefabs, Prefab variants, and Prefabs with nested prefabs.

    The one thing I have not been able to figure out is what causes these changes / what decides what order the data is serialized in. Does anyone have any idea ?
     
    Peter77 likes this.
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    Hi,

    We have changed the sorting of overrides and they should be stable now, but it does mean that you will see scene and prefabs were the overrides might be shuffled until all are sorted correctly, then it should stop happening.
     
    SugoiDev and Adrien-Ninpo like this.
  3. Adrien-Ninpo

    Adrien-Ninpo

    Joined:
    Oct 2, 2018
    Posts:
    17
    Thanks for your reply,

    So you mean the order depends on the Unity version ?
    By the way, most of our projects are under 2018.3 as of now. Did you stabilize the sorting in 2019? or is the latest 2018.3 already shuffle-free ?
    I've been doing my best to only commit relevant changes, so the projects I'm working on are probably still carrying sorting orders from earliest 2018.3 versions.
     
  4. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    The latest 2018.3 should be shuffle free once all scenes and prefabs have been saved again.
     
    Adrien-Ninpo likes this.
  5. Alex_StudioDrydock

    Alex_StudioDrydock

    Joined:
    Jan 16, 2019
    Posts:
    9
    I have exactly this issue with 2019.1, we have two developers on the same version of Unity, and it is saving out different orders for properties for a number of prefabs, creating a lot of source control churn. In all cases the properties being shuffled are in the section:

    Code (csharp):
    1. PrefabInstance:
    2.   m_ObjectHideFlags: 0
    3.   serializedVersion: 2
    4.   m_Modification:
    5.     m_TransformParent: {fileID: 5805130152914501332}
    6.     m_Modifications:
    We found that restarting one of the instances of Unity has (temporarily?) fixed the issue (meaning that instance of Unity is now saving out the prefab in the same order as the other instance).

    I believe this started happening recently with 2019.1, and was not an issue for me under 2018.3.
     
  6. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    I am using 2019.1.2f1 and am also seeing this issue. Here is an examples of diff:

    upload_2019-5-26_14-59-42.png

    I have a base prefab called PartMeshRenderer, which each 'part' prefab in my game inherits from. The part prefabs then override the mesh property on the MeshFilter (Which was defined in PartMeshRenderer). So the result is a prefab override of the 'm_Mesh' property of the MeshFilter.

    After I do a build, if Unity decides to shuffle the serialisation, it is shuffled for *all* of the prefabs that inherit PartMeshRenderer. So in my source control client I can see 10-20 entries that look almost exactly like the image above, except referencing a different meshes (Since each prefab overrides the MeshFilters mesh with its own mesh). Here is another example, from the same commit:

    upload_2019-5-26_15-2-21.png

    Unfortunately I cannot confirm if this is the first time this is happened post fix. I will keep an eye on this and report back if it happens again. This way we will know for sure that the serialisation was shuffled post fix.
     
    Last edited: May 26, 2019
    Peter77 likes this.
  7. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Problem persists as recently as 2019.2.6f1
     
  8. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    This is fix and will soon be shipped and back ported to previous versions
     
  9. A_Savvidis

    A_Savvidis

    Joined:
    Jul 21, 2016
    Posts:
    98
    Is there a ticket assigned to this please? We are currently using 2018.4.3 and face this issue. I would really like to know the list of versions that this fix was ported to in order to make an informed desicion on our next version.
    Thank you @SteenLund