Unity 平台区分

来源:互联网 发布:广告宣传软件 编辑:程序博客网 时间:2024/06/06 01:25

1.宏区分

(测试显示这种区分是根据你选择的平台进行区分,比如你在电脑上运行 选择的是安卓平台  则区分的是安卓平台)

示例代码:

function Awake() {    #if UNITY_ANDROID        Debug.Log("这里是安卓设备^_^");    #endif     #if UNITY_IPHONE        Debug.Log("这里是苹果设备>_<");    #endif     #if UNITY_STANDALONE_WIN        Debug.Log("我是从Windows的电脑上运行的T_T");    #endif        }


2.代码区分

示例代码:

if(Application.platform == RuntimePlatform.Android ){else if((Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)){}




0 0
原创粉丝点击