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_EDITOR Unity编辑器
UNITY_EDITOR_WIN 在Windows上用于编辑器代码的脚本符号
UNITY_EDITOR_OSX 用于Mac oS X上编辑器代码的脚本符号
UNITY_EDITOR_LINUX 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
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_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

  }          
}

总结

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

你可能感兴趣的:(#,unity之日常开发,unity,游戏引擎)