Inconsistent line endings in Visual Studio for Mac

Continuing the discussion from Unity / VS / MAC Error:

Hello everyone,

@Nina in the post above you gave a solution to someone who had exactly the same issue as me but it didn’t help for some reason.

I’m using Visual Studio for Mac 8.9.5 and Unity 2020.3.0f1.
Everything went very smoothly for the first 2 sections of the Unity 3D course but as soon as I saved the very first script for the Rocket Boost I had the following warning :

There are inconsistent line endings in the ‘Assets/Scripts/Movement.cs’ script. Some are Mac OS X (UNIX) and some are Windows.
This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.

So I searched a bit on the web and I found the same solution you gave someone a while ago on Stackoverflow but after changing the setting and restarting both Visual Studio and Unity I still have the same issue. I even deleted the original script and rewrote a short one and it still gives me the warning.

Here is the very simple test code.

public class Movement : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        ProcessIntput();
    }

    void ProcessIntput()
    {
        if (Input.GetKey(KeyCode.Space))
        {
            Debug.Log("Test");
        }
    }
}

Would anyone have an idea ?

@Rob I saw that you gave another solution that I also tried but sadly Visual Studio for Mac doesn’t give us the option to change the format of a file while saving it. Or at least I didn’t find the option :confused:

Hi FlyingWhale,

Maybe you could test the following solution for your Movement script:

If that worked, go to Unity\Editor\Data\Resources and open NewBehaviourScript.cs (and maybe also other templates). Open the script in VS and save it with the correct line endings (UNIX). This way, when you create a new script in Unity, that script, which is based on the template that you edited, will have the correct line endings.

Please let me know if it worked. :slight_smile:


See also:

Thanks for your answer @Nina

It worked for me, I hope this can help others :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms