Skip to content

Instantly share code, notes, and snippets.

@rlabrecque
Created August 28, 2014 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rlabrecque/047d0a0337ea8e93912d to your computer and use it in GitHub Desktop.
Save rlabrecque/047d0a0337ea8e93912d to your computer and use it in GitHub Desktop.
UNITY preprocessor define
It's just a simple preprocessor define for Unity itself.
Use case: If I'm building the same piece of code both in Unity and in XNA/Monogame/regular C# sometimes I want to do something different on each 'platform'.
A mediocre but to the point use case:
void f() {
#if UNITY
UnityEngine.Debug.Log("f");
#else
Console.WriteLine("f");
#endif
}
The whole reason for wanting it in 4.6.x is eventually we will be supporting the last release of Unity 4, and all releases of Unity 5. (Much like we supported Unity 3.5.7 and Unity 4 up until earlier this year.)
If it doesn't land in 4.x then the timeline for us being able to actually make use of it results in the 'feature' being worth quite a bit less.
Right now we do use the gmcs.rsp / smcs.rsp files for internal stuff but that is hard to ship to partners.
So we end up with:
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0
#define UNITY_BUILD
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment