找回密码
 立即注册
查看: 395|回复: 0

Unity运行平台判断

[复制链接]
发表于 2022-4-9 21:23 | 显示全部楼层 |阅读模式
对照表如下:


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_IPHONE           Deprecated. Use UNITY_IOS instead.

UNITY_ANDROID          Scripting symbol for the Android platform.

UNITY_PS4               Scripting symbol for running PlayStation 4 code.

UNITY_XBOXONE          Scripting symbol for executing Xbox One code.

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_WINRT            Same as UNITY_WSA. UNITY_WINRT_10_0 Equivalent to UNITY_WSA_10_0 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.
实战:

#ifUNITY_EDITOR

platform="hi,大家好,我是在unity编辑模式下";

#elifUNITY_XBOXONE

platform="hi,大家好,我在UNITY_XBOXONE平台";

#elifUNITY_IOS

platform="hi,大家好,我是IOS平台";

#elifUNITY_ANDROID

platform="hi,大家好,我是ANDROID平台";

#elifUNITY_STANDALONE_OSX

platform="hi,大家好,我是OSX平台";

#elifUNITY_STANDALONE_WIN

platform="hi,大家好,我是Windows平台";

#endif

Debug.Log("CurrentPlatform:"+platform);
参考官方文档:http://docs.unity3d.com/Manual/PlatformDependentCompilation.html
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-9-22 15:43 , Processed in 0.089962 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表