Unity 平台编译预定义

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录

  • 前言
  • 一、Platform scripting symbols
  • 二、测试
  • 总结


前言

提示:这里可以添加本文要记录的大概内容:
链接: 官方文档

一、Platform scripting symbols

Unity automatically defines certain scripting symbols based on the authoring and build target platform. These are as follows:

Define功能
UNITY_EDITORUnity编辑器
UNITY_EDITOR_WIN在Windows上用于编辑器代码的脚本符号
UNITY_EDITOR_OSX用于Mac oS X上编辑器代码的脚本符号
UNITY_EDITOR_LINUXLinux上编辑器代码的脚本符号
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_STANDALONE
UNITY_WII
UNITY_IOS
UNITY_ANDROID
UNITY_LUMIN
UNITY_TIZEN
UNITY_TVOS
UNITY_WSA
UNITY_WSA_10_0
UNITY_WEBGL

二、测试

using UnityEngine;
using System.Collections;public class PlatformDefines : MonoBehaviour {void Start () {#if UNITY_EDITORDebug.Log("Unity Editor");#endif#if UNITY_IOSDebug.Log("iOS");#endif#if UNITY_STANDALONE_OSXDebug.Log("Standalone OSX");#endif#if UNITY_STANDALONE_WINDebug.Log("Standalone Windows");#endif}          
}

总结

提示:这里对文章进行总结:
本文仅仅简单介绍了平台编译预定义的使用,而平台编译预定义提供了大量能使我们快速便捷地处理方法。