Unity相关的平台相关的条件开关

来源:互联网 发布:codelens数据不可用 编辑:程序博客网 时间:2024/05/08 03:39

Platform Dependent Compilation

Platform Defines

The platform defines that Unity supports for your scripts are:

Property:Function:UNITY_EDITORDefine for calling Unity Editor scripts from your game code.UNITY_EDITOR_WINPlatform define for editor code on Windows.UNITY_EDITOR_OSXPlatform define for editor code on Mac OSX.UNITY_STANDALONE_OSXPlatform define for compiling/executing code specifically for Mac OS (This includes Universal, PPC and Intel architectures).UNITY_DASHBOARD_WIDGETPlatform define when creating code for Mac OS dashboard widgets.UNITY_STANDALONE_WINUse this when you want to compile/execute code for Windows stand alone applications.UNITY_STANDALONE_LINUXUse this when you want to compile/execute code for Linux stand alone applications.UNITY_STANDALONEUse this to compile/execute code for any standalone platform (Mac, Windows or Linux).UNITY_WEBPLAYERPlatform define for web player content (this includes Windows and Mac Web player executables).UNITY_WIIPlatform define for compiling/executing code for the Wii console.UNITY_IPHONEPlatform define for compiling/executing code for the iPhone platform.UNITY_ANDROIDPlatform define for the Android platform.UNITY_PS3Platform define for running PlayStation 3 code.UNITY_XBOX360Platform define for executing Xbox 360 code.UNITY_FLASHPlatform define when compiling code for Adobe Flash.UNITY_BLACKBERRYPlatform define for a Blackberry10 device.UNITY_WP8Platform define for Windows Phone 8.UNITY_METROPlatform define for Windows Store Apps (additionallyNETFX_CORE is defined when compiling C# files against .NET Core).UNITY_WINRTEquivalent to UNITY_WP8 |UNITY_METRO

Also you can compile code selectively depending on the version of the engine you are working on. Currently the supported ones are:

 UNITY_2_6Platform define for the major version of Unity 2.6.UNITY_2_6_1Platform define for specific version 2.6.1.UNITY_3_0Platform define for the major version of Unity 3.0.UNITY_3_0_0Platform define for specific version 3.0.0.UNITY_3_1Platform define for major version of Unity 3.1.UNITY_3_2Platform define for major version of Unity 3.2.UNITY_3_3Platform define for major version of Unity 3.3.UNITY_3_4Platform define for major version of Unity 3.4.UNITY_3_5Platform define for major version of Unity 3.5.UNITY_4_0Platform define for major version of Unity 4.0.UNITY_4_0_1Platform define for specific version 4.0.1.UNITY_4_1Platform define for major version of Unity 4.1.UNITY_4_2Platform define for major version of Unity 4.2.UNITY_4_3Platform define for major version of Unity 4.3.UNITY_4_5Platform define for major version of Unity 4.5.

Note: For versions before 2.6.0 there are no platform defines as this feature was first introduced in that version.

Platform Custom Defines

It is also possible to add to the built-in selection of defines by supplying your own. In the Other Settingspanel of the Player Settings, you will see the Scripting Define Symbols textbox.



Global Custom Defines

You can define your own preprocessor directives to control which code gets included when compiling. To do this you must add a text file with the extra directives to the “Assets/” folder. The name of the file depends on the language you are using, and the extension is .rsp:

 C#<Project Path>/Assets/smcs.rspC# - Editor Scripts<Project Path>/Assets/gmcs.rspUnityScript<Project Path>/Assets/us.rspBoo<Project Path>/Assets/boo.rsp

0 0
原创粉丝点击