I would like to suggest to add another option here that fixes line endings automatically, so I don’t need to open each file in a text editor that supports those conversion.
If Unity detects line endings are not as specified as in the new “Force Line Endings For Scripts” setting, it would fix those automatically.
The new “Force Line Endings For Scripts” setting should provide the same modes: OS Native, Unity, Windows and additionally “Disabled”.
It would be a useful update, but if you’re using Visual Studio you could install the free ‘Stripem’ add-on which offers both manual and automatic recognition and correction.
I generally like the idea, but I also want to chime in with concerns regarding large projects and performance. Unity already parses all script files and checks their line endings, which itself should be a fast process. However, automatically fixing the line endings might be slow when there are many large script files in the project. This would need to be profiled, to make a decision, but in case this would cause any slowdowns, I would prefer a menu command to fix line endings at a convenient time. As a worst case, in a project I was working on, we had a dozen script files with approx. 35k lines of generated code. So, I would benchmark with this scope.
If this feature would be optional, it wouldn’t harm anyone who doesn’t use it, however, automatically changing script files can also cause unwanted merge conflicts for users in teams, which speaks against the usefulness of this feature. For example, if I see a few logs, I as one of many developers, can go through the list and fix my own scripts one by one in Visual Studio and then commit to source control. If Unity would automatically fix all scripts, I could be causing merge conflicts with developers who are currently refactoring the same classes and make many changes.
“Many text editors” apparently doesn’t include Unity itself.
When will these tool programmers realise nobody cares about line endings in 2020? Or actually, nobody should care but somehow we are taught to have an opinion about it. By GIT and now by Unity devs. They can take away that completely unnecessary noise by just ignoring that stuff and deal with it in the Editor itself. Visual Studio can do that, Beyond Compare can do that, Notepad++ can do that… so just go back with your warning to 1988.
Unity should not be educating me about the dangers of mixed line endings. Show me a tool that doesn’t function without correct line endings and I’ll show you how that’s irrelevant because I’m not using that tool.
/rant
Or just have it autocorrect the lines… It could even give you an option, if you really feel it might be an issue with slowing down build time. But this is crazy annoying because it can lead to issues finding where your errors are occurring in your scripts.
Ah the unending problem with Unity and Visual Studio - I hate this warning in Unity and probably there will be an option to ignore soon as I believe one is coming for ‘minor’ warnings.
Until then if Unity and Visual Studio could just auto-sync on line endings it would be nice as I forget the best work-around and VS plugins get lost as versions change!