属性 方法
UNITY_EDITOR #define directive for calling Unity Editor scripts from your game code.
UNITY_EDITOR_WIN #define directive for Editor code on Windows.
UNITY_EDITOR_OSX #define directive for Editor code on Mac OS X.
UNITY_STANDALONE #define directive for compiling/executing code for any standalone platform (Mac OS X, Windows or Linux).
UNITY_STANDALONE_WIN #define directive for compiling/executing code specifically for Windows standalone applications.
UNITY_STANDALONE_OSX #define directive for compiling/executing code specifically for Mac OS X (including Universal, PPC and Intel architectures).
UNITY_STANDALONE_LINUX #define directive for compiling/executing code specifically for Linux standalone applications.
UNITY_ANDROID #define directive for the Android platform.
UNITY_IOS #define directive for compiling/executing code for the iOS platform.
UNITY_IPHONE Deprecated. Use UNITY_IOS instead.
UNITY_WEBGL #define directive for WebGL.
UNITY_WP_8_1 #define directive for Windows Phone 8.1.
UNITY_PS4 #define directive for running PlayStation 4 code.
UNITY_XBOXONE #define directive for executing Xbox One code.
UNITY_WII #define directive for compiling/executing code for the Wii console.
UNITY_SAMSUNGTV #define directive for executing Samsung TV code.

样例:

// C#
using UnityEngine;
using System.Collections; public class PlatformDefines : MonoBehaviour { void Start () {
#if UNITY_EDITOR
Debug.Log("Unity Editor");
#elif UNITY_IOS
Debug.Log("Unity iPhone");
#else
Debug.Log("Any other platform");
#endif
} }
// 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
}

Unity宏定义官方文档

Unity各平台内置宏定义的更多相关文章

  1. 获取gcc和clang的内置宏定义

    下面是对Gcc的内置宏定义的解释: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html https://github.co ...

  2. C++ 内置宏定义 与 预编译指令

    内置宏和预编译指令, 在代码调试.单元测试.跨平台代码中经常会用到.这里记录一下. 1. 内置宏 (文件名,当前行号,当前日期,当前时间,当前执行方法名) __FILE____LINE____DATE ...

  3. 查看GCC的内置宏定义

    开发过程中我们常常需要使用宏定义.. 为了尽可能多的使用GCC为我们提供的特性,首先我们需要知道gcc提供了那些特性... gcc -dM -E - < /dev/null 没错,就这么一句话就 ...

  4. unity 着色器内置宏

    目标平台 Macro: Target platform: SHADER_API_D3D11 Direct3D 11 SHADER_API_GLCORE Desktop OpenGL “core” (G ...

  5. 编译器内置宏__LINE__&__FUNCTION__

    编译器内置宏: 先介绍几个编译器内置的宏定义,这些宏定义不仅可以帮助我们完成跨平台的源码编写,灵活使用也可以巧妙地帮我们输出非常有用的调试信息. ANSI C标准中有几个标准预定义宏(也是常用的): ...

  6. c语言编译器内置宏

    注:转自http://www.cnblogs.com/lixiaohui-ambition/archive/2012/08/21/2649052.html  感谢分享 前言: 我们在写程序的时候,总是 ...

  7. 一起talk C栗子吧(第一百二十四回:C语言实例--内置宏)

    各位看官们,大家好,上一回中咱们说的是显示变量和函数地址的样例,这一回咱们说的样例是:内置宏.闲话休提,言归正转.让我们一起talk C栗子吧! 看官们,我们在编译程序的时候,假设有语法错误,编译器就 ...

  8. python函数基础:调用内置函数&定义函数

    调用内置函数 有很多内置函数,在使用中需要积累.这里只举两个例子: 分别调用abs和数据类型转换,注意当入参类型错误时候会报错 ''' print('abs(-100)') abs(-100) pri ...

  9. c/c++一些常用的内置宏

    关于 本文演示环境: win10 + VS2017 Note 市面上的编译器五花八门,但是通常都支持: __DATE__,__FILE__,__LINE__ 和 __TIME__ 这个4个宏 VS20 ...

随机推荐

  1. 02.CSS选择器-->:focus

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. springmvc和spring的区别

    springmvc只是spring其中的一部分.spring 可以 支持 hibernate ,ibatis ,JMS,JDBC 支持事务管理, 注解功能,表达式语言,测试springmvc 就是一个 ...

  3. Spring Data MongoDB 环境搭建

    一.开发环境 spring版本:4.0.6.RELEASE spring-data-mongodb版本:1.4.1.RELEASE junit版本 4.11 maven版本:3.0.5 二.pom.x ...

  4. PHP匿名函数(闭包)

    匿名函数(Anonymous functions),也叫闭包函数(closures),允许 临时创建一个没有指定名称的函数.最经常用作回调函数(callback)参数的值.当然,也有其它应用的情况. ...

  5. Storm 实现滑动窗口计数和TopN排序

    计算top N words的topology, 用于比如trending topics or trending images on Twitter. 实现了滑动窗口计数和TopN排序, 比较有意思,  ...

  6. cocos2dx中node的pause函数(lua)

    time:2015/05/14 描述 lua下使用node的pause函数想暂停layer上的所有动画,结果没有效果 1. pause函数 (1)cc.Node:pause 代码: void Node ...

  7. Linux(CentOS)网卡的基本设置

    临时设置 修改IP地址: ifconfig eth0 10.60.45.205 mask 255.255.255.0 修改网关地址 route add default gw 10.60.45.1 de ...

  8. java获取中文拼音首字母

    import net.sourceforge.pinyin4j.PinyinHelper; public class PinyinHelperUtil { /** * 得到中文首字母(中国 -> ...

  9. android 智能指针的学习先看邓凡平的书扫盲 再看前面两片博客提升

    android 智能指针的学习先看邓凡平的书扫盲 再看前面两片博客提升

  10. Python 常用文件

    获取当前文件的路径: from os import path d = path.dirname(__file__) #返回当前文件所在的目录 # __file__ 为当前文件, 若果在ide中运行此行 ...