- Home /
Any pragma to tell if Unity is in release mode?
I have some assets which are not within the Resources directory, as I don't want the files to get bundled up in in the generated resource output.
Anyway due to this I have a line in a configuration file which reads like:
private static readonly string DataDirectory = "Assets/Data";
However this only works within the Unity Editor, when the build is done the data is not copied automatically so its a manual step and it ends up just being located at:
private static readonly string DataDirectory = "Data";
So is there any pragma directive available to work out if it is running as a release or not?
Comment
Best Answer
Answer by Bunny83 · Aug 18, 2012 at 01:33 PM
You can use preprocessor tags like this:
#if UNITY_EDITOR
private static readonly string DataDirectory = "Assets/Data";
#else
private static readonly string DataDirectory = "Data";
#endif
See the Platform Dependent Compilation page in the manual
But like JD said, Application.dataPath is the easiest way.