Coding tools: ScriptInspector, VisualStudio & Resharper

Coding tools are important for programmers, and using the right editors and options make a big difference to your productivity.

MonoDevelop is terrible

If you’re not using Windows and can’t run Visual Studio, you will have to put up with MonoDevelop’s problems or use ScriptInspector or some other alternate editor.

  • MonoDevelop doesn’t allow word wrap (80 line limit is nice but it greatly interferes with using XML comments)
  • MonoDevelop indents code crazily (Does anyone know a way to override this?)

Visual Studio

If you have Windows, download Visual Studio Community Edition.

Configuring Visual Studio

Panels to the right

  1. Collapse all the side and bottom panels by clicking little push pin buttons at the top.
  2. To maximize viewable area on vertical monitors, move the Toolbox from left to right.

Word wrap on

  1. Turn word wrap on with Edit menu / Advanced / Word Wrap.

ScriptInspector 

ScriptInspector is an alternative to MonoDevleop and Visual Studio that lets you edit code inside Unity and it works much better than MonoDevelop for most coding on Mac. It is worth the money if you hate MonoDevelop.

  • Faster than launching MonoDevelop or Visual Studio, Script Inspector will save you lots of time.
  • Mac users: Saving code by hitting control-S might seem weird.
  • Note: Unity needs to be able to compile for it to load the first time so make sure you don’t have compiler errors when you try to import it.
  • Limitations you will need to use MD or VS to do:
    • No debugger
    • No refactor.
    • No folder search, it has search all open tabs or whole project.

XML comments

You should use XML comments to take full advantage of Intellisense in your own code.

Resharper

When you first install Resharper, it needs configuring.

Variable Naming

The first thing you’ll notice is that after installing Resharper it underlines lots of variable names with wavy green lines saying that you should name them differently.

  1. Look at the naming conventions it recommends in the Resharper menu / Options.

The standard naming conventions used in C# Unity source code are based on Microsoft’s C# naming conventions.

You can add some common style rules if your team requires them, such as m_ before private member instance variables such as those used in backing fields for properties and sometimes s_ before private statics.

Fonts & Colors

Resharper adds lots of new colors under Visual Studios Options menu / Fonts & Colors.

The most useful for C# are different colors for members vs statics.

Indenting tabs or spaces

Resharper defaults to spaces (which is definitely inferior to tabs).

  1. Click Visual Studio menubar / Resharper / Options / Code Editing / General Formatter Style.
  2. Click Only use tabs.

resharper_pushes_spaces_over_tabs

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s