Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 1.76 KB

README.md

File metadata and controls

16 lines (12 loc) · 1.76 KB

What is EditorConfig?

EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems.

As of Visual Studio 2017, the Visual Studio IDE now supports EditorConfig natively without requiring any additional plugins.

EditorConfig and Unity?

Ordinarily, you would just add an .editorconfig file to your Visual Studio solution and be done with it. However, every time a script/code file in a Unity project is added, deleted or renamed, the Visual Studio/MonoDevelop solution and its associated project files are regenerated by the editor, wiping out any manual changes you had made to the project.

To circumvent this, we can utilize the Visual Studio Tools extension that's automatically installed alongside Visual Studio and intercept the .sln file to inject a reference to .editorconfig before the whole thing gets written to disk.

Instructions

  • Download the EditorConfigSolutionFileGenerator.cs script and drop it in an Editor folder within your project.
  • Download the (or provide your own) .editorconfig file and place it in the root folder of your Unity project (i.e. at the same folder level as Assets/).
  • Forcibly regenerate your .sln file by deleting it from the project root and then choosing Assets -> Open C# Project in the Unity editor.
  • Tweak .editorconfig to your liking, as described here: https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2017