why visual studio region block area code color become none?

With #if region, inside code area’s color become whole grey.

How to colorify again?

Very hard to see the codes.

solved.

Why this forum does not have thread delete function?

Because they’re TRYING to encourage people to be helpful.

For instance, instead of just “solved” and walking away without giving any help to anyone else coming along, you could perhaps tell us all what you did to solve it. Imagine! You could be someone else’s HERO for solving their problem!

Thats the entire point of a community forum. You understand that, right?? It’s a growing body of knowledge and we all want to contribute as much correct knowledge to it as possible.

ok,

so reason was I selected Windows platform at build setting,
but the code start with #if UNITY_SWITCH…
so it became inactive region.

After I switch platform to Switch, code region again become colorful.

2 Likes

For clarification-sake, the reason why the pre-processor regions turn gray is to indicate that a region of code will not be compiled.

Take this, for example:

public class Example {
#if UNITY_EDITOR
    void DoSomething() {
        //Doing something within the Unity editor...
    }
#else
    void DoSomething() {
        //Doing something as a standalone build...
    }
#endif
}

If you were to copy/paste this code in your project, the DoSomething() method within the #else...#endif tags will be grayed-out because it is specified to only compile when not running inside the Unity editor, and that condition is currently false, as you are viewing this script in the Unity editor.

Likewise, once you create a standalone build, the DoSomething() method within the #if UNITY_EDITOR...#else tags will not be compiled instead.