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:

    1. Master Toggle Check: Immediately exits if CanleyHaptics.Enabled is set to false.
    2. 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).
  • Parameters:

    • style: The qualitative HapticStyle to 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 Update or OnCollisionEnter) without causing garbage collection spikes or frame rate stutters.