平台定义

UNITY_EDITOR 编辑器调用。

UNITY_STANDALONE_OSX 专门为Mac OS(包括Universal,PPC和Intelarchitectures)平台的定义。

UNITY_DASHBOARD_WIDGET Mac OS Dashboard widget (Mac OS仪表板小部件)。

UNITY_STANDALONE_WIN Windows 操作系统。

UNITY_STANDALONE_LINUX Linux的独立的应用程序。

UNITY_STANDALONE 独立的平台(Mac,Windows或Linux)。

UNITY_WEBPLAYER 网页播放器(包括Windows和Mac Web播放器可执行文件)。

UNITY_WII Wii游戏机平台。

UNITY_IPHONE iPhone平台。

UNITY_ANDROID Android平台。

UNITY_PS3 PlayStation 3。

UNITY_XBOX360 Xbox 360。

UNITY_NACL 谷歌原生客户端(使用这个必须另外使用UNITY_WEBPLAYER)。

UNITY_FLASH Adobe Flash。

判断Unity版本

也可以判断Unity版本,目前支持的版本

UNITY_2_6 平台定义为主要版本的Unity 2.6。

UNITY_2_6_1 平台定义的特定版本1的主要版本2.6。

UNITY_3_0 平台定义为主要版本的Unity 3.0。

UNITY_3_0_0 平台定义的特定版本的Unity 3.0 0。

UNITY_3_1 平台定义为主要版本的Unity 3.1。

UNITY_3_2 平台定义为主要版本的Unity 3.2。

UNITY_3_3 平台定义为主要版本的Unity 3.3。

UNITY_3_4 平台定义为主要版本的Unity 3.4。

UNITY_3_5 平台定义为主要版本的Unity 3.5。

UNITY_4_0 平台定义为主要版本的Unity 4.0。

UNITY_4_0_1 主要版本4.0.1统一的平台定义。

UNITY_4_1 平台定义为主要版本的Unity 4.1。

UNITY_4_2 平台定义为主要版本的Unity 4.2。

运行平台

//获得当前运行平台
Debug.Log("plat = " + Application.platform);


 
//可以获取到的平台类型
public enum RuntimePlatform
{
OSXEditor = 0,
OSXPlayer = 1,
WindowsPlayer = 2,
OSXWebPlayer = 3,
OSXDashboardPlayer = 4,
WindowsWebPlayer = 5,
WiiPlayer = 6,
WindowsEditor = 7,
IPhonePlayer = 8,
PS3 = 9,
XBOX360 = 10,
Android = 11,
NaCl = 12,
LinuxPlayer = 13,
FlashPlayer = 15,
}
 

示例

// JS
function Awake() {
#if UNITY_EDITOR
Debug.Log("Unity Editor");
#endif #if UNITY_IPHONE
Debug.Log("Iphone");
#endif #if UNITY_STANDALONE_OSX
Debug.Log("Stand Alone OSX");
#endif #if UNITY_STANDALONE_WIN
Debug.Log("Stand Alone Windows");
#endif
} // C#
using UnityEngine;
using System.Collections; public class PlatformDefines : MonoBehaviour {
void Start () { #if UNITY_EDITOR
Debug.Log("Unity Editor");
#endif #if UNITY_IPHONE
Debug.Log("Iphone");
#endif #if UNITY_STANDALONE_OSX
Debug.Log("Stand Alone OSX");
#endif #if UNITY_STANDALONE_WIN
Debug.Log("Stand Alone Windows");
#endif }
} // Boo
import UnityEngine class PlatformDefines (MonoBehaviour): def Start ():
ifdef UNITY_EDITOR:
Debug.Log("Unity Editor") ifdef UNITY_IPHONE:
Debug.Log("IPhone") ifdef UNITY_STANDALONE_OSX:
Debug.Log("Stand Alone OSX") ifdef not UNITY_IPHONE:
Debug.Log("not an iPhone")

 

文献资料

API地址:http://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html

Unity3D 多平台 预编译 宏定义的更多相关文章

  1. C中的预编译宏定义

     可以用宏判断是否为ARC环境 #if _has_feature(objc_arc) #else //MRC #endif C中的预编译宏定义 -- 作者: infobillows 来源:网络 在将一 ...

  2. linux, windows, mac, ios等平台GCC预编译宏判断

    写跨平台c/c++程序的时候,需要搞清各平台下面的预编译宏,区分各平台代码.而跨平台c/c++编程,GCC基本在各平台都可以使用.整理了一份各平台预编译宏的判断示例. 需要注意几点: * window ...

  3. C++头文件中预编译宏的目的

    C++头文件中预编译宏的目的 eg: #ifndef _FACTORY_H_#define _FACTORY_H_......#endif //~_FACTORY_H_ 防止头文件被重复包含,导致变量 ...

  4. GCC预编译宏查看

    编译调试代码时,总是遇到要使用编译器预编译宏进行跨平台编译. gcc -E -dM -</dev/null 编译器版本 Thread model: posix gcc version 5.4.0 ...

  5. CL.exe的 /D 选项, Preprocessor Macro预处理器宏定义

    在看"Inside COM"第10章的代码. MAKEFILE里面有几个标记我没看懂. 去网上搜也搜不到. /D_OUTPROC_SERVER_ /DWIN32 /DREGISTE ...

  6. Unity各平台内置宏定义

    属性 方法 UNITY_EDITOR #define directive for calling Unity Editor scripts from your game code. UNITY_EDI ...

  7. C/C++跨平台的的预编译宏

    我们在编译一些跨平台的程序的时候难免会遇到_WIN32  __linux__什么之类的SDK或者编译器环境预定义的宏.有很多,之前还分不清_WIN32 和WIN32的区别.不过这里还好有个列表,做个备 ...

  8. xcode 配置系统环境变量 Preporocessing 预编译宏的另一种写法, 系统的DEBUG 由来

    在某些项目中看到一些环境变量类似宏的东西 比如叫ENVIRONMENT, 但发现还找不到具体这个宏是什么值, 那是因为他实在Preprocessing里配置了这个宏的值, 他能配置debug/rele ...

  9. C预编译宏

    /* ============================================================================ Name : c_test001.c A ...

随机推荐

  1. javascript的封装实例

    StringBuffer方法的js自定义封装: <!doctype html><html lang="en"> <head> <meta ...

  2. C# DevExpress 的gridControl或gridView数据导出失败解决方法

    来自:http://blog.csdn.net/lybwwp/article/details/8049464 谢谢 在使用DevExpress 的GridPanel控件的时候出现了一个莫名其妙的现象, ...

  3. 关于SharePoint 的Client object model该何时load和execut query的一点自己的看法

    很多人在用client object model的时候,不知道何时或者该不该load,今天看到一个观点描述这个问题,觉得很有道理,和大家分享.那就是写client object model就像写sql ...

  4. Android 正则表达式

    1.相关知识链接 正则表达式语法   https://msdn.microsoft.com/zh-cn/library/ae5bf541(v=vs.80).aspx 正则表达式入门教程   http: ...

  5. 【读书笔记】iOS-GCD-使用方法

    代码: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { dispatch_async(dispatch_get_gl ...

  6. NSFileManager文件操作的十个小功能

    NSFileManager文件操作的十个小功能 NSFileManager是一个单列类,也是一个文件管理器.可以通过NSFileManager创建文件夹.创建文件.写文件.读文件内容等等基本功能. 下 ...

  7. python arguments *args and **args ** is for dictionaries, * is for lists or tuples.

    below is a good answer for this question , so I copy on here for some people need it By the way, the ...

  8. Windows Server 2012之搭建域控制器DC

    安装域控制器,域(Domain) 1,本地管理员权限 2,设置静态IP 地址 3,至少有一个NTFS分区 4,操作系统版本(web版除外)   设置静态IP地址    dcpromo.exe命令不生效 ...

  9. C++基础——子类转父类转子类 (派生类转基类转派生类)

    ==================================声明================================== 本文原创,转载在正文中显要的注明作者和出处,并保证文章的完 ...

  10. 华硕飞行堡垒zx50安装Ubunutu折腾记

    今年8月入手了华硕zx50,配置不错,作为一个合格的Linux爱好者,没买来一台电脑肯定得装上Linux编个程序什么的吧,,可恶的是,笔记本安装Linux系统往往比较麻烦,必须折腾很久才安装上,我手上 ...