Search Unity

Question Is there any way to specific line ends for assets serialization?

Discussion in 'Editor & General Support' started by leozzyzheng2, Oct 1, 2021.

  1. leozzyzheng2

    leozzyzheng2

    Joined:
    Jul 2, 2021
    Posts:
    63
    I found unity will use both LF and CRLF as line ends for assets file serialization. For example, I have a scriptableobject saved on disk with CRLF before, after one day, I found unity will use LF to serialize it to disk. It results that I will see diff in version control like svn and git even there is only line ends different.

    It will slow down our workflow cause we will check one by one whether the modify is meaningful and it will also conflict with other people's modify.

    So I want know whether there is a switch for line ends for serialization?

    I'm using 2020.3.17f1 on windows 10.
     
  2. ColinAmuzo

    ColinAmuzo

    Joined:
    Mar 20, 2013
    Posts:
    46
    We are also seeing this, with the exact same Unity version coincidentally. Certain prefabs seem to get flagged to be written to disk only after playing our game in the editor. The only changes are line endings.

    Thing is, with one of the prefabs (prefab A, say), once the line endings have changed, we get "Missing Prefabs" in other prefabs in which prefab A is nested. No guids have changed anywhere. I don't know if there's some checksum validation that failing after the line endings change. Very weird. If I revert the line ending changes to prefab A, that fixes the missing prefabs.

    So as far as i can see, there are 3 issues:
    1. Seemingly unnecessary writing of prefab to disk.
    2. Not preserving line endings of existing file.
    3. Somehow breaking nested prefab refs after line ending change.
     
    Last edited: Apr 7, 2022
  3. spashkovskiy1

    spashkovskiy1

    Joined:
    Sep 5, 2022
    Posts:
    12
    In my case, Unity also uses both LF and CRLF for assets. Sometimes it changes one line ending with another. This leads to additional changes in the VCS and additional conflicts when merging assets. And I don't understand how to set certain line ending for all my assets forever.

    Unity 2022.1.14
     
    AdamBebkoFV likes this.