Unity には意味的に正しい方法でシーンやプレハブのファイルをマージすることができる UnityYAMLMerge というツールが組み込まれています。このツールは、コマンドラインからアクセスでき、サードパーティのバージョン管理ソフトウェアも利用可能です。
Editor ウィンドウ (Edit> Project Settings の順に移動し、Editor カテゴリを選択) で、サードパーティ製のバージョン管理ツール (Perforce や PlasticSCM など) を選択することができます。これらのツールの 1 つが有効になっている場合、Version Control 見出しの下に Smart Merge メニューが表示されます。メニューには 4 つのオプションがあります。
UnityYAMLMerge ツールは、Unity editor が同梱されています。 Unity が標準の場所にインストールされていると仮定すると、UnityYAMLMerge へのパスは次のようになります。
C:\Program Files\Unity\Editor\Data\Tools\UnityYAMLMerge.exe
または
C:\Program Files (x86)\Unity\Editor\Data\Tools\UnityYAMLMerge.exe
上は Windows用。
/Applications/Unity/Unity.app/Contents/Tools/UnityYAMLMerge
上は Mac OSX 用 (このフォルダーにアクセスするには、Finder から Show Package Contents コマンドを使用します)。
UnityYAMLMerge は、それがどのように未解決のコンフリクトまたは未知のファイルを続行するかを指定するデフォルトのフォールバックファイル( Tools フォルダーでも mergespecfile.txt と呼ばれます)が同梱されています。これはまた、ファイル拡張子に基づいて自動的にマージツールを選択しない(例えば、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
と入力します。UnityYAMLMerge がファイルをマージする方法をカスタマイズするには、mergerules.txt ファイルを設定します。これは、Unity インストールの Editor/Data/Tools
フォルダーにあります。
様々な設定オプションは以下の通りです。
Array (配列) の設定セクションでは、UnityYAMLMerge に指定したパスを配列として扱うように指示できます。すべての配列のデフォルトは、ハイブリッドモードで、いくつかの既知のヒューリスティックでマッチングを試みます。
[arrays]
set *.GameObject.m_Component *.fileID
set *.Prefab.m_Modification.m_Modifications target.fileID target.guid propertyPath
plain *.MeshRenderer.m_Materials
plain *.Renderer.m_Materials
Exclusions (除外) 設定セクションでは、どのパスをマージから除外するかを示します。両方が変更されている場合、これらは競合として扱われ、ユーザーが入力できるように表示されます。
[exclusions]
exclude *.MeshRenderer.m_Materials.*
exclude *.SpriteRenderer.m_Materials
exclude *.SpriteRenderer.m_Color
include *.ParticleSystem.InitialModule
exclude *.ParticleSystem.*
exclude *.ParticleSystem.InitialModule.*
# excludeDepend *.MonoBehaviour m_Script ^m_
excludeIfContains *.MonoBehaviour.* x y z
excludeIfContains *.MonoBehaviour.* r g b
Comparisons (比較) セクションでは、ユーザー設定に基づいて、浮動小数点値間の無視できる差を考慮します。有効にすると、浮動小数点の比較が相対的に行われ、相対的な誤差が考慮されます。比較は以下の方法で設定できます。
相対的な比較値は、イプシロンと、float の相対誤差の大きさに応じた比較のスケール方法を決定します。絶対的な比較カットオフ値は、float の比較が絶対からゼロからの相対に切り替わるポイントを決定します (グラフ上)。
ノート: 比較値は、float イプシロン (~0.00000011921) から 1.0 までの間でなければなりません。
[comparisons]
float *.Transform.m_LocalPosition.x 0.0000005
float *.Transform.m_LocalPosition.y 0.0000005
float *.Transform.m_LocalPosition.z 0.0000005
float *.Transform.m_LocalRotation.x 0.00005 0.001
float *.Transform.m_LocalRotation.y
float *.Transform.m_LocalRotation.z 0.00005 0.001
float *.Transform.m_LocalRotation.w
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.