I created a new c# script and started with a comment to explain what my script does. Once I were done writing my comment I went down two lines and wrote a function there, the function Foo. Realizing I should create the function Bar first I selected the line between my comment and Foo, pressed return and created the new function Bar. I now noticed an unwanted indentation had been made:
public class ExampleScript : MonoBehaviour
{
//This is my comment
void Bar() {
}
void Foo() {
}
}
Testing it again I notice the indentation occurs as I create the new line by pressing return.
If I select everything and press Ctrl-K, Ctrl-F then it is as it should.
I do not know why I encountered this problem first now. Maybe it’s because I just installed Unity version 2019.3.11f1? I’ve been unable to find a solution to this, actually I found it difficult finding others with the same problem. Naturally, all help is appreciated.
I’m using Unity 2019.3.11f1 and Visual Studio 2017.
Settings in visual studio that might be relevant:
Tools → Options → Text Editor → C# → Tabs:
Indenting: Smart
Tab: Keep tabs