I need to check if the project is running in editor mode or standalone. Is this possible?
Thanks
I need to check if the project is running in editor mode or standalone. Is this possible?
Thanks
I guess you could just check the Application.dataPath variable.
You can simply do it through Application.platform
Or even more simpler
if( Application.IsEditor() )
{
...
}
Perfect. Thanks guys!
that one though is to check if you are really running in editor after you made a class ExecuteInEditMode isn’t it? (where the platform wouldn’t do any good)
Don’t think so, used it several times already and sucessfully - at least as far i remember…
Docs says nothing about the ExecuteInEditMode exclusivity too…
Ah sorry didn’t want to imply it was exclusive. But it seems to be primary targeted at that usage as the game mode is covered by Application.platform
I guess it just works in game mode too because its still within the editor
using Unity 4.6.5, the actual method call is
if (Application.isEditor) {…

Or even better
#if UNITY_EDITOR
...
#endif
Application.isEditor should do the job
Or even better
#if UNITY_EDITOR ... #endif
I’d say this is not better, as it uses preprocessor directive, and they can often hide errors that the compiler ignores. Then you might encounter such errors when attempting to build, etc.
Application.isEditor is the better solution.