- Home /
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?
Answer by sampenguin · Apr 06, 2012 at 05:13 PM
And just found it
http://unity3d.com/support/documentation/ScriptReference/Debug-isDebugBuild.html
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.
I have to say, I am extremely frustrated with this API, since it's not even thread safe! I just need it to return a bool, and yet, I can only call it from the main thread... Boo-hoo.
Answer by zauberzaubar · Sep 09, 2020 at 10:38 AM
Late to the party but for googlers: There is also
#if DEVELOPMENT_BUILD
#endif
More detail here: https://gamedev.stackexchange.com/questions/154604/difference-between-debug-and-development-build-in-unity
Answer by Kryptos · Apr 06, 2012 at 05:00 PM
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
.
That's an assumption. While it is true when you are looking at ideal usage of the dev build feature for simply testing a deployment, it's not the purpose I'm trying to achieve all the time.
Use case: I would like to distribute a small subset standalone build to a publishing partner that does not have the Unity engine in house, let's say to test one specific feature. I would like the publisher to have certain debugging options enabled, but do not want those to be accidentally left enabled when I package a full release build later (it's a large project, multiple people involved, with lots of nooks and crannies). It would be very clean to be able to allow certain paths to be followed when its in dev build mode, without having to make actual changes in assets or scripts that could get accidentally committed.