Detailed Method Reference
Namespace: Canley.Utility.Haptics
Class: CanleyHaptics
Trigger
public static void Trigger(HapticStyle style)-
Description: The main entry point to fire haptic feedback. It maps a qualitative style to the specific native motor instructions required by the current platform.
-
Workflow:
- Master Toggle Check: Immediately exits if
CanleyHaptics.Enabledis set tofalse. - Platform Routing:
- Unity Editor: Bypasses hardware calls and prints a Rich Text log to the console.
- iOS: Sends the style index to the Objective-C bridge for the Taptic Engine.
- Android: Performs a version check to execute the highest-fidelity API available (Composition, Modern, or Legacy).
- Master Toggle Check: Immediately exits if
-
Parameters:
style: The qualitativeHapticStyleto be played (e.g.,SoftBump,TriplePulse).
-
Returns:
void -
Example:
using Canley.Utility.Haptics;
// Triggers a sharp, heavy impact suitable for explosions or collisions
CanleyHaptics.Trigger(CanleyHaptics.HapticStyle.HeavyBump);TIP
This method is engineered to be “Zero-Allocation.” You can safely call it from high-frequency methods (like
UpdateorOnCollisionEnter) without causing garbage collection spikes or frame rate stutters.