Unity中各个平台的预编译的运用方式

时间:2023-03-08 19:52:06

1,unity中官方文档的一个操纵关键词  

Platform Dependent Compilation

2,常用的预编译关键词
    
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。

3,具体的运用

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 }
}