Alexey Chubar
e7314e688b
Build and Publish NPM Package / docker (push) Successful in 14s
Details
|
||
---|---|---|
.gitea/workflows | ||
MMNiceVibrations | ||
Resources | ||
Runtime | ||
.gitignore | ||
CHANGELOG.md | ||
CHANGELOG.md.meta | ||
MMNiceVibrations.meta | ||
README.md | ||
README.md.meta | ||
Resources.meta | ||
Runtime.meta | ||
package.json | ||
package.json.meta |
README.md
At a glance
Lightweight wrapper for native haptic feedback APIs for Android & iOS.
Currently contains:
HapticFeedbackAndroid
&HapticFeedbackIOS
wrappers to access OS APIs with little to no allocationsHapticFeedbackChirp
: combine OS haptic primitives to build pleasant vibration patternsHapticsManager
: helper class for feedback pacing control
Usage
using BitGames.Haptics;
...
//Step 1: Create a manager
var haptics = new HapticsManager(maxConcurrentFeedbacks: 1, () => UnityEngine.Time.time);
haptics.Init();
//Step 2: Register a pattern
const int myPatternID = 1337;
haptics.Register(myPatternID, new HapticFeedbackChirp(haptics.ChirpEngine,
HapticChirpIntensity.High,
HapticChirpIntensity.Low,
HapticChirpIntensity.None,
HapticChirpIntensity.None,
HapticChirpIntensity.High,
HapticChirpIntensity.Low
));
//(pro-tip: no need to hardcode: use HapticFeedbackChirpPatternAsset for pattern content)
//(pro-tip 2: use project-specific metagen enums for pattern IDs)
//Step 3: Fire a haptic feedback when necessary
haptics.Feedback(myPatternID);