Sun Guangdong 2015.6.14
Before the unity5.x version, we opened with a text editor such as sublime text. Unity. Prefab is a text content that can be seen in YAML format, but in unity5.x when looking at. Unity. Prefab file has become a binary file The
Let's take a look at the internal tools that unityprovides us with: Smart merge
Unity uses something called Unityyamlmerge , a tool that combines scenes and prefabricated files in a semantically correct way. The tool can be accessed from the command line and is also available to third-party version control software interfaces.
Smart Merging (intelligent merge) settings in Unity
In the Editor settings (menu:Edit > Project Settings > Editor), you can select a third-party version control tool (such as perforce or PLASTICSCM). When you enable one of these tools, you will see the menu under the smart merge (Smart Combine) versioning heading. the menu has four options:
- Off: Do not use smart merge preferences, only the default merge tool.
- premerge: Enable smart Merge, accept clean merge. The unclean merge will be the basis for creating the premerged version. Then, use these default merge tools.
- Ask: Enable smart Merge When a conflict occurs, display a dialog box for the user to resolve it (this is the default setting).
Set Unityyamlmerge for third-party tools
The Unity Editor comes with unityyamlmerge tools; assuming unity is installed in a standard location, you will see the path to the Unityyamlmerge:
C:\Program Files\Unity\Editor\Data\Tools\UnityYAMLMerge.exeorC:\Program Files (x86)\Unity\Editor\Data\Tools\UnityYAMLMerge.exe
...... Have Windows and
/Applications/Unity/Unity.app/Contents/Tools/UnityYAMLMerge
...... There is Mac OSX (use the Show package content from Finder command to access this folder).
Unityyamlmerge comes with a default fallback file (also known as Mergespecfile.txt in the Tools folder), which specifies how unresolved conflicts or unknown files should be handled. This also allows you to use it as the primary Merge tool for version control systems (such as Git), with no auto-select Merge tool based on the file name extension and the most commonly used tools listed in Mergespecfile.txt. However, you can edit this file to add a new tool or to make the re-election.
you can run Unityyamlmerge as a standalone tool from the command line (you can see the full usage instructions run without any parameters). The settings for the common version control system are described below.
p4v
- See the first preferences > Merge
- Select Other application
- Click the Add button.
- in the Extension field, type
.unity
.
- In the Application field, type the path to the Unityyamlmerge tool (see above).
- In the Arguments field, type merge-p%b%1%2%r
- Click Save.
Then, follow the same program to add the .prefab
extension.
Git
Add the following text to your .git
or .gitconfig
file:
[merge] tool = unityyamlmerge [mergetool "unityyamlmerge"] trustExitCode = false cmd = ‘<path to UnityYAMLMerge>‘ merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
Mercurial
The following text is added to the .hgrc
file:
[merge-patterns] **.unity = unityyamlmerge **.prefab = unityyamlmerge [merge-tools] unityyamlmerge.executable = <path to UnityYAMLMerge> unityyamlmerge.args = merge -p $base $other $local $output unityyamlmerge.checkprompt = True unityyamlmerge.premerge = False unityyamlmerge.binary = False
Svn
Add the ~/.subversion/config
following content to your file:
[helpers] merge-tool-cmd = <path to UnityYAMLMerge>
Tortoisegit
- Come to Preferences > Diff Viewer > Merge Tool and click the Advanced button.
- In the pop-up window, type in the extension field
.unity
.
- In the External program field type:
<path to UnityYAMLMerge> merge -p %base %theirs %mine %merged
Then, follow the same program to add the .prefab
extension.
Plasticscm
- Come to Preferences > Merge Tools and click the Add button.
- Select the External Merge tool.
- Select Use with files that match the following pattern.
- Add a
.unity
name extension.
- Please enter a command:
<path to UnityYAMLMerge> merge -p “@basefile” “@sourcefile” “@destinationfile” “@output”
Then, follow the same program to add the .prefab
extension.
Sourcetree
- Go to Tools > Options > Diff.
- Select Custom from the merge Tool drop-down list.
- In the Diff command text field, type the path to Unityyamlmerge.
merge -p $BASE $REMOTE $LOCAL $MERGED
the type is in the Arguments text field.
Let's take a look at UNity 's fast and efficient yaml Merge:
Interested in reading this post:
http://blogs.unity3d.com/2015/06/02/how-we-do-fast-and-efficient-yaml-merging/
Finally, let's introduce a unity plugin: unimerge
About his documents here, you can take a look: Http://wiki.unity3d.com/index.php/UniMerge
In particular, the conflict window merging function is also very good.
??
Git version Control Library extensions