4
votes

I am trying to merge a Unity scene my partner and I have been working on, using Smart Merge. My other assets and prefabs resolved the conflicts with Smart Merge just fine; however, one scene isn't merging at all.

In my .git/config file I added

[merge]
tool = unityyamlmerge
[mergetool "unityyamlmerge"]
trustExitCode = false
cmd = 'C:\\Program Files\\Unity\\Editor\\Data\\Tools\\UnityYAMLMerge.exe' merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"

I've also included a .gitattributes file containing

*.unity binary
*.prefab binary
*.asset binary

I've set my asset serilialization to 'Force Text' and Version Control to 'Visible Meta Files.'

Our prefabs and other assets merged fine, but one of our scenes doesn't merge at all.

When running the git mergetool command in the terminal, it displays the conflicts for this specified scene, but then returns this at the end:

Left  563852304.Light.m_Color.r add as 0.8962264
Right 563852304.Light.m_Color.r add as 0.9433962
Left  610301896.GameObject.m_IsActive add as 0
Right 610301896.GameObject.m_IsActive add as 1
Left  610301898.Transform.m_LocalPosition.x add as -13.07
Right 610301898.Transform.m_LocalPosition.x add as -14.31
Left  610301898.Transform.m_LocalPosition.y add as 2.6
Right 610301898.Transform.m_LocalPosition.y add as 2.14
Left  610301898.Transform.m_RootOrder add as 8
Right 610301898.Transform.m_RootOrder add as 7
Left  869912137.Transform.m_LocalPosition.x add as -7.36
Right 869912137.Transform.m_LocalPosition.x add as -7.333
Left  869912137.Transform.m_LocalScale.x add as 4
Right 869912137.Transform.m_LocalScale.x add as 4.0070143
Conflict handling:
Xmas-Prototype-01/Assets/_Scenes/InitScene.unity seems unchanged.
Was the merge successful [y/n]?

There's more conflict, but too much to list.

This is the only file that hasn't merged with my local branch. Is there a way I can get this one scene to merge?

Thank you!

2

2 Answers

3
votes

I know this isn't much of an answer. The typical best practice when working with scenes and git, is to only have one person working on a scene at a time. We have been using a "scene hat".

What we've been doing (indie studio) is to additively load multiple scenes, so the level designer(s) have one scene without functionality to work on, and programmers (who don't need a lot of time with a scene) have a "bootstrap" scene, which contains game functionality.

0
votes

I believe you should ensure yamlmergetool can handle .unity, .prefabs, and anything else as plain text (not binary) by adding this in your .gitattributes

*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf

One of the things that annoys me about YAML is how it seems there’s no sense to where text is added through edits in the scene. If you add a GameObject to the very bottom of the scene list it appears in a random place in the source of the YAML. If you move it, rather than move the source code, it changes a property called m_RootOrder to reflect the zero index order of the root. When the yamlmergetool starts it quickly gets confused because source code editors are dealing with lines numbers + blocks of code that look the same. As @thefragen has pointed out, a good way to deal with this is to have your collaborators work in separate scenes to avoid potential merge issues.