Impulse Vibrations for iOS and Android (aka Taptic or Haptic Engine) 📳
Impulse Vibrations is providing bridging between mobile haptic vibration API's and Unity3D Engine. Basically, it's an wrapper around UIFeedbackGenerator [iOS], Vibrator [Android], and View#performHapticFeedback() [Android].
Unlike most of the other Unity plugins, this will not provide you a common interface for each platform. Yet, it will give you more control over the code as a developer!
OS/Device Support 📲
- Support iOS 10+ starting from iPhone 7 to the latest model/OS
- Supports all Android versions
Features ⚙️
- Example Unity scene to test the API.
- Has safe to use API, it checks the OS versions and fallbacks in some cases.
- It has one line easy to use integration.
- iOS Taptic Engine support with
UIFeedbackGeneratorclass. - Android
Vibratorclass support. - Android
View#performHapticFeedback()class support for starting from SDK level 26. - API documentation and Comments above the functions
- All of the source code included, so it's open for extend.
iOS API 📄
- UISelectionFeedbackGenerator
- UIImpactFeedbackGenerator (light, medium, heavy, rigid, soft)
- UINotificationFeedbackGenerator (success, warning, error)
Android API 📄
- HapticFeedbackConstants
- Vibrate with VibrationEffect (long milliseconds, int amplitude = -1)
Important Note 🗒
- Don't forget to add the
using ImpulseVibrations;line on the top of your class. - Some Android devices doesn't support all of the Haptic Feedbacks.
- Taptic Engine and Vibrations will only work on the physical device. So consider the test this feature on the real device instead of Unity Editor.
Example 🧪
- For iOS you could try
Vibrator.iOSVibrate();, This will triggerselectionfeedback. - For Android you could try
Vibrator.AndroidVibrate(HapticFeedbackConstants.LONG_PRESS);, This will trigger the long press feedback.