Introduction | Sample App | Installation | Code Overview
I made this "vibration utility for Unity" to ease your app development.
When I developed the vibration with Unity at work, I spent a lot of time testing the vibration, and getting feedbacks.
Here are the sample codes and plugin(iOS) ready for you!
Feel free to use my script and sample app!
All of the scripts are written per official AOS/iOS documents.
Please don't forget to read the document before use.
Refer to the "Reference" section for details.
All of the Android predefined vibration types are made by trial and errors.
Tried my best to make AOS vibration as similar as iOS predefined vibration types.
Try out my sample app to customize your own vibration conveniently.
Any feedbacks are always welcome. Submit issues if you have any. I will reply to your issues ASAP. (Enhancement, bugs, advice, etc)
Google Play : Vibration Tester
-
Copy all files in ./Assets/Scripts/
- VibrationInstance.cs
- VibrationAndroid.cs
- VibrationEditor.cs
- VibrationIOS.cs
- VibrationUtil.cs
-
Android :
- Add
<uses-permission android:name = "android.permission.VIBRATE"/>
in your AndroidManifest.xml
- Add
-
iOS :
- Copy plugin file in ./Assets/Plugins
- VibrationPlugin.mm
- Copy plugin file in ./Assets/Plugins
- Android
- API Level >= 26
- Permssion :
<uses-permission android:name = "android.permission.VIBRATE"/>
- IOS
- OS Version : >= 10.0
- Galaxy Note 20 (AOS 13)
- Galaxy A52s (AOS 13)
- Iphone 12 mini (iOS 16 & 17)
public abstract void Vibrate(VibrationType vibrationType);
Vibrates using pre-defined types. See Vibrationtype
enum VibrationType
Default = 1352, Peek = 1519, Pop = 1520, Nope = 1521, Heavy, Medium, Light, Rigid, Soft, Error, Success, Warning
public class AmplitudeType {}
Vibration Amplitude Types
These values are adjusted by trial and errors on Samsung Galaxy.
public class LengthType {}
(Customized) Vibration length (duration) types
These values are adjusted by trial and error on Samsung Galaxy.
public class VibrationAndroid : VibrationInstance { }
Implements vibration method for AOS
protected override bool IsVibrationAvailable();
Checks if the Android device supports the vibration API. Checks 2 functions : HasVibrator && API Level >= 26
- True : Available
- False : Not Available
public class VibrationIOS : VibrationInstance { }
Implements vibration method for iOS
protected override bool IsVibrationAvailable();
Does not check availability for iOS for now. Always return true.
- True : Available