I get this everytime, yet I just use “Advanced Save Options” on Visual Studio Community 2015 in order to convert it into Windows CR-LF without even knowing what it does and what it means.
What does it mean? Is it okay to convert it? What does it do?
line endings are the special characters that tell the text editors “this is the end of the line”… Windows and MacOS have different special characters (Unix/Linux is probably different again ). I think the default unity script template uses the mac version.
Yes it’s fine to convert them, it’s just Visual Studio pointing out an inconsistency between the file and the operting system you’re using… not converting them shouldn’t cause any problems either to be honest.
Thanks
MacOS is a Unix system
The only problem you’ll find if you ignore this is that Unity may report the line number wrongly in a rare case so you’ll jump to the wrong place. Theoretically.
To simply avoid this just replace the script template with a fixed one. This has to be done after every Unity update though.
But I would apreciate if the installer would detect the OS it runs on and install the proper script template automatically. Its not rocket science.
It clutters your console and makes it much harder to spot relevant warnings.
AFAIK there is also a setting in Visual Studio to automatically make this but you still have to open the file manually to make the warning disapear.
There’s a visual studio plugin named Strip’em which automatically sets line endings to whatever you want.
What the hell is CRLF all about?
There’s two main line endings:
LF (Unix; so Linux and modern OSX)
CR+LF (Windows)
To make things confusing, there’s a third one that used to be employed by OSX: CR. It’s generally refered to as “Mac line endings”, even though apparently modern macs don’t use it.
CR stands for “carriage return” and LF for “line feed”. This is a hold-over from the early days where you sent one character at a time to printers, and had to explicitly tell them to do those two things - move the printing head back to start, and feed a new line of paper.
Unix did the smart thing and reduced the concept of a new line down to one symbol. Microsoft did the smart thing and kept backwards-compatibility. Now both systems have the concept too deeply ingrained for us to ever get a unified way of doing this.
Would be nice if there was a way to fix this with an editor script - automatically force line endings to one format on import. Then I could call it ‘HappyEndings.cs’…
Doesn’t look like you can preprocess a script in the same way as OnPreprocessModel, though?: ( Unity - Scripting API: AssetPostprocessor )
Is there a VS plugin that can be configured to do this automatically on save?
I don’t know, is there?
I lol’ed
It didn’t look like it’d do it automatically on-save? (I can do it manually with File->Advanced Save Options without a plugin - but I was looking for an automated solution to eliminate this warning once and for all, as it’s a daily annoyance)
(I’ve not messed with the templates as that might fix it for one machine/user, but not the whole team)
Edit - ok, it does do it on save… will give that a go
what’s always bugged me is, you run different installers when you install on windows/mac/whatever so couldn’t they just have the templates match whatever it is being installed on… (no idea how the installers work :p:) )
First line on the page I linked:
“This Add-in converts the text format of a file when it is saved in Visual Studio.”
Do you even read, bro?
yip, that’s a relief! Thanks
this doesnt show up on mac is there a way of making this work on mac