Unity运行平台判断

作者: 半夏半暖半倾城灬 | 来源:发表于2022-04-08 10:42 被阅读0次

    对照表如下:

    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.

    实战:

    #if UNITY_EDITOR  

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

    #elif UNITY_XBOXONE  

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

    #elif UNITY_IOS  

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

    #elif UNITY_ANDROID  

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

    #elif UNITY_STANDALONE_OSX  

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

    #elif UNITY_STANDALONE_WIN  

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

    #endif  

        Debug.Log("Current Platform:" + platform);  

    参考官方文档:http://docs.unity3d.com/Manual/PlatformDependentCompilation.html

    相关文章

      网友评论

        本文标题:Unity运行平台判断

        本文链接:https://www.haomeiwen.com/subject/ptxysrtx.html