using UnityEngine;
using System.Collections;
public class PlatformDefines : MonoBehaviour {
void Start () {
#if UNITY_EDITOR
Debug.Log("Unity Editor");
#endif
#if UNITY_IOS
Debug.Log("iOS");
#endif
#if UNITY_STANDALONE_OSX
Debug.Log("Standalone OSX");
#endif
#if UNITY_STANDALONE_WIN
Debug.Log("Standalone Windows");
#endif
}
}
#if UNITY_EDITOR
Debug.Log("Unity Editor");
#elif UNITY_IOS
Debug.Log("Unity iOS");
#else
Debug.Log("Any other platform");
#endif
UNITY_EDITOR | Scripting symbol to call Unity Editor scripts from your game code. |
UNITY_EDITOR_WIN | Scripting symbol for Editor code on Windows. |
UNITY_EDITOR_OSX | Scripting symbol for Editor code on Mac OS X. |
UNITY_EDITOR_LINUX | Scripting symbol for Editor code on Linux. |
UNITY_STANDALONE_OSX | Scripting symbol to compile or execute code specifically for Mac OS X (including Universal, PPC and Intel architectures). |
UNITY_STANDALONE_WIN | Scripting symbol for compiling/executing code specifically for Windows standalone applications. |
UNITY_STANDALONE_LINUX | Scripting symbol for compiling/executing code specifically for Linux standalone applications. |
UNITY_STANDALONE | Scripting symbol for compiling/executing code for any standalone platform (Mac OS X, Windows or Linux). |
UNITY_WII | Scripting symbol for compiling/executing code for the Wii console. |
UNITY_IOS | Scripting symbol for compiling/executing code for the iOS platform. |
UNITY_IPHONE | Deprecated. Use UNITY_IOS instead. |
UNITY_ANDROID | Scripting symbol for the Android platform. |
UNITY_LUMIN | Scripting symbol for the Magic Leap OS platform. You can also use PLATFORM_LUMIN. |
UNITY_TIZEN | Scripting symbol for the Tizen platform. |
UNITY_TVOS | Scripting symbol for the Apple TV platform. |
UNITY_WSA | Scripting symbol for Universal Windows Platform . Additionally, NETFX_CORE is defined when compiling C# files against .NET Core and using .NET scripting backend . |
UNITY_WSA_10_0 | Scripting symbol for Universal Windows Platform. Additionally WINDOWS_UWP is defined when compiling C# files against .NET Core. |
UNITY_WEBGL | Scripting symbol for WebGL . |
UNITY_FACEBOOK | Scripting symbol for the Facebook platform (WebGL or Windows standalone). |
UNITY_ANALYTICS | Scripting symbol for calling Unity Analytics methods from your game code. Version 5.2 and above. |
UNITY_ASSERTIONS | Scripting symbol for assertions control process. |
UNITY_64 | Scripting symbol for 64-bit platforms. |
官方文档:https://docs.unity3d.com/Manual/PlatformDependentCompilation.html