If you are looking for NewBehaviourScript.cs in order to change the line endings permanently (which is my preferred solution), the name and location has changed. It is now
Editor\Data\Resources\ScriptTemplates\81-C# Script-NewBehaviourScript.cs.txt
You can change the line endings as described above using Visual Studio, or in Notepad++ using Edit > Format Line Endings > Convert to … (whatever you prefer).
3 Likes
Thank you! This is the most sensible suggestion here.
In Visual Studio 2012:
File > Advanced Save Options
In “Line endings” select “Unix (LF)”
Toadwolf:
If you are looking for NewBehaviourScript.cs in order to change the line endings permanently (which is my preferred solution), the name and location has changed. It is now
Editor\Data\Resources\ScriptTemplates\81-C# Script-NewBehaviourScript.cs.txt
You can change the line endings as described above using Visual Studio, or in Notepad++ using Edit > Format Line Endings > Convert to … (whatever you prefer).
notepad++ have moved the option for this, it’s now: “edit > EOL conversion > format”
The easiest way to change the line endings without having to modify anything in VS is to go to the File > Advanced Save Options . In the Advanced Save Options window, under Line endings drop down, select the line ending you want to use and click OK. Then save the script again; this will automatically change the line endings in your script when you save it. When you go back into Unity, the error will disappear.
I prefer this answer, thanks.
In Visual Studio 2015:
Tool → Options → Environments → Documents → Check for consistent line ending on load.
It will then propose you to convert line ending on opening. Then just open the files and save them.
This worked for me, never got the error again
7 Likes
lmov
January 4, 2017, 11:48am
28
The easiest way to change the line endings without having to modify anything in VS is to go to the File > Advanced Save Options . In the Advanced Save Options window, under Line endings drop down, select the line ending you want to use and click OK. Then save the script again; this will automatically change the line endings in your script when you save it. When you go back into Unity, the error will disappear.
Great Solution!! very good!!
yagodar
January 24, 2017, 8:28am
29
anon_83463695:
OK, I fixed the problem by replacing the NewBehaviourScript.cs that is located in Unity\Editor\Data\Resources
By creating a new script using Windows it contains only CrLf for new lines. So now when I create a new cs script in Unity and edit it in Visual Studio all the line endings are the same. So no more warnings
omg! awesome solution! you saved my days in change Advanced Save Options each time I create script!! :):)
Elixir:
I’m using VisualStudio 2012 to write my scripts and I used to get these warnings.
To solve the problem just go to your scripts in VS and do:
Edit > Advanced > Format Document
That will stop the warnings.
Thank you, that fixed it in my Visual Studio 2010.
The easiest way to change the line endings without having to modify anything in VS is to go to the File > Advanced Save Options . In the Advanced Save Options window, under Line endings drop down, select the line ending you want to use and click OK. Then save the script again; this will automatically change the line endings in your script when you save it. When you go back into Unity, the error will disappear.
Thank you so much! This helped
Strin’em is supposed to do the trick. If you don’t like it you can uninstall it vis the Tools->Extensions and Updates Installed tab.
But I cannot save the text document in Unity\Editor\Data\Resources\ScriptTemplates in unity5.6beta
anon_83463695:
I’m using Unity 3D in combination with Visual Studio 2008 on a Windows 7 64 bit system.
When saving a cs file in Visual Studio and returning to Unity 3D I always get the following warning:
There are inconsistent line endings in the ‘someFileName.cs’ script. Some are Mac OS X (UNIX) and some are Windows.
This might lead to incorrect line numbers in stacktraces and compiler errors. Unitron and other text editors can fix this using Convert Line Endings menu commands.
I’ve seen that more people have this problem but they all are using OS X.
How can I fix this problem on my Windows machine?
UPDATE:
OK, I fixed the problem by replacing the NewBehaviourScript.cs that is located in Unity\Editor\Data\Resources
By creating a new script using Windows it contains only CrLf for new lines. So now when I create a new cs script in Unity and edit it in Visual Studio all the line endings are the same. So no more warnings
To save this file you need to execute visual studio with administrator rights.
anon_83463695:
UPDATE:
OK, I fixed the problem by replacing the NewBehaviourScript.cs that is located in Unity\Editor\Data\Resources
By creating a new script using Windows it contains only CrLf for new lines. So now when I create a new cs script in Unity and edit it in Visual Studio all the line endings are the same. So no more warnings
Thanks for this information. The add-in you mentioned was not compatible with Visual Studio 2017 , so for those in the same boat i found this add-in on the Visual Studio Marketplace and it installed and seems to work like a charm. Line Endings Unifier by Jakub Bielawa
https://marketplace.visualstudio.com/items?itemName=JakubBielawa.LineEndingsUnifier
1 Like
Mr_Jun
June 18, 2017, 8:00am
36
The easiest way to change the line endings without having to modify anything in VS is to go to the File > Advanced Save Options . In the Advanced Save Options window, under Line endings drop down, select the line ending you want to use and click OK. Then save the script again; this will automatically change the line endings in your script when you save it. When you go back into Unity, the error will disappear.
But I could’nt find Advanced Sace Options in visual studio
If you are on VS 2017 I dont think its there any more.
Seek another solution, there are more posted in this thread.
it’s just in the “save as” options now (not that that makes much sense…)
1 Like
Ah nice catch, I would never have seen that.
gig6
June 27, 2017, 6:35pm
40
Toadwolf:
If you are looking for NewBehaviourScript.cs in order to change the line endings permanently (which is my preferred solution), the name and location has changed. It is now
Editor\Data\Resources\ScriptTemplates\81-C# Script-NewBehaviourScript.cs.txt
You can change the line endings as described above using Visual Studio, or in Notepad++ using Edit > Format Line Endings > Convert to … (whatever you prefer).
Just opening the script with Visual Studio in the directory above and saving it (no changes to the file) fixed the problem for me.
1 Like