Environment variable in Unity to differ between development and production

Viewed 1810

Is there a way to differ in code between development and production environment in Unity?

Currently, I would love to use it so I can change testMode variable for Ads implementation.

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

For example, this works.

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

1 Answers

Use #if DEVELOPMENT_BUILD.

From 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.

E.g.,

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

Related