The C# project uses Rider to set up the so-called "macro compilation" (compilation switch)

First of all, let me declare that C# does not have macro definitions , only compilation switches.

  • Codes such as #if UNITY_ANDROID in Unity are compilation switches, indicating that they will only be compiled in this case.
  • In Unity, you can set macro-defined variables directly in ProjectSettings.
  • If you want to set the compilation switch for a c# project, you essentially need to modify the .csproj file of the project (different editors may have different operations, but the essence is to modify this file). The specific modification locations are as follows.

Insert image description here

  • To modify in Rider, you can directly right-click the outermost project icon on the left, select properties
    Insert image description here
    , select configurations, select a running environment (such as the Debug environment I selected here), and add variables.
    Insert image description here

Guess you like

Origin blog.csdn.net/qq_37421018/article/details/108348789