Inconsistent Line Endings Error

I have made this quick script, to crossfade an animation with my walk and run animations.

But it comes up with a weird error saying:

There are inconsistent line endings in the ‘Assets/attackscript.js’
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.

My script is:

function Update () {

animation["my_animation"]. layer = 1;

if(Input.GetMouseButtonDown(0))
	animation.CrossFade("my_animation");

}

What am I doing wrong to get this error?

Thanks,

Sorry to undelete this. I had written the answer then found out when I tried posting it that you deleted the question. Its a good question so I left it up for others to see.

2 Answers

2

The solution to your problem depends on what external script editor you are using. The error is caused by as it says, line-endings. Its not a coding error in the sense that you typed something wrong so that should be a relief.

Somewhere in your script editor, there should be a drop down for line endings. Find the platform you’re currently working on and choose that one. That should fix it.

To add some help to this I was using Code::Blocks IDE outside of unity so I could look at two parts of code at the same time (one in mono and one in C::B). I am getting this error - I think if I would have coded the entire file in either monodevelop or code::blocks I would be ok, but since I edited the file in c::b after creating and coding the bulk in mono I think one is saving with mac format and one with windows. You can find the End-Of-Line mode in C::B under Settings > Editor... Note: LF seems to be the format unity uses.

@peterg I can not seem to find the drop down for line ending in visual studios. Can you point me in the right direction? Thanks

VS2017: Inconsistent Line Endings Visual Studio Community 2017 - Stack Overflow