Unity 中的环境变量以区分开发和生产

Environment variable in Unity to differ between development and production

有没有办法在 Unity 中区分开发环境和生产环境的代码?

目前,我很想使用它,这样我就可以为广告实施更改 testMode 变量。

// I would love to have something like this:
# if DEVELOPMENT
    bool testMode = true;
# elif PRODUCTION
    bool testMode = false;
#endif

例如,这行得通。

#if UNITY_IOS
    private string gameId = "1111111";
#elif UNITY_ANDROID
    private string gameId = "2222222";
#endif

使用#if DEVELOPMENT_BUILD.

来自the documentation

You use the DEVELOPMENT_BUILD #define to identify whether your script is running in a player which was built with the “Development Build ” option enabled.

例如,

// I would love to have something like this:
#if DEVELOPMENT_BUILD
    bool testMode = true;
#else
    bool testMode = false;
#endif