Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off Visual Studio 2013 PreProcessor Graying Out C#?

When I put code inside an #if STATEMENT block in C#, Visual Studio grays out the entire block, ruining syntax highlighting, Find All References... and all those great Visual Studio features.

Is there a way I can disable this graying out of code or are pre-processor statements to confusing for Visual Studio?

I looked at some other posts: How to get Visual Studio 2012 to grey out ifdef instead of dimming it Disable or fix #ifdef-sensitive colouring and intellisense in Visual Studio

But these are for older versions of Visual Studio and C++ rather than C# and I couldn't find a similar setting in my Text Editor Options.

enter image description here

like image 784
hubatish Avatar asked Oct 30 '25 13:10

hubatish


1 Answers

You can define the UNITY_ANDROID symbol (or UNITY_EDITOR, ecc..) following these steps (for Visual Studio 2015, but I think it is pretty similar to 2013):

  • Open Solution Explorer (from Window menu or Ctrl+Alt+L)
  • Right click on your project (should by csharp or csharp.editor if you are using Unity) and click Properties from the context menu (or Alt+Enter)
  • Select the Build tab
  • Write UNITY_ANDROID (or whatever) in Conditional compilation symbols field
  • Save project or solution

Now your code inside #if UNITY_ANDROID ... #endif shouldn't be grayed out anymore (and you should be able to use IntelliSense and all the other stuff).