Unity调用Android原生的震动(简单)

该博客介绍了如何在Unity中使用Vibrator类调用Android系统的震动功能。内容包括Vibrator类的作用、如何设置震动模式及重复模式,并提供了打包Android工程为jar包并在Unity中调用的步骤。最后给出了简单的C#脚本示例代码。
摘要由CSDN通过智能技术生成


要在unity中调用Android系统的震动,需要一个Vibrator类 ,通过AndroidManifest.xml文件设置权限了

如下:

<uses-permission android:name="android.permission.VIBRATE" />

在这里先给贴出英文文档及大概的翻译 :


Class that operates the vibrator on the device.
If your process exits, any vibration you started with will stop.

Vibrator类用来操作设备上的震动,如果你的线程退出了,那么启动的震动也会停止

Pass in an array of ints that are the durations for which to turn on or off the vibrator in milliseconds. The first value indicates the number of milliseconds to wait before turning the vibrator on. The next value indicates the number of milliseconds for which to keep the vibrator on before turning it off.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值