Question by
William_Goodspeed · Apr 04, 2016 at 11:18 AM ·
buildruntimeplayplaymode
How to flag Unity playmode vs Build playmode
Hey folks,
So for complicated reasons I have a need to change some method calls in code dependant on whether a developer is looking at the game in Unitys playmode or if the game is actually compliled, built and playing.
I essentially want something akin to this:
if (Unity.Playmode){
DoThis();
}
if (Build.Playmode){
DoSomethingElse();
}
I'm not clear on whether something like Application.isPlaying would be called both in playmode and once the game is built, if so it would be unsuitable. Any advice would be greatly appreciated :).
Comment
Best Answer
Answer by William_Goodspeed · Mar 11, 2017 at 11:21 AM
Coming back to this rather silly question of mine from some time ago to provide an answer for anyone looking for it.
if(Application.isPlaying && !Application.isEditor)
{
// Will get called only outside of the editor in the final game build
}
if(Application.isPlaying && Applicaiton.isEditor)
{
// Will get called only when playing in Editor mode
}