public void OnVibrateCancel() { if (!AGVibrator.HasVibrator()) { Debug.LogWarning("This device does not have vibrator"); } //Cancels the current vibration pattern AGVibrator.Cancel(); }
public void OnVibrate() { if (!AGVibrator.HasVibrator()) { Debug.LogWarning("This device does not have vibrator"); } AGVibrator.Cancel(); AGVibrator.Vibrate(500); }
public void OnVibratePattern() { if (!AGVibrator.HasVibrator()) { Debug.LogWarning("This device does not have vibrator"); } // Start without a delay // Each element then alternates between vibrate, sleep, vibrate, sleep... long[] pattern = { 0, 100, 1000, 300, 200, 100, 500, 200, 100 }; AGVibrator.Cancel(); AGVibrator.VibratePattern(pattern); }
public void OnVibrateOneSHot() { if (!AGVibrator.HasVibrator()) { Debug.LogWarning("This device does not have vibrator"); } if (!AGVibrator.AreVibrationEffectsSupported) { Debug.LogWarning("This device does not support vibration effects API!"); return; } AGVibrator.Cancel(); //Create a one shot vibration for 1000 ms at default amplitude AGVibrator.Vibrate(VibrationEffect.CreateOneShot(1000, VibrationEffect.DEFAULT_AMPLITUDE)); }
public void OnVibrateWaveForm2() { if (!AGVibrator.HasVibrator()) { Debug.LogWarning("This device does not have vibrator"); } if (!AGVibrator.AreVibrationEffectsSupported) { Debug.LogWarning("This device does not support vibration effects API!"); return; } long[] mVibratePattern = { 0, 400, 1000, 600, 1000, 800, 1000, 1000 }; int[] mAmplitudes = { 0, 255, 0, 255, 0, 255, 0, 255 }; //Create a waveform vibration with different vibration amplitudes AGVibrator.Cancel(); AGVibrator.Vibrate(VibrationEffect.CreateWaveForm(mVibratePattern, mAmplitudes, 0)); }
public void OnVibrateWaveForm1() { if (!AGVibrator.HasVibrator()) { Debug.LogWarning("This device does not have vibrator"); } if (!AGVibrator.AreVibrationEffectsSupported) { Debug.LogWarning("This device does not support vibration effects API!"); return; } // Start without a delay // Each element then alternates between vibrate, sleep, vibrate, sleep... long[] mVibratePattern = { 0, 400, 1000, 600, 1000, 800, 1000, 1000 }; AGVibrator.Cancel(); //Create a waveform vibration. AGVibrator.Vibrate(VibrationEffect.CreateWaveForm(mVibratePattern, -1)); }
public void OnVibrateWithAudioAttributes() { if (!AGVibrator.HasVibrator()) { Debug.LogWarning("This device does not have vibrator"); } if (!AGVibrator.AreVibrationEffectsSupported) { Debug.LogWarning("This device does not support vibration effects API!"); return; } AGVibrator.Cancel(); //Creating new audio attributes with custom parameters var audioAttributes = new AudioAttributes.Builder() .SetContentType(AudioAttributes.ContentType.Music) .SetFlags(AudioAttributes.Flags.FlagAll) .SetUsage(AudioAttributes.Usage.Alarm) .Build(); //Create a one shot vibration for 1000 ms at default amplitude with audio attributes AGVibrator.Vibrate(VibrationEffect.CreateOneShot(800, VibrationEffect.DEFAULT_AMPLITUDE), audioAttributes); }