Unity實現(xiàn)蘋果手機Taptic震動
本文實例為大家分享了Unity蘋果手機Taptic震動的具體代碼,供大家參考,具體內(nèi)容如下
文件:ios震動.zip
將上方文件解壓之后將MultiHaptic.mm的文件放到Assets/Plugins/iOS目錄下,MultiHaptic.cs文件不用掛載到游戲物體上,在需要的時候調(diào)用里面的三個靜態(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(); } } }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
C#聯(lián)合VisionPro實現(xiàn)TCP/IP通信詳解
TCP/IP(傳輸控制協(xié)議/互聯(lián)網(wǎng)協(xié)議)是一組用于在網(wǎng)絡(luò)上進行通信的通信協(xié)議,本文主要為大家詳細介紹了C#如何聯(lián)合VisionPro實現(xiàn)TCP/IP通信,希望對大家有所幫助2024-02-02C#實現(xiàn)通過winmm.dll控制聲音播放的方法
這篇文章主要介紹了C#實現(xiàn)通過winmm.dll控制聲音播放的方法,很實用的功能,需要的朋友可以參考下2014-08-08C#過濾DataTable中空數(shù)據(jù)和重復(fù)數(shù)據(jù)的示例代碼
這篇文章主要給大家介紹了關(guān)于C#過濾DataTable中空數(shù)據(jù)和重復(fù)數(shù)據(jù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01