### Play a preset haptic with Haptics.PlayPreset Source: https://github.com/acharad/richhaptic/blob/main/README.md Use the static Haptics class to play a preset haptic. No setup or initialization is required. On iOS, system feedback generators are used; on Android, an authored approximation is played. Note that system haptics cannot be cancelled and OutputLevel does not scale Selection/Success/Warning/Failure presets. ```csharp using RichHaptic; using RichHaptic.Data; Haptics.PlayPreset(PresetType.Success); ``` -------------------------------- ### Haptics.StartContinuous(float, float) Source: https://github.com/acharad/richhaptic/blob/main/README.md Starts a continuous haptic session with the given intensity and sharpness. The session runs until `StopContinuous` is called, with a platform-specific maximum duration (100 seconds on iOS, 30 on Android). ```APIDOC ## [C#] Haptics.StartContinuous(float, float) ### Description Starts a continuous haptic session with the given intensity and sharpness. The session runs until `StopContinuous` is called, with a platform-specific maximum duration (100 seconds on iOS, 30 on Android). ### Method C# static method ### Signature `Haptics.StartContinuous(float intensity, float sharpness)` ### Parameters - **intensity** (float) - Required - The intensity of the haptic feedback. - **sharpness** (float) - Required - The sharpness of the haptic feedback. ### Remarks - There is no duration parameter; the session runs until `StopContinuous` is called. - On Android, every `UpdateContinuous` call sends a fresh segment and restarts the clock. ### Example ```csharp void OnDrawStart() => Haptics.StartContinuous(intensity: 0.2f, sharpness: 0.5f); ``` ``` -------------------------------- ### Haptics.OutputLevel Property Source: https://github.com/acharad/richhaptic/blob/main/README.md Gets or sets the output level as a 0-1 multiplier applied to every haptic call. Setting to 0 silences everything. ```APIDOC ## [C#] Haptics.OutputLevel Property ### Description Gets or sets the output level as a 0-1 multiplier applied to every haptic call. Setting to 0 silences everything. ### Property `public static float OutputLevel { get; set; }` ### Remarks - On iOS, scales the five impacts but not Selection/Success/Warning/Failure. ### Example ```csharp Haptics.OutputLevel = 0.5f; // 0-1 multiplier over every call ``` ``` -------------------------------- ### Haptics.SupportLevel Property Source: https://github.com/acharad/richhaptic/blob/main/README.md Gets the current support level for haptics on the device. Can be used to hide UI elements if haptics are not supported. ```APIDOC ## [C#] Haptics.SupportLevel Property ### Description Gets the current support level for haptics on the device. Can be used to hide UI elements if haptics are not supported. ### Property `public static SupportLevel SupportLevel { get; }` ### Remarks - `SupportLevel.None` indicates no haptic support. ### Example ```csharp if (Haptics.SupportLevel == SupportLevel.None) settingsRow.SetActive(false); // nothing to offer the player, hide the toggle ``` ``` -------------------------------- ### Install via Git URL Source: https://github.com/acharad/richhaptic/blob/main/README.md Adds the RichHaptic package from a git URL in Unity's Package Manager. Use the 'Add package from git URL' option. ```text https://github.com/Acharad/RichHaptic.git?path=src/RichHaptic/Assets/RichHaptic ``` -------------------------------- ### Install via OpenUPM Source: https://github.com/acharad/richhaptic/blob/main/README.md Adds the RichHaptic package using the OpenUPM CLI. Requires the openupm-cli tool. ```shell openupm add com.acharad.richhaptic ``` -------------------------------- ### Continuous haptic feedback with StartContinuous, UpdateContinuous, StopContinuous Source: https://github.com/acharad/richhaptic/blob/main/README.md Start a continuous haptic session, update it with new intensity/sharpness values, and stop it when done. UpdateContinuous allocates nothing and is safe to call every frame. Sessions run until stopped, with a platform-specific ceiling (100s on iOS, 30s on Android) that silently ends the session if reached. ```csharp void OnDrawStart() => Haptics.StartContinuous(intensity: 0.2f, sharpness: 0.5f); void OnDrawUpdate(float t) => Haptics.UpdateContinuous(t, 0.5f); // safe every frame void OnRelease() => Haptics.StopContinuous(); ``` -------------------------------- ### Haptics.PlayClip(HapticClip) Source: https://github.com/acharad/richhaptic/blob/main/README.md Plays a haptic clip, which is a ScriptableObject containing a list of events with type, start time, intensity, and sharpness. The clip is created via Create → RichHaptic → Haptic Clip. ```APIDOC ## [C#] Haptics.PlayClip(HapticClip) ### Description Plays a haptic clip, which is a ScriptableObject containing a list of events with type, start time, intensity, and sharpness. The clip is created via Create → RichHaptic → Haptic Clip. ### Method C# static method ### Signature `Haptics.PlayClip(HapticClip clip)` ### Parameters - **clip** (HapticClip) - Required - The haptic clip to play. ### Remarks - The demo sample ships three clips: a heartbeat, a charge-up, and a rising four-beat hit. ### Example ```csharp [SerializeField] private HapticClip explosion; void OnHit() => Haptics.PlayClip(explosion); ``` ``` -------------------------------- ### Haptics.Service Property Source: https://github.com/acharad/richhaptic/blob/main/README.md Returns the same haptic instance behind an IHapticService interface, useful for dependency injection containers. Both paths mutate the same state. ```APIDOC ## [C#] Haptics.Service Property ### Description Returns the same haptic instance behind an IHapticService interface, useful for dependency injection containers. Both paths mutate the same state. ### Property `public static IHapticService Service { get; }` ### Remarks - The returned instance is the same as the static class's internal state. ### Example ```csharp // Register in a container container.RegisterInstance(Haptics.Service); ``` ``` -------------------------------- ### Haptics.HapticsEnabled Property Source: https://github.com/acharad/richhaptic/blob/main/README.md Gets or sets whether haptics are enabled. Setting to false stops anything already playing. Useful for a settings toggle. ```APIDOC ## [C#] Haptics.HapticsEnabled Property ### Description Gets or sets whether haptics are enabled. Setting to false stops anything already playing. Useful for a settings toggle. ### Property `public static bool HapticsEnabled { get; set; }` ### Example ```csharp Haptics.HapticsEnabled = false; // settings toggle; stops anything already playing ``` ``` -------------------------------- ### Haptics.PlayPreset(PresetType) Source: https://github.com/acharad/richhaptic/blob/main/README.md Plays a system haptic preset. On iOS it uses the system's feedback generators; on Android it plays an authored approximation. Presets include Selection, Success, Warning, Failure, and five impacts (LightImpact through HeavyImpact, plus RigidImpact and SoftImpact). ```APIDOC ## [C#] Haptics.PlayPreset(PresetType) ### Description Plays a system haptic preset. On iOS it uses the system's feedback generators; on Android it plays an authored approximation. Presets include Selection, Success, Warning, Failure, and five impacts (LightImpact through HeavyImpact, plus RigidImpact and SoftImpact). ### Method C# static method ### Signature `Haptics.PlayPreset(PresetType presetType)` ### Parameters - **presetType** (PresetType) - Required - The preset to play. Valid values: Selection, Success, Warning, Failure, LightImpact, MediumImpact, HeavyImpact, RigidImpact, SoftImpact. ### Remarks - On iOS, system haptics cannot be cancelled; `Stop()` will not cut a preset short. - `OutputLevel` scales the five impacts but not Selection/Success/Warning/Failure. - Setting `OutputLevel` to 0 silences everything. ### Example ```csharp using RichHaptic; using RichHaptic.Data; Haptics.PlayPreset(PresetType.Success); ``` ``` -------------------------------- ### Haptics.Priority Property Source: https://github.com/acharad/richhaptic/blob/main/README.md Gets or sets the priority for haptic calls. Lower numbers win, range is 0–256, default is 128. When something is already playing, a new call with a worse priority is dropped. ```APIDOC ## [C#] Haptics.Priority Property ### Description Gets or sets the priority for haptic calls. Lower numbers win, range is 0–256, default is 128. When something is already playing, a new call with a worse priority is dropped. ### Property `public static int Priority { get; set; }` ### Remarks - Lower numbers win. - Range is 0–256, default is 128. - Stopping is never gated: `StopContinuous` and `Stop` work regardless of priority. ### Example ```csharp Haptics.Priority = 0; Haptics.PlayClip(explosion); // important, ~0.3 s long Haptics.Priority = 200; Haptics.PlayClip(footstep); // arrives mid-explosion, so it never plays ``` ``` -------------------------------- ### Haptics.UpdateContinuous(float, float) Source: https://github.com/acharad/richhaptic/blob/main/README.md Updates the continuous haptic session with new intensity and sharpness values. Safe to call every frame and allocates nothing. ```APIDOC ## [C#] Haptics.UpdateContinuous(float, float) ### Description Updates the continuous haptic session with new intensity and sharpness values. Safe to call every frame and allocates nothing. ### Method C# static method ### Signature `Haptics.UpdateContinuous(float intensity, float sharpness)` ### Parameters - **intensity** (float) - Required - The new intensity value. - **sharpness** (float) - Required - The new sharpness value. ### Remarks - Allocates nothing, so it can be called from `Update`. - On Android, each call sends a fresh segment and restarts the session clock. ### Example ```csharp void OnDrawUpdate(float t) => Haptics.UpdateContinuous(t, 0.5f); ``` ``` -------------------------------- ### Haptics.StopContinuous() Source: https://github.com/acharad/richhaptic/blob/main/README.md Stops the current continuous haptic session. Works regardless of the caller's priority. ```APIDOC ## [C#] Haptics.StopContinuous() ### Description Stops the current continuous haptic session. Works regardless of the caller's priority. ### Method C# static method ### Signature `Haptics.StopContinuous()` ### Parameters None. ### Example ```csharp void OnRelease() => Haptics.StopContinuous(); ``` ``` -------------------------------- ### Play a haptic clip with PlayClip Source: https://github.com/acharad/richhaptic/blob/main/README.md Play a HapticClip ScriptableObject, which is edited in the Inspector. Create clips via Create → RichHaptic → Haptic Clip. The demo sample includes three clips (heartbeat, charge-up, rising four-beat hit) with buttons for each. ```csharp [SerializeField] private HapticClip explosion; void OnHit() => Haptics.PlayClip(explosion); ``` -------------------------------- ### Play a constant haptic with PlayConstant Source: https://github.com/acharad/richhaptic/blob/main/README.md Play a single haptic pulse with fixed intensity, sharpness, and a specified duration. Use this when you know the duration in advance, as an alternative to continuous feedback. ```csharp Haptics.PlayConstant(intensity: 0.8f, sharpness: 0.5f, duration: 0.4f); ``` -------------------------------- ### Haptics.PlayConstant(float, float, float) Source: https://github.com/acharad/richhaptic/blob/main/README.md Plays a single haptic pulse with a fixed intensity, sharpness, and a specified duration. Useful when the duration is known in advance. ```APIDOC ## [C#] Haptics.PlayConstant(float, float, float) ### Description Plays a single haptic pulse with a fixed intensity, sharpness, and a specified duration. Useful when the duration is known in advance. ### Method C# static method ### Signature `Haptics.PlayConstant(float intensity, float sharpness, float duration)` ### Parameters - **intensity** (float) - Required - The intensity of the pulse. - **sharpness** (float) - Required - The sharpness of the pulse. - **duration** (float) - Required - The duration of the pulse in seconds. ### Example ```csharp Haptics.PlayConstant(intensity: 0.8f, sharpness: 0.5f, duration: 0.4f); ``` ``` -------------------------------- ### Priority-based haptic playback with Haptics.Priority Source: https://github.com/acharad/richhaptic/blob/main/README.md Set the priority for haptic calls. Lower numbers win; range is 0–256, default 128. When a new call has a worse priority than the currently playing haptic, it is dropped. Stopping is never gated by priority. ```csharp Haptics.Priority = 0; Haptics.PlayClip(explosion); // important, ~0.3 s long Haptics.Priority = 200; Haptics.PlayClip(footstep); // arrives mid-explosion, so it never plays ``` -------------------------------- ### Global haptic controls: HapticsEnabled, OutputLevel, SupportLevel Source: https://github.com/acharad/richhaptic/blob/main/README.md Control haptics globally: disable/enable haptics (stops anything playing), set output level (0-1 multiplier), and check support level to hide UI if unsupported. Also available via Haptics.Service behind an IHapticService interface. ```csharp Haptics.HapticsEnabled = false; // settings toggle; stops anything already playing Haptics.OutputLevel = 0.5f; // 0-1 multiplier over every call if (Haptics.SupportLevel == SupportLevel.None) settingsRow.SetActive(false); // nothing to offer the player, hide the toggle ```