Version: 2020.2
Using external version control systems with Unity
Multi-Scene editing

Smart Merge

Unity incorpora una herramienta llamada UnityYAMLMerge que puede fusionar tanto archivos de escena como prefab en una manera semántica correcta. La herramienta se puede acceder desde la linea de comando y también está disponible a software de terceros de control de versiones.

Configurando Smart Merging en Unity

In the Editor window (menu: Edit > Project Settings, then select the Editor category), you have the option to select a third party version control tool (Perforce or PlasticSCM, for example). When one of these tools is enabled, you will see a Smart Merge menu under the Version Control heading. The menu has four options:

  • +Off*: Utilice solamente la herramienta de fusion predeterminada en las preferencias sin ninguna smart (inteligente) fusión.
  • Premerge: habilita el smart merging (fusión inteligente), acepta fusiones limpias. Unas fusiones no limpias crearán versiones pre-fusionadas de base, sus y mis versiones del archivo. Luego, utilice a estos con la herramienta predeterminada de fusión.
  • Ask: habilita el smart merging pero cuando un conflicto ocurre, muestra un diálogo para que el usuario lo resuelva (esta es la configuración predeterminada).

Configurando UnityYAMLMerge para su Uso con con Herramientas de Terceros

La herramienta UnityYAMLMerge es lanzada con el editor de Unity; asumiendo que Unity está instalado en la ubicación estándar, la ruta a UnityYAMLMerge será:

C:\Program Files\Unity\Editor\Data\Tools\UnityYAMLMerge.exe

o

C:\Program Files (x86)\Unity\Editor\Data\Tools\UnityYAMLMerge.exe

…en Windows y

/Applications/Unity/Unity.app/Contents/Tools/UnityYAMLMerge

…en Mac OSX (utilice el comando Show Package Contents desde el Finder para acceder a esta carpeta).

UnityYAMLMerge es lanzado con un archivo fallback predeterminado (llamado mergespecfile.txt,también en la carpeta Tools) que específica cómo debería proceder con los conflictos sin resolver o archivos no conocidos. Esto también le permite a usted utilizarlo como la herramienta de fusión principal para sistemas de control de versiones (como lo es git) que no seleccionan automáticamente las herramientas smart merge basadas en las extensiones de los archivos. Las herramientas más comunes ya están listadas por defecto en mergespecfile.txt pero usted puede editar este archivo para agregar nuevas herramientas o cambiar opciones.

Usted puede ejecutar UnityYAMLMerge como la herramienta standalone desde la linea de comando (usted pude ver las instrucciones completas de uso al correrlo sin argumentos). Las instrucciones de configuración para los sistemas de control de versiones comunes se dan abajo:

P4V

  • Vaya a Preferences > Merge.
  • Seleccione Other application.
  • Agregue el botón Add.
  • En el campo de extensión, ingrese .unity.
  • En el campo de Application, ingrese la ruta a la herramienta UnityYAMLMerge (ver arriba).
  • En el campo de Arguments, ingrese merge -p %b %1 %2 %r
  • Click Save.

Luego, siga el mismo procedimiento para agregar una extensión .prefab.

Git

Agregue el siguiente texto a su archivo .git o .gitconfig

    [merge]
        tool = unityyamlmerge

        [mergetool "unityyamlmerge"]
        trustExitCode = false
        cmd = '<path to UnityYAMLMerge>' merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"

Mercurial

Agregue el siguiente texto a su archivo .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

SVN

Agregue lo siguiente a su archivo ~/.subversion/config:

    [helpers]
        merge-tool-cmd = <path to UnityYAMLMerge>

TortoiseGit

  • Vaya a Preferences > Diff Viewer > Merge Tool y haga click en el botón Advanced.
  • En el popup, ingrese .unity en el campo de extensión.
  • En tipo de campo External Program:
    <path to UnityYAMLMerge> merge -p %base %theirs %mine %merged

Luego, siga el mismo procedimiento para agregar una extensión .prefab.

PlasticSCM

  • Vaya a Preferences > Merge Tools y haga click en el botón Add.
  • Seleccione External merge tool.
  • Seleccione Use with files that match the following pattern.
  • Agregue la extensión .unity.
  • Ingrese el comando:
    <path to UnityYAMLMerge> merge -p "@basefile" "@sourcefile"  "@destinationfile" "@output"

Luego, siga el mismo procedimiento para agregar una extensión .prefab.

SourceTree

  • Vaya a Tools > Options > Diff.
  • Seleccione Custom en el desplegable Merge Tool.
  • Ingrese la ruta a UnityYAMLMerge en el campo de texto Merge Command.
  • Ingrese merge -p $BASE $REMOTE $LOCAL $MERGED en el campo de texto Arguments.

Configuring mergerules.txt

To customize how UnityYAMLMerge merges files, configure the mergerules.txt file. This is available in the Editor/Data/Tools folder of your Unity installation. The various configuration options are as follows.

Arrays

The arrays configuration section tells UnityYAMLMerge to treat the specified path as an array; either as a “set” with a key value, or as a “plain” array without key values. The default for all arrays is to do a hybrid mode and try to match with some known heuristics.

  • <mode> is one of “set” or “plain”

Example (as per default mergerules file)

[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

The exclusions configuration section indicates which paths to exclude from merging. If both sides have been modified, they are then treated as a conflict and will show up for user input.

  • <mode> is one of “include”, “exclude”, “includeIfContains”, “excludeIfContains”

Example (as per default mergerules file)

[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

The comparisons section takes into account negligible differences between float values to ignore per user settings. When enabled, floating point comparison is done relatively to account for relative error. You can configure comparison in the following ways:

  • “float” <float value to compare> (This sets epsilon to a default value close to machine epsilon)
  • “float” <float value to compare> <relative comparison value and absolute cutoff>
  • “float” <float value to compare> <relative comparison value> <absolute comparison cutoff>

The relative comparison value determines epsilon and how comparison will scale with the size of the floats’ relative error. The absolute comparison cutoff determines at which point float comparison switches from absolute to relative from zero (on a graph).

Note: Comparison values should be between float epsilon (~0.00000011921) and 1.0

Ejemplo

[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
Using external version control systems with Unity
Multi-Scene editing
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961