본문 바로가기
SW Programming/형상관리

Unity Scene git Merge하다가 comflict ... 돌아버리기전에 발견한 UnityYAMLMerge기능으로 자동머지하자 (git)

by Crystal.k 2021. 11. 26.

Unity Secen은 text editor로 열어보면 이해하기 힘든 id들과 값들로 이루어져있어서 사실상 수동 머지가 불가능하다는 것을 느꼈다. 같이 작업만 하면 백발백중 complict인데 도대체 어떻게 개발하지? 하다가

 

개발자끼리 Secen을 분리해서 서로 다른 Secen을 작업하면 좋겠지만, 피치못할 때가 있지 않은가!

 

다행히 Unity는 UnityYAMLMerge를 이용해서 scene과 prefab 파일을 머지할 수 있게 제공해주고 있다...

https://docs.unity3d.com/2021.2/Documentation/Manual/SmartMerge.html

 

Unity - Manual: Smart merge

Using external version control systems with Unity Smart merge Use the UnityYAMLMerge tool to merge sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments,

docs.unity3d.com

설명이 좀 더 친절한 아래의 글도 참고하자

https://github.com/anacat/unity-mergetool

 

GitHub - anacat/unity-mergetool: A quick guide to set up Unity's Smart Merge with Git

A quick guide to set up Unity's Smart Merge with Git - GitHub - anacat/unity-mergetool: A quick guide to set up Unity's Smart Merge with Git

github.com

 

세팅하는 게 좀 귀찮긴 한데 그래도 효과가 대단하니 할만하다.

1. 본인 pc의 "UnityYAMLMerge.exe " 위치를 확인해서 유니티 프로젝트의 .git>config 파일에 아래와 같이 추가해주면 된다. 새로운 유니티 프로젝트를 생성할 때마다 이 작업을 해야 한다는 것은 귀찮긴 하다.

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

 

2. 유니티 에디터에서도 설정을 확인해줘야 하는데 확인해보니깐 디폴트 값이었는지, 난 수정할 필요는 없었다.

유니티 에디터의 Settings> Editor에서 아래 두 개 값의 설정을 확인하면 된다.

- Version Control mode : Visible Meta Files 

- Asset Serialization mode : Force Text

 

그리고 실전이다.

git을 이용해서 merge 하다가 comflict 발생하는 상태에서 git bash를 열어서 아래의 명령어를 입력한다.

> git mergetool

git bash

 

 

 

만약 이것으로 성공적으로 merge 되지 않는다면.... 결국 또 수동 머지다...;-;

 

반응형

댓글