Unity平台判断

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_EDITORScripting symbol to call Unity Editor scripts from your game code.
UNITY_EDITOR_WINScripting symbol for Editor code on Windows.
UNITY_EDITOR_OSXScripting symbol for Editor code on Mac OS X.
UNITY_EDITOR_LINUXScripting symbol for Editor code on Linux.
UNITY_STANDALONE_OSXScripting symbol to compile or execute code specifically for Mac OS X (including Universal, PPC and Intel architectures).
UNITY_STANDALONE_WINScripting symbol for compiling/executing code specifically for Windows standalone applications.
UNITY_STANDALONE_LINUXScripting symbol for compiling/executing code specifically for Linux standalone applications.
UNITY_STANDALONEScripting symbol for compiling/executing code for any standalone platform (Mac OS X, Windows or Linux).
UNITY_WIIScripting symbol for compiling/executing code for the Wii console.
UNITY_IOSScripting symbol for compiling/executing code for the iOS platform.
UNITY_IPHONEDeprecated. Use UNITY_IOS instead.
UNITY_ANDROIDScripting symbol for the Android platform.
UNITY_LUMINScripting symbol for the Magic Leap OS platform. You can also use PLATFORM_LUMIN.
UNITY_TIZENScripting symbol for the Tizen platform.
UNITY_TVOSScripting symbol for the Apple TV platform.
UNITY_WSAScripting 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_0Scripting symbol for Universal Windows Platform. Additionally WINDOWS_UWP is defined when compiling C# files against .NET Core.
UNITY_WEBGLScripting symbol for WebGL
.
UNITY_FACEBOOKScripting symbol for the Facebook platform (WebGL or Windows standalone).
UNITY_ANALYTICSScripting symbol for calling Unity Analytics
 methods from your game code. Version 5.2 and above.
UNITY_ASSERTIONSScripting symbol for assertions control process.
UNITY_64Scripting symbol for 64-bit platforms.

官方文档:https://docs.unity3d.com/Manual/PlatformDependentCompilation.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奇大可

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值