Gameptics 1.0.0
Gameptics (Game+Haptics) is a lightweight cross-platform haptics toolkit for Unity. Author haptic signals and sequences with duration, intensity and sharpness, then play them on iOS and Android.
Loading...
Searching...
No Matches
SCG.Gameptics.GamepticSignal Class Referencesealed

Describes a single haptic signal request. Provides duration, intensity, and sharpness, with optional curves over normalized time. This type is platform-agnostic and can be interpreted by runtime backends differently. More...

Public Member Functions

 GamepticSignal (float durationSeconds, float intensity, float sharpness)
 Creates a new signal instance for runtime usage. The constructor sets base values only, without curves. Curves can be configured via SetCurves.
 GamepticSignal ()
 Creates a default instance for Unity serialization. Values can be edited in the inspector and used as inline data. Curves are disabled by default.
void SetCurves (bool enableCurves, AnimationCurve newIntensityCurve, AnimationCurve newSharpnessCurve, int newCurveSamples)
 Configures curve-driven playback for this signal. This controls whether curves are used and which curves are evaluated. The method is safe to call at runtime and in editor tooling.
float EvaluateIntensity (float t01)
 Evaluates intensity for the provided normalized time. Falls back to the base intensity when curves are disabled or missing. The returned value is clamped to range [0..1].
float EvaluateSharpness (float t01)
 Evaluates sharpness for the provided normalized time. Falls back to the base sharpness when curves are disabled or missing. The returned value is clamped to range [0..1].
bool TryBuildCurveSamples (out float[] times01, out float[] intensities01, out float[] sharpness01)
 Attempts to build curve samples for supported backends. Produces normalized time points and normalized values in range [0..1]. Returns false when curve mode is disabled or sampling is not applicable.

Static Public Member Functions

static GamepticSignal Create (float durationSeconds, float intensity, float sharpness, bool enableCurves, AnimationCurve intensityCurve, AnimationCurve sharpnessCurve, int curveSamples)
 Creates a signal instance with optional curves in a single expression. This is designed for editor tooling and code generation scenarios. Curves are copied by reference and can be shared intentionally.

Properties

float DurationSeconds = 0.05f [get, set]
 Signal duration in seconds.
float Intensity = 0.7f [get, set]
 Base intensity in range [0..1].
float Sharpness = 0.7f [get, set]
 Base sharpness in range [0..1].
bool CurvesEnabled [get]
 Gets whether curve evaluation is enabled for this signal. When enabled, missing curves still fall back to base intensity and sharpness. Backends may ignore curves if they are not supported by the platform.
AnimationCurve IntensityCurve [get]
 Gets the configured intensity curve. When the curve is missing or invalid, intensity falls back to the base value. The curve is evaluated over normalized time [0..1].
AnimationCurve SharpnessCurve [get]
 Gets the configured sharpness curve. When the curve is missing or invalid, sharpness falls back to the base value. The curve is evaluated over normalized time [0..1].
int RequestedCurveSamples [get]
 Gets the requested curve sample count. This is used by backends that need uniform sampling for waveform-like playback. Values are clamped to safe bounds when evaluated.
bool UseCurves [get]
 Returns true when curve playback is enabled and at least one curve is valid. Backends may still ignore curves if they are not supported. This does not validate tangents or keyframe continuity.
bool HasIntensityCurve [get]
 Returns true when the intensity curve is assigned and contains enough keys. This is used as a lightweight validity check for curve evaluation. Curves with a single key are treated as invalid for time sampling.
bool HasSharpnessCurve [get]
 Returns true when the sharpness curve is assigned and contains enough keys. This is used as a lightweight validity check for curve evaluation. Curves with a single key are treated as invalid for time sampling.
int CurveSamples [get]
 Returns the requested sample count for curve-driven playback, clamped to safe bounds. This value is used by sampling-based backends when building waveforms. The bounds are chosen to avoid extreme allocations and timing jitter.

Detailed Description

Describes a single haptic signal request. Provides duration, intensity, and sharpness, with optional curves over normalized time. This type is platform-agnostic and can be interpreted by runtime backends differently.


The documentation for this class was generated from the following file:
  • SCG/Gameptics/Core/GamepticSignal.cs