Game Development Reference
In-Depth Information
Preprocessor directives
When you want the code to run in a particular way on one platform and in a different way
on another, you can use the precompiler directives to tell Unity to pick one section of code
over another (when it builds the project), or to simply ignore the sections of the code. This
is also true for the editor, which Unity considers a platform, just like any other. So, we can
have the code to run and deploy in the editor, but restrict its execution when it's deployed
to another platform. You could say the special editor classes do this, but you may also
want to do this with any other code.
The preprocessor directives (or the platform defines) that Unity recognizes are listed in
the following table:
Statement
Description
UNITY_EDITOR
This code will run only in the editor, not on a platform
This code specifically targets the editor on Windows (if you have the code that runs
differently than on a Mac)
UNITY_EDITOR_WIN
This code specifically targets the editor on Mac (if you have the code that runs dif-
ferently than on a PC)
UNITY_EDITOR_OSX
This code targets the desktop platforms (Windows/Mac/Linux)
UNITY_STANDALONE
This code targets Mac OS X only (this includes Universal, PPC, and Intel architec-
tures)
UNITY_STANDALONE_OSX
UNITY_DASHBOARD_WIDGET This code targets the Mac OS X dashboard widget deployments
UNITY_STANDALONE_WIN This code targets the Windows desktop only (excluding Windows 8)
UNITY_STANDALONE_LINUX This code targets the Linux desktop clients only
UNITY_WEBPLAYER
This code targets the Web players
Search WWH ::




Custom Search