您好,登錄后才能下訂單哦!
小編給大家分享一下Unity如何實(shí)現(xiàn)蘋(píng)果手機(jī)Taptic震動(dòng),希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
具體內(nèi)容如下
將上方文件解壓之后將MultiHaptic.mm的文件放到Assets/Plugins/iOS目錄下,MultiHaptic.cs文件不用掛載到游戲物體上,在需要的時(shí)候調(diào)用里面的三個(gè)靜態(tài)方法即可
附上MultiHaptic.cs的代碼:
using UnityEngine; using System.Runtime.InteropServices; public class MultiHaptic { [DllImport("__Internal")] static extern void _hapticMedium(); [DllImport("__Internal")] static extern void _hapticLight(); [DllImport("__Internal")] static extern void _hapticHeavy(); public static void HapticLight() { if (Application.platform == RuntimePlatform.IPhonePlayer) if (PlayerPrefs.GetInt("Taptic", 1) == 1) { _hapticLight(); } } public static void HapticMedium() { if (Application.platform == RuntimePlatform.IPhonePlayer) if (PlayerPrefs.GetInt("Taptic", 1) == 1) { _hapticMedium(); } } public static void HapticHeavy() { if (Application.platform == RuntimePlatform.IPhonePlayer) if (PlayerPrefs.GetInt("Taptic", 1) == 1) { _hapticHeavy(); } } }
看完了這篇文章,相信你對(duì)“Unity如何實(shí)現(xiàn)蘋(píng)果手機(jī)Taptic震動(dòng)”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。