Nice Vibrations  v3.9
Static Public Member Functions | Static Public Attributes | List of all members
MoreMountains.NiceVibrations.MMVibrationManager Class Reference

This class will allow you to trigger vibrations and haptic feedbacks on both iOS and Android, or on each specific platform independently. More...

Static Public Member Functions

static void SetHapticsActive (bool status)
 Enables or disables all haptics called via this class More...
 
static bool HapticsSupported ()
 Returns true if haptics are supported on this device More...
 
static void SetDebugMode (bool log)
 Enables or disables console logs (off by default) More...
 
static bool Android ()
 Returns true if the current platform is Android, false otherwise. More...
 
static bool iOS ()
 Returns true if the current platform is iOS, false otherwise More...
 
static void Vibrate ()
 Triggers a simple vibration More...
 
static void Haptic (HapticTypes type, bool defaultToRegularVibrate=false, bool alsoRumble=false, MonoBehaviour coroutineSupport=null, int controllerID=-1)
 Triggers a haptic feedback of the specified type More...
 
static void TransientHaptic (float intensity, float sharpness, bool alsoRumble=false, MonoBehaviour coroutineSupport=null, int controllerID=-1)
 Plays a transient haptic, a single, short haptic feedback, of the specified intensity and sharpness More...
 
static void TransientHaptic (bool vibrateiOS, float iOSIntensity, float iOSSharpness, bool vibrateAndroid, float androidIntensity=1f, float androidSharpness=1f, bool vibrateAndroidIfNoSupport=false, bool rumble=true, float rumbleLowFrequency=1f, float rumbleHighFrequency=1f, int controllerID=-1, MonoBehaviour coroutineSupport=null, bool threaded=true)
 Plays a transient haptic, signature with more fine control More...
 
static void ContinuousHaptic (float intensity, float sharpness, float duration, HapticTypes fallbackOldiOS=HapticTypes.None, MonoBehaviour mono=null, bool alsoRumble=false, int controllerID=-1, bool threaded=false, bool fullIntensity=true)
 Plays a continuous haptic of the specified intensity, sharpness and duration More...
 
static void ContinuousHaptic (bool vibrateiOS, float iOSIntensity, float iOSSharpness, HapticTypes fallbackOldiOS, bool vibrateAndroid, float androidIntensity, float androidSharpness, bool vibrateAndroidIfNoSupport, bool rumble, float rumbleLowFrequency, float rumbleHighFrequency, int controllerID, float duration, MonoBehaviour mono=null, bool threaded=false, bool fullIntensity=true)
 Plays a continuous haptic, full options signature More...
 
static void UpdateContinuousHaptic (float intensity, float sharpness, bool alsoRumble=false, int controllerID=-1, bool threaded=false)
 Updates a continuous haptic while it's playing. Not supported on Android for now, until Google adds API support for that More...
 
static void UpdateContinuousHaptic (bool ios, float iosIntensity, float iosSharpness, bool android, float androidIntensity, float androidSharpness, bool rumble, float rumbleLowFrequency, float rumbleHighFrequency, int controllerID=-1, bool threaded=false)
 Updates a continuous haptic while it's playing. Not supported on Android for now, until Google adds API support for that More options signature More...
 
static void StopAllHaptics (bool alsoRumble=false)
 Stops all currently running haptics More...
 
static void StopContinuousHaptic (bool alsoRumble=false)
 Stops all running pattern or continuous haptics More...
 
static void AdvancedHapticPattern (string iOSJSONString, long[] androidPattern, int[] androidAmplitudes, int androidRepeat, long[] rumblePattern, int[] rumbleLowFreqAmplitudes, int[] rumbleHighFreqAmplitudes, int rumbleRepeat, HapticTypes fallbackOldiOS=HapticTypes.None, MonoBehaviour coroutineSupport=null, int controllerID=-1, bool threaded=false)
 Plays a haptic pattern, the most complex type of haptic, defined by a JSON string on iOS, and a pattern on Android More...
 
static void AdvancedHapticPattern (bool ios, string iOSJSONString, bool android, long[] androidPattern, int[] androidAmplitudes, int androidRepeat, bool vibrateAndroidIfNoSupport, bool rumble, long[] rumblePattern, int[] rumbleLowFreqAmplitudes, int[] rumbleHighFreqAmplitudes, int rumbleRepeat, HapticTypes fallbackOldiOS=HapticTypes.None, MonoBehaviour coroutineSupport=null, int controllerID=-1, bool threaded=false)
 Plays a advanced haptic pattern, More...
 
static float Remap (float x, float A, float B, float C, float D)
 Remaps value x between AB to CD More...
 

Static Public Attributes

static float iOSVersion
 the current iOS version More...
 
static long LightDuration = 20
 the duration of the light vibration (in microseconds) More...
 
static long MediumDuration = 40
 the duration of the medium vibration (in microseconds) More...
 
static long HeavyDuration = 80
 the duration of the heavy vibration (in microseconds) More...
 
static long RigidDuration = 20
 the duration of the rigid vibration (in microseconds) More...
 
static long SoftDuration = 80
 the duration of the soft vibration (in microseconds) More...
 
static int LightAmplitude = 40
 the amplitude of the light vibration More...
 
static int MediumAmplitude = 120
 the amplitude of the medium vibration More...
 
static int HeavyAmplitude = 255
 the amplitude of the heavy vibration More...
 
static int RigidAmplitude = 255
 the amplitude of the rigid vibration More...
 
static int SoftAmplitude = 40
 the amplitude of the soft vibration More...
 

Detailed Description

This class will allow you to trigger vibrations and haptic feedbacks on both iOS and Android, or on each specific platform independently.

For haptics patterns, it takes inspiration from the iOS guidelines : https://developer.apple.com/ios/human-interface-guidelines/user-interaction/feedback Of course the iOS haptics are called directly as they are, and they're crudely reproduced on Android. Feel free to tweak the patterns or create your own.

Here's a brief overview of the patterns :

In addition, this class will also let you trigger core haptics on supported devices running recent versions of iOS (after iOS 13). These let you trigger transient or continuous haptics, or play AHAP based JSON strings for even more control.

Member Function Documentation

◆ AdvancedHapticPattern() [1/2]

static void MoreMountains.NiceVibrations.MMVibrationManager.AdvancedHapticPattern ( bool  ios,
string  iOSJSONString,
bool  android,
long[]  androidPattern,
int[]  androidAmplitudes,
int  androidRepeat,
bool  vibrateAndroidIfNoSupport,
bool  rumble,
long[]  rumblePattern,
int[]  rumbleLowFreqAmplitudes,
int[]  rumbleHighFreqAmplitudes,
int  rumbleRepeat,
HapticTypes  fallbackOldiOS = HapticTypes.None,
MonoBehaviour  coroutineSupport = null,
int  controllerID = -1,
bool  threaded = false 
)
static

Plays a advanced haptic pattern,

Parameters
ios
iOSJSONString
android
androidPattern
androidAmplitudes
androidRepeat
vibrateAndroidIfNoSupport
rumble
rumblePattern
rumbleLowFreqAmplitudes
rumbleHighFreqAmplitudes
rumbleRepeat
fallbackOldiOS
coroutineSupport
controllerID

◆ AdvancedHapticPattern() [2/2]

static void MoreMountains.NiceVibrations.MMVibrationManager.AdvancedHapticPattern ( string  iOSJSONString,
long[]  androidPattern,
int[]  androidAmplitudes,
int  androidRepeat,
long[]  rumblePattern,
int[]  rumbleLowFreqAmplitudes,
int[]  rumbleHighFreqAmplitudes,
int  rumbleRepeat,
HapticTypes  fallbackOldiOS = HapticTypes.None,
MonoBehaviour  coroutineSupport = null,
int  controllerID = -1,
bool  threaded = false 
)
static

Plays a haptic pattern, the most complex type of haptic, defined by a JSON string on iOS, and a pattern on Android

Parameters
iOSJSONString
androidPattern
androidAmplitudes
androidRepeat
fallbackOldiOS

◆ Android()

static bool MoreMountains.NiceVibrations.MMVibrationManager.Android ( )
static

Returns true if the current platform is Android, false otherwise.

◆ ContinuousHaptic() [1/2]

static void MoreMountains.NiceVibrations.MMVibrationManager.ContinuousHaptic ( bool  vibrateiOS,
float  iOSIntensity,
float  iOSSharpness,
HapticTypes  fallbackOldiOS,
bool  vibrateAndroid,
float  androidIntensity,
float  androidSharpness,
bool  vibrateAndroidIfNoSupport,
bool  rumble,
float  rumbleLowFrequency,
float  rumbleHighFrequency,
int  controllerID,
float  duration,
MonoBehaviour  mono = null,
bool  threaded = false,
bool  fullIntensity = true 
)
static

Plays a continuous haptic, full options signature

Parameters
vibrateiOS
iOSIntensity
iOSSharpness
fallbackOldiOS
vibrateAndroid
androidIntensity
androidSharpness
vibrateAndroidIfNoSupport
rumble
rumbleLowFrequency
rumbleHighFrequency
controllerID
durationthe duration in seconds
monoa monobehaviour to use to sustain this haptic
threadedwhether to call this on the main thread (false) or a secondary one (true)
fullIntensitywhether to allow for full intensity control for subsequent updates

◆ ContinuousHaptic() [2/2]

static void MoreMountains.NiceVibrations.MMVibrationManager.ContinuousHaptic ( float  intensity,
float  sharpness,
float  duration,
HapticTypes  fallbackOldiOS = HapticTypes.None,
MonoBehaviour  mono = null,
bool  alsoRumble = false,
int  controllerID = -1,
bool  threaded = false,
bool  fullIntensity = true 
)
static

Plays a continuous haptic of the specified intensity, sharpness and duration

Parameters
intensitythe intensity of the haptic, between 0 and 1
sharpnessthe sharpness of the haptic, between 0 and 1
durationthe duration in seconds
fallbackOldiOSthe fallback to use on old iOS versions that don't support Core Haptics
monoa monobehaviour to use to sustain this haptic
alsoRumblewhether to also rumble or not
controllerIDthe ID of the controller
threadedwhether to call this on the main thread (false) or a secondary one (true)
fullIntensitywhether to allow for full intensity control for subsequent updates

◆ Haptic()

static void MoreMountains.NiceVibrations.MMVibrationManager.Haptic ( HapticTypes  type,
bool  defaultToRegularVibrate = false,
bool  alsoRumble = false,
MonoBehaviour  coroutineSupport = null,
int  controllerID = -1 
)
static

Triggers a haptic feedback of the specified type

Parameters
typeType.

◆ HapticsSupported()

static bool MoreMountains.NiceVibrations.MMVibrationManager.HapticsSupported ( )
static

Returns true if haptics are supported on this device

Returns

◆ iOS()

static bool MoreMountains.NiceVibrations.MMVibrationManager.iOS ( )
static

Returns true if the current platform is iOS, false otherwise

Returns
true, if O was ied, false otherwise.

◆ Remap()

static float MoreMountains.NiceVibrations.MMVibrationManager.Remap ( float  x,
float  A,
float  B,
float  C,
float  D 
)
static

Remaps value x between AB to CD

Parameters
x
A
B
C
D
Returns

◆ SetDebugMode()

static void MoreMountains.NiceVibrations.MMVibrationManager.SetDebugMode ( bool  log)
static

Enables or disables console logs (off by default)

Parameters
log

◆ SetHapticsActive()

static void MoreMountains.NiceVibrations.MMVibrationManager.SetHapticsActive ( bool  status)
static

Enables or disables all haptics called via this class

Parameters
status

◆ StopAllHaptics()

static void MoreMountains.NiceVibrations.MMVibrationManager.StopAllHaptics ( bool  alsoRumble = false)
static

Stops all currently running haptics

Parameters
alsoRumble

◆ StopContinuousHaptic()

static void MoreMountains.NiceVibrations.MMVibrationManager.StopContinuousHaptic ( bool  alsoRumble = false)
static

Stops all running pattern or continuous haptics

◆ TransientHaptic() [1/2]

static void MoreMountains.NiceVibrations.MMVibrationManager.TransientHaptic ( bool  vibrateiOS,
float  iOSIntensity,
float  iOSSharpness,
bool  vibrateAndroid,
float  androidIntensity = 1f,
float  androidSharpness = 1f,
bool  vibrateAndroidIfNoSupport = false,
bool  rumble = true,
float  rumbleLowFrequency = 1f,
float  rumbleHighFrequency = 1f,
int  controllerID = -1,
MonoBehaviour  coroutineSupport = null,
bool  threaded = true 
)
static

Plays a transient haptic, signature with more fine control

Parameters
vibrateiOS
iOSIntensity
iOSSharpness
vibrateAndroid
androidIntensity
androidSharpness
vibrateAndroidIfNoSupport
rumble
rumbleLowFrequency
rumbleHighFrequency
controllerID
coroutineSupport

◆ TransientHaptic() [2/2]

static void MoreMountains.NiceVibrations.MMVibrationManager.TransientHaptic ( float  intensity,
float  sharpness,
bool  alsoRumble = false,
MonoBehaviour  coroutineSupport = null,
int  controllerID = -1 
)
static

Plays a transient haptic, a single, short haptic feedback, of the specified intensity and sharpness

Parameters
intensity
sharpness

◆ UpdateContinuousHaptic() [1/2]

static void MoreMountains.NiceVibrations.MMVibrationManager.UpdateContinuousHaptic ( bool  ios,
float  iosIntensity,
float  iosSharpness,
bool  android,
float  androidIntensity,
float  androidSharpness,
bool  rumble,
float  rumbleLowFrequency,
float  rumbleHighFrequency,
int  controllerID = -1,
bool  threaded = false 
)
static

Updates a continuous haptic while it's playing. Not supported on Android for now, until Google adds API support for that More options signature

Parameters
ios
iosIntensity
iosSharpness
android
androidIntensity
androidSharpness
rumble
rumbleLowFrequency
rumbleHighFrequency
controllerID

◆ UpdateContinuousHaptic() [2/2]

static void MoreMountains.NiceVibrations.MMVibrationManager.UpdateContinuousHaptic ( float  intensity,
float  sharpness,
bool  alsoRumble = false,
int  controllerID = -1,
bool  threaded = false 
)
static

Updates a continuous haptic while it's playing. Not supported on Android for now, until Google adds API support for that

Parameters
intensity
sharpness
alsoRumble

◆ Vibrate()

static void MoreMountains.NiceVibrations.MMVibrationManager.Vibrate ( )
static

Triggers a simple vibration

Member Data Documentation

◆ HeavyAmplitude

int MoreMountains.NiceVibrations.MMVibrationManager.HeavyAmplitude = 255
static

the amplitude of the heavy vibration

◆ HeavyDuration

long MoreMountains.NiceVibrations.MMVibrationManager.HeavyDuration = 80
static

the duration of the heavy vibration (in microseconds)

◆ iOSVersion

float MoreMountains.NiceVibrations.MMVibrationManager.iOSVersion
static

the current iOS version

◆ LightAmplitude

int MoreMountains.NiceVibrations.MMVibrationManager.LightAmplitude = 40
static

the amplitude of the light vibration

◆ LightDuration

long MoreMountains.NiceVibrations.MMVibrationManager.LightDuration = 20
static

the duration of the light vibration (in microseconds)

◆ MediumAmplitude

int MoreMountains.NiceVibrations.MMVibrationManager.MediumAmplitude = 120
static

the amplitude of the medium vibration

◆ MediumDuration

long MoreMountains.NiceVibrations.MMVibrationManager.MediumDuration = 40
static

the duration of the medium vibration (in microseconds)

◆ RigidAmplitude

int MoreMountains.NiceVibrations.MMVibrationManager.RigidAmplitude = 255
static

the amplitude of the rigid vibration

◆ RigidDuration

long MoreMountains.NiceVibrations.MMVibrationManager.RigidDuration = 20
static

the duration of the rigid vibration (in microseconds)

◆ SoftAmplitude

int MoreMountains.NiceVibrations.MMVibrationManager.SoftAmplitude = 40
static

the amplitude of the soft vibration

◆ SoftDuration

long MoreMountains.NiceVibrations.MMVibrationManager.SoftDuration = 80
static

the duration of the soft vibration (in microseconds)


The documentation for this class was generated from the following file: