com.xmobitea.changx.mini-vibrate
v1.5.2
Published
Unity mobile vibration and haptic wrapper for Android, iOS, and mobile WebGL.
Readme
XmobiTea Vibrate
Unity mobile vibration and haptic wrapper for Android, iOS, and mobile WebGL.
AI Entry Points
Open the smallest file for the task:
| Need | Use |
| --- | --- |
| Generate common runtime code | AI_USAGE.md |
| Setup, Android bootstrap, initialization order | AI_SETUP.md |
| Exact signatures, enum values, compile guards, returns | AI_API_REFERENCE.md |
| Platform behavior, WebGL limits, Android hazards, async behavior | AI_BEHAVIOR.md |
| Agent guardrails and maintenance checklist | AGENTS.md |
| Missing or conflicting docs | Runtime/Vibration.cs |
Provides
- Static helper:
XmobiTea.MiniVibrate.Vibration - Android vibration through Unity Android Java bridge
- iOS preset vibration bridge:
Plugins/iOS/Vibration.h,Plugins/iOS/Vibration.mm - iOS semantic haptics:
Plugins/iOS/HapticFeedback.mm - Generic
Vibrate()path:Handheld.Vibrate()on Android/iOS,navigator.vibrate(1)on mobile WebGL - WebGL vibration bridge:
Plugins/WebGL/vibrate.jslib
Required Setup
Call Vibration.Init() once during early startup when Android can execute the call path.
For Android builds, make sure the final app manifest includes android.permission.VIBRATE. This package does not ship an Android manifest.
The same shared startup call is harmless on iOS and WebGL; it only performs Android handle caching under UNITY_ANDROID.
See AI_SETUP.md for the bootstrap pattern and call-order rules.
Common Calls
using XmobiTea.MiniVibrate;
Vibration.VibratePop();
Vibration.Vibrate();
_ = Vibration.VibrateNope();
Vibration.SetActive(enabled);Decision Guide
| Need | Use |
| --- | --- |
| Generic tap/click feedback | Vibration.VibratePop() |
| Generic OS vibration | Vibration.Vibrate() |
| Slightly longer preset on Android/WebGL | Vibration.VibratePeek() |
| Negative/reject feedback | Vibration.VibrateNope() |
| App vibration setting | Vibration.SetActive(enabled) |
| iOS semantic success/warning/error | Vibration.VibrateIOS(NotificationFeedbackStyle.Success) behind an iOS-specific path |
| iOS impact style | Vibration.VibrateIOS(ImpactFeedbackStyle.Light) behind an iOS-specific path |
| Android custom duration/pattern | Vibration.VibrateAndroid(...) inside #if UNITY_ANDROID |
Hard Limits
- Android does not auto-initialize. Call
Vibration.Init()before availability checks, package vibration calls,SetActive(false), orCancelAndroid()on Android. - Android vibration requires
android.permission.VIBRATEin the final app manifest; the package does not add it by itself. - Android custom APIs compile only under
UNITY_ANDROID. - Android Java bridge fields exposed by
Vibrationare package-owned cached handles. Do not read, assign, or use them as a setup shortcut; callVibration.Init()instead. - Public
Vibrate()on Android/iOS uses UnityHandheld.Vibrate(). The iOS_Vibrate()native export exists, but the current public API does not call it. SetActive(false)is runtime-only package mute, not persisted settings and not an OS setting.HasVibrator()on WebGL does not probenavigator.vibrate; mobile WebGL can report available while unsupported browsers silently no-op in the jslib.- Desktop should be treated as unsupported.
Package Metadata
- Package:
com.xmobitea.changx.mini-vibrate - Runtime assembly:
com.xmobitea.changx.mini-vibrate.runtime - Namespace:
XmobiTea.MiniVibrate - Unity:
2022.3 - Dependencies:
com.xmobitea.changx.app - License:
Apache-2.0
