Is there any way to detect if this is a development build from script?

In most of my projects, it would be extremely useful to be able to enable/disable/destroy certain objects based on whether the application is built as a development build or not. Specifically, I’m looking for a way to branch in script based on this state.

Obviously there is something internal tracking this somewhere since Unity adds a display tag if you build that way, but I haven’t been able to find any way to access this yet. Anyone have any ideas?

And just found it

Description

In the Build Settings
dialog there is a check box called
“Development Build”.

If it is checked isDebugBuild will be
true. In the editor isDebugBuild
always returns true.

Late to the party but for googlers: There is also

#if DEVELOPMENT_BUILD

#endif

More detail here:

Working with Unity for at least 10 years I really recommend using:

The ‘obvious’ approach is not reliable and does not always return the right value:

Just my two cents on this matter.

Actually the purpose of the development build is to test your application like a released-one but with debugging option activated. Willing to have different scripts based on the fact that it is or not a development build makes no sense.

How will you test your real build if it is different from the development build?

Anyway Unity does not provide such option. But you can define a COMPILATION CONSTANT (#define) and use #ifdef in your script. When you build the release, just remove the #define.