Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Scene Merge Conflict With Git

Discussion in 'Editor & General Support' started by qiveal, May 19, 2022.

  1. qiveal

    qiveal

    Joined:
    Jan 31, 2022
    Posts:
    320
    How do I fix a github merge conflict when it involves the scene?
     

    Attached Files:

  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,890
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,519
    YAML cannot be merged reliably.

    Unity offered a scene merger plugin but we never had much luck with it.

    Best approach: never merge scenes or prefabs.

    Second-best approach:
    - clone and rename the item in one branch
    - do the merge, resolve the conflict by taking the OTHER branch's instance
    - open both the original and clone at the same time and hand resolve the differences
    - delete the clone

    Third best: go to whichever branch has the least amount of work and discard it, then manually re-apply that work directly to the other branch. This gets into the importance of good commit messages so you can reason about what work each branch might contain.

    Finally, it may be VERY advantageous to use additive scenes, which lets you slice up your scenes into lots of small unrelated parts, loading all the parts additively. I swear by this method to keep each scene file as physically small as possible. Here's more reading:

    Additive scene loading is one possible solution:

    https://forum.unity.com/threads/right-way-for-performance-divide-scene.1023673/#post-6630961
    https://forum.unity.com/threads/right-way-for-performance-divide-scene.1023673/#post-6754330

    https://forum.unity.com/threads/problem-with-canvas-ui-prefabs.1039075/#post-6726169

    A multi-scene loader thingy:

    https://pastebin.com/Vecczt5Q

    My typical Scene Loader:

    https://gist.github.com/kurtdekker/862da3bc22ee13aff61a7606ece6fdd3

    Other notes on additive scene loading:

    https://forum.unity.com/threads/removing-duplicates-on-load-scene.956568/#post-6233406

    Timing of scene loading:

    https://forum.unity.com/threads/fun...ject-in-the-second-scene.993141/#post-6449718

    Also, if something exists only in one scene, DO NOT MAKE A PREFAB out of it. It's a waste of time and needlessly splits your work between two files, the prefab and the scene, leading to many possible errors and edge cases.

    Two similar examples of checking if everything is ready to go:

    https://forum.unity.com/threads/daily-events-and-content-changes.1108202/#post-7143713

    https://forum.unity.com/threads/uni...on-before-other-scripts.1153739/#post-7401794
     
    Last edited: May 19, 2022
    PraetorBlue likes this.
  4. qiveal

    qiveal

    Joined:
    Jan 31, 2022
    Posts:
    320
    Thanks