unityYAMLMerge messing up merged code by adding line breaks

For some reason, unityYAMLmerge in PlasticSCM when used with prefabs adds line breaks to pretty much all existing lines (even lines that needn’t be merged)

This can’t be by design can it?, as this makes double checking merges completely impossible.

Am I doing something wrong? Is this a bug?

See attached screenshot.

Unity 2021.3.20f with PlasticSCM (or whatever the f it’s now called) 11.0.16.8060

Yeah, it’s an old bug of UnityYAMLMerge.exe, and so far they haven’t bothered to fix that :-/
See footnote here: Unity YAMLMerge [Uninomicon]
So PlasticSCM is not at fault, but since it internally calls UnityYAMLMerge, this problem becomes visible.

There is a relatively new (>=2020.x?) Editor setting SerializeInlineMappingsOnOneLine, which appears to be ON by default - but UnityYAMLMerge completely ignores this, and always creates output emulated with this setting OFF.

9250161--1293285--YAML_Inline_Linebreaks.png

Until Unity fixes this, your best bet will probably be to DISABLE this flag, and force-reimport all scenes+prefabs once (untested - will probably not help directly, as a re-import generally doesn’t modify the Assets, only the metadada).
Another method would be to disallow PlasticSCM from calling UnityYAMLMerge, by configuring its MergeTools for the entry “.prefab;.unity”, so it uses the regular diff tool instead - at the cost of possibly slightly less intelligent diffs.

2 Likes

Hello, any news on this? Did somebody report the issue with UnityYAMLMerge tool to Unity?

Hi @svenneve ,

Thanks for bringing this to our attention. I will try to reproduce the situation when possible and report this issue to the relevant team. Once the report is completed, I will share the update here.

1 Like

Thanks, I have trouble reproducing it myself, but if you have a case number or the report, I’ll check if I can send you that particular changeset of the project, if that helps ofcourse.

Hi @svenneve ,

The issue was reproduced by a different team, and it was reported to the relevant team. Once the fix is available, I will update it here.

2 Likes

Great to hear! Thanks @rednbrick ! :sunglasses:

@rednbrick Any updates here?

The team is still working on the investigation as the issue appears randomly based on the version of the engine. Once there’s a further update, it will be updated here as well.

We have a similar issue.

Unity will serialize our file like this:

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 0}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 61002b575d8440828fe4e0936c1d3850, type: 3}
  m_Name: en_StringLibrary
  m_EditorClassIdentifier: 
  GUID:
    m_data: f4963499c84f22b405c4ee219ae44e19
  Version: 0
  Entries:
    - UID:
        m_data: 4f15f1141e3676765d095c02046e5095
      Key: Content/Story/Townies/Generic/JoinTown01_02
      Value: But as this is a demo I'll just make it easy for you and start living
        here!
      Comment: null
      State: 0

But YAMLMerge will serialize it like this :

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 0}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 61002b575d8440828fe4e0936c1d3850, type: 3}
  m_Name: en_StringLibrary
  m_EditorClassIdentifier: 
  GUID:
    m_data: f4963499c84f22b405c4ee219ae44e19
  Version: 0
  Entries:
    - UID:
        m_data: 4f15f1141e3676765d095c02046e5095
      Key: Content/Story/Townies/Generic/JoinTown01_02
      Value: But as this is a demo I'll just make it easy for you and start living here!
      Comment: null
      State: 0

(Note, the word 'here! in the entries section moves to the same line in the YAMLMerge).

It seems to happen more frequently with lines that end in spaces.

It almost seems like Unity, and UnityYAMLMerge are using different rules for how to handle the length of lines.

Was there a resolution for this? UnityYAMLMerge is adding a line break to lots of objects before the ‘type: 3’ text.

This issue is still known and the relevant team is working on it. When the fix is available, you will be informed via this forum.

1 Like

Hello! Any news?