• Unity3D 多平台_预编译相关宏定义


    http://www.cnblogs.com/zhaoqingqing/p/3510332.html

    API地址:http://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html

    平台定义

    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。

    也可以判断Unity版本,目前支持的版本

    UNITY_2_6 平台定义为主要版本的Unity 2.6。

    UNITY_2_6_1 平台定义的特定版本1的主要版本2.6。

    UNITY_3_0 平台定义为主要版本的Unity 3.0。

    UNITY_3_0_0 平台定义的特定版本的Unity 3.0 0。

    UNITY_3_1 平台定义为主要版本的Unity 3.1。

    UNITY_3_2 平台定义为主要版本的Unity 3.2。

    UNITY_3_3 平台定义为主要版本的Unity 3.3。

    UNITY_3_4 平台定义为主要版本的Unity 3.4。

    UNITY_3_5 平台定义为主要版本的Unity 3.5。

    UNITY_4_0 平台定义为主要版本的Unity 4.0。

    UNITY_4_0_1 主要版本4.0.1统一的平台定义。

    UNITY_4_1 平台定义为主要版本的Unity 4.1。

    UNITY_4_2 平台定义为主要版本的Unity 4.2。

    运行平台

    //获得当前运行平台
       Debug.Log("plat = " + Application.platform);
     
    //可以获取到的平台类型  
       public enum RuntimePlatform  
        {  
            OSXEditor = 0,  
            OSXPlayer = 1,  
            WindowsPlayer = 2,  
            OSXWebPlayer = 3,  
            OSXDashboardPlayer = 4,  
            WindowsWebPlayer = 5,  
            WiiPlayer = 6,  
            WindowsEditor = 7,  
            IPhonePlayer = 8,  
            PS3 = 9,  
            XBOX360 = 10,  
            Android = 11,  
            NaCl = 12,  
            LinuxPlayer = 13,  
            FlashPlayer = 15,  
        }
     
    Example
    // 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    
    }
    
    
    // C#
    using UnityEngine;
    using System.Collections;
    
    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
    
      }               
    }
    
    
    // Boo
    import UnityEngine
    
    class PlatformDefines (MonoBehaviour): 
    
        def Start ():
            ifdef UNITY_EDITOR:
                Debug.Log("Unity Editor")
    
            ifdef UNITY_IPHONE:
                Debug.Log("IPhone")
    
            ifdef UNITY_STANDALONE_OSX:
                Debug.Log("Stand Alone OSX")
    
            ifdef not UNITY_IPHONE:
                Debug.Log("not an iPhone")
  • 相关阅读:
    BZOJ3847 : ZCC loves march
    BZOJ3828 : [Poi2014]Criminals
    BZOJ3834 : [Poi2014]Solar Panels
    BZOJ3831 : [Poi2014]Little Bird
    BZOJ3829 : [Poi2014]FarmCraft
    BZOJ2757 : [SCOI2012]Blinker的仰慕者
    BZOJ2707 : [SDOI2012]走迷宫
    给iOS工程增加Daily Build
    给NSString增加Java风格的方法
    象写程序一样写博客:搭建基于github的博客
  • 原文地址:https://www.cnblogs.com/123ing/p/4037251.html
Copyright © 2020-2023  润新知