Unity 包含一个名为 UnityYAMLMerge 的工具,能够以语义正确的方式合并场景和预制件文件。可从命令行中访问该工具,也可将其用于第三方版本控制软件。
在 Editor 窗口(菜单:__Edit > Project Settings__,然后选择 Editor 类别)中,可以选择第三方版本控制工具(例如 Perforce 或 PlasticSCM)。启用其中一个工具后,将在 Version Control 标题下看到 Smart Merge 菜单。该菜单具有四个选项:
UnityYAMLMerge 工具随附于 Unity Editor;假设 Unity 安装在标准位置,则 UnityYAMLMerge 的路径将是:
C:\Program Files\Unity\Editor\Data\Tools\UnityYAMLMerge.exe
or
C:\Program Files (x86)\Unity\Editor\Data\Tools\UnityYAMLMerge.exe
/Applications/Unity/Unity.app/Contents/Tools/UnityYAMLMerge
UnityYAMLMerge 附带了一个默认的回退文件(称为 mergespecfile.txt,也在 Tools 文件夹中),用于指定如何处理未解决的冲突或未知文件。此外,还可将其用作不会根据文件扩展名自动选择合并工具的版本控制系统(例如 git)的主要合并工具。默认情况下,mergespecfile.txt 中已列出最常用的工具,但可以编辑此文件以添加新工具或更改选项。
可从命令行中将 UnityYAMLMerge 作为独立工具运行(若要查看该工具的完整使用说明,可在运行时不带任何参数)。下面给出了常见版本控制系统的设置说明。
.unity
。merge -p %b %1 %2 %r
然后,按照相同的步骤添加 .prefab
扩展名。
将以下文本添加到 .git
或 .gitconfig
文件中:
[merge]
tool = unityyamlmerge
[mergetool "unityyamlmerge"]
trustExitCode = false
cmd = '<path to UnityYAMLMerge>' merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
将以下文本添加到 .hgrc
文件中:
[merge-patterns]
**.unity = unityyamlmerge
**.prefab = unityyamlmerge
[merge-tools]
unityyamlmerge.executable = <path to UnityYAMLMerge>
unityyamlmerge.args = merge -p --force $base $other $local $output
unityyamlmerge.checkprompt = True
unityyamlmerge.premerge = False
unityyamlmerge.binary = False
将以下文本添加到 ~/.subversion/config
文件中:
[helpers]
merge-tool-cmd = <path to UnityYAMLMerge>
.unity
。 <path to UnityYAMLMerge> merge -p %base %theirs %mine %merged
然后,按照相同的步骤添加 .prefab
扩展名。
.unity
扩展名。 <path to UnityYAMLMerge> merge -p "@basefile" "@sourcefile" "@destinationfile" "@output"
然后,按照相同的步骤添加 .prefab
扩展名。
merge -p $BASE $REMOTE $LOCAL $MERGED
。Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.