Insanely huge initial commit

This commit is contained in:
2026-02-21 17:04:05 -08:00
parent 9cdd36191a
commit 613d75914a
22525 changed files with 4035207 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 94bdc8dfc1e5b1745b2e9a81629047f8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0d69e81340dd6ec419cf2600d5fddf0f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e3751a254943c3c408d0ff5a4182a52c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,315 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
//#if MOREMOUNTAINS_NICEVIBRATIONS
//using MoreMountains.NiceVibrations;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this feedback to be able to trigger haptic feedbacks via the NiceVibration library.
/// It'll let you create transient or continuous vibrations, play presets or advanced patterns via AHAP files, and stop any vibration at any time
/// This feedback has been deprecated, and is just here to avoid errors in case you were to update from an old version. Use the new haptic feedbacks instead.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Haptics/Haptics DEPRECATED!")]
[FeedbackHelp("This feedback has been deprecated, and is just here to avoid errors in case you were to update from an old version. Use the new haptic feedbacks instead.")]
public class MMFeedbackHaptics : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
#endif
public enum HapticTypes { Selection, Success, Warning, Failure, LightImpact, MediumImpact, HeavyImpact, RigidImpact, SoftImpact, None }
/// the possible haptic methods for this feedback
public enum HapticMethods { NativePreset, Transient, Continuous, AdvancedPattern, Stop, AdvancedTransient, AdvancedContinuous }
/// the timescale to operate on
public enum Timescales { ScaledTime, UnscaledTime }
// NATIVE PRESET -----------------------------------------------------------------------------------------------------
[Header("Haptics")]
/// the method to use when triggering this haptic feedback
[Tooltip("the method to use when triggering this haptic feedback")]
public HapticMethods HapticMethod = HapticMethods.NativePreset;
/// the type of native preset to use
[Tooltip("the type of native preset to use")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.NativePreset)]
public HapticTypes HapticType = HapticTypes.None;
// TRANSIENT ---------------------------------------------------------------------------------------------------------
/// the intensity of the transient haptic
[Tooltip("the intensity of the transient haptic")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.Transient)]
public float TransientIntensity = 1f;
/// the sharpness of the transient haptic
[Tooltip("the sharpness of the transient haptic")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.Transient)]
public float TransientSharpness = 1f;
// ADV TRANSIENT ---------------------------------------------------------------------------------------------------------
/// whether or not to vibrate on iOS when in AdvancedTransient mode
[Tooltip("whether or not to vibrate on iOS when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public bool ATVibrateIOS = true;
/// the intensity on iOS when in AdvancedTransient mode
[Tooltip("the intensity on iOS when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public float ATIOSIntensity = 1f;
/// the sharpness on iOS when in AdvancedTransient mode
[Tooltip("the sharpness on iOS when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public float ATIOSSharpness = 1f;
/// whether or not to vibrate on android when in AdvancedTransient mode
[Tooltip("whether or not to vibrate on android when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public bool ATVibrateAndroid = true;
/// whether or not to vibrate on android if no support for advanced vibrations when in AdvancedTransient mode
[Tooltip("whether or not to vibrate on android if no support for advanced vibrations when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public bool ATVibrateAndroidIfNoSupport = false;
/// the intensity on android when in AdvancedTransient mode
[Tooltip("the intensity on android when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public float ATAndroidIntensity = 1f;
/// the sharpness on android when in AdvancedTransient mode
[Tooltip("the sharpness on android when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public float ATAndroidSharpness = 1f;
/// whether or not to rumble when in AdvancedTransient mode
[Tooltip("whether or not to rumble when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public bool ATRumble = true;
/// the rumble intensity when in AdvancedTransient mode
[Tooltip("the rumble intensity when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public float ATRumbleIntensity = 1f;
/// the rumble sharpness when in AdvancedTransient mode
[Tooltip("the rumble sharpness when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public float ATRumbleSharpness = 1f;
/// the controllerID when in AdvancedTransient mode
[Tooltip("the controllerID when in AdvancedTransient mode")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedTransient)]
public int ATRumbleControllerID = -1;
// CONTINUOUS ---------------------------------------------------------------------------------------------------------
/// the intensity that should be used to initialize the continuous haptic
[Tooltip("the intensity that should be used to initialize the continuous haptic")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.Continuous)]
public float InitialContinuousIntensity = 1f;
/// the curve used to tween the continuous intensity
[Tooltip("the curve used to tween the continuous intensity")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.Continuous)]
public AnimationCurve ContinuousIntensityCurve = new AnimationCurve(new Keyframe(0, 1), new Keyframe(1f, 1f));
/// the sharpness that should be used to initialize the continuous haptic
[Tooltip("the sharpness that should be used to initialize the continuous haptic")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.Continuous)]
public float InitialContinuousSharpness = 1f;
/// the curve used to tween the continuous sharpness
[Tooltip("the curve used to tween the continuous sharpness")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.Continuous)]
public AnimationCurve ContinuousSharpnessCurve = new AnimationCurve(new Keyframe(0, 1), new Keyframe(1f, 1f));
/// the duration of the continuous haptic
[Tooltip("the duration of the continuous haptic")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.Continuous)]
public float ContinuousDuration = 1f;
// ADV PATTERN ---------------------------------------------------------------------------------------------------------
/// whether or not to trigger advanced patterns on iOS
[Tooltip("whether or not to trigger advanced patterns on iOS")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
public bool APVibrateIOS = true;
/// the AHAP file to use to trigger a pattern on iOS
[Tooltip("the AHAP file to use to trigger a pattern on iOS")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
public TextAsset AHAPFileForIOS;
/// whether or not to trigger advanced patterns on Android
[Tooltip("whether or not to trigger advanced patterns on Android")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
public bool APVibrateAndroid = true;
/// whether or not to vibrate if there's no haptics support
[Tooltip("whether or not to vibrate if there's no haptics support")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
public bool APVibrateAndroidIfNoSupport = false;
/// the WaveFormFile to use to trigger a pattern on Android
//[Tooltip("the WaveFormFile to use to trigger a pattern on Android")]
//[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
//public MMNVAndroidWaveFormAsset AndroidWaveFormFile;
/// whether or not to trigger advanced patterns on rumble
[Tooltip("whether or not to trigger advanced patterns on rumble")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
public bool APRumble = true;
/// the file to use to trigger a rumble on gamepad
//[Tooltip("the file to use to trigger a rumble on gamepad")]
//[MMNVEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
//public MMNVRumbleWaveFormAsset RumbleWaveFormFile;
/// the amount of times this should repeat on Android (-1 : zero, 0 : infinite, 1 : one time, 2 : twice, etc)
[Tooltip("the amount of times this should repeat on Android (-1 : zero, 0 : infinite, 1 : one time, 2 : twice, etc)")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
public int AndroidRepeat = -1;
/// the amount of times this should repeat on gamepad
//[Tooltip("the amount of times this should repeat on gamepad")]
//[MMNVEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
public int RumbleRepeat = -1;
/// a haptic type to play on older iOS APIs (prior to iOS 13)
[Tooltip("a haptic type to play on older iOS APIs (prior to iOS 13)")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
public HapticTypes OldIOSFallback;
/// whether to run this on scaled or unscaled time
[Tooltip("whether to run this on scaled or unscaled time")]
[MMFEnumCondition("HapticMethod", (int)HapticMethods.AdvancedPattern)]
public Timescales Timescale = Timescales.UnscaledTime;
// RUMBLE -------------------------------------------------------------------------------------------------------------
[Header("Rumble")]
/// whether or not this feedback should trigger a rumble on gamepad
[Tooltip("whether or not this feedback should trigger a rumble on gamepad")]
public bool AllowRumble = true;
/// the ID of the controller to rumble (-1 : auto/current, 0 : first controller, 1 : second controller, etc)
[Tooltip("the ID of the controller to rumble (-1 : auto/current, 0 : first controller, 1 : second controller, etc)")]
public int ControllerID = -1;
[Header("Deprecated Feedback")]
/// if this is true, this feedback will output a warning when played
public bool OutputDeprecationWarning = true;
protected static bool _continuousPlaying = false;
protected static float _continuousStartedAt = 0f;
/// <summary>
/// When this feedback gets played
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
if (OutputDeprecationWarning)
{
Debug.LogWarning(this.name + " : the haptic feedback on this object is using the old version of Nice Vibrations, and won't work anymore. Replace it with any of the new haptic feedbacks.");
}
/*switch (HapticMethod)
{
case HapticMethods.AdvancedPattern:
string iOSString = (AHAPFileForIOS == null) ? "" : AHAPFileForIOS.text;
long[] androidPattern = (AndroidWaveFormFile == null) ? null : AndroidWaveFormFile.WaveForm.Pattern;
int[] androidAmplitude = (AndroidWaveFormFile == null) ? null : AndroidWaveFormFile.WaveForm.Amplitudes;
long[] rumblePattern = (RumbleWaveFormFile == null) ? null : RumbleWaveFormFile.WaveForm.Pattern;
int[] lowFreqAmplitude = (RumbleWaveFormFile == null) ? null : RumbleWaveFormFile.WaveForm.LowFrequencyAmplitudes;
int[] highFreqAmplitude = (RumbleWaveFormFile == null) ? null : RumbleWaveFormFile.WaveForm.HighFrequencyAmplitudes;
MMVibrationManager.AdvancedHapticPattern(APVibrateIOS, iOSString, APVibrateAndroid, androidPattern, androidAmplitude,
AndroidRepeat, APVibrateAndroidIfNoSupport, APRumble,
rumblePattern, lowFreqAmplitude, highFreqAmplitude, RumbleRepeat,
OldIOSFallback, this, ControllerID);
break;
case HapticMethods.Continuous:
StartCoroutine(ContinuousHapticsCoroutine());
break;
case HapticMethods.NativePreset:
MMVibrationManager.Haptic(HapticType, false, AllowRumble, this, ControllerID);
break;
case HapticMethods.Transient:
MMVibrationManager.TransientHaptic(TransientIntensity, TransientSharpness, AllowRumble, this, ControllerID);
break;
case HapticMethods.AdvancedTransient:
MMVibrationManager.TransientHaptic(ATVibrateIOS, ATIOSIntensity, ATIOSSharpness, ATVibrateAndroid,
ATAndroidIntensity, ATAndroidSharpness, ATVibrateAndroidIfNoSupport, ATRumble,
ATRumbleIntensity, ATRumbleSharpness, ATRumbleControllerID, this);
break;
case HapticMethods.AdvancedContinuous:
break;
case HapticMethods.Stop:
if (_continuousPlaying)
{
MMVibrationManager.StopContinuousHaptic(AllowRumble);
_continuousPlaying = false;
}
break;
}*/
}
/// <summary>
/// A coroutine used to update continuous haptics as they're playing
/// </summary>
/// <returns></returns>
/*protected virtual IEnumerator ContinuousHapticsCoroutine()
{
_continuousStartedAt = (Timescale == Timescales.ScaledTime) ? Time.time : Time.unscaledTime;
_continuousPlaying = true;
float elapsedTime = ComputeElapsedTime();
MMVibrationManager.ContinuousHaptic(InitialContinuousIntensity, InitialContinuousSharpness, ContinuousDuration, HapticTypes.Success, this);
while (_continuousPlaying && (elapsedTime < ContinuousDuration))
{
elapsedTime = ComputeElapsedTime();
float remappedTime = Remap(elapsedTime, 0f, ContinuousDuration, 0f, 1f);
float intensity = ContinuousIntensityCurve.Evaluate(remappedTime);
float sharpness = ContinuousSharpnessCurve.Evaluate(remappedTime);
MMVibrationManager.UpdateContinuousHaptic(intensity, sharpness, true);
if (AllowRumble)
{
#if MOREMOUNTAINS_NICEVIBRATIONS_RUMBLE
MMNVRumble.RumbleContinuous(intensity, sharpness, ControllerID);
#endif
}
yield return null;
}
if (_continuousPlaying)
{
_continuousPlaying = false;
MMVibrationManager.StopContinuousHaptic(AllowRumble);
}
}*/
/// <summary>
/// This methods computes and returns the elapsed time since the start of the last played continuous haptic
/// </summary>
/// <returns></returns>
/*protected virtual float ComputeElapsedTime()
{
float elapsedTime = (Timescale == Timescales.ScaledTime) ? Time.time - _continuousStartedAt : Time.unscaledTime - _continuousStartedAt;
return elapsedTime;
}*/
/// <summary>
/// Remaps value x from AB to CD
/// </summary>
/// <param name="x"></param>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
/// <param name="D"></param>
/// <returns></returns>
/*public static float Remap(float x, float A, float B, float C, float D)
{
float remappedValue = C + (x - A) / (B - A) * (D - C);
return remappedValue;
}*/
}
}
//#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5f1326a5f4dbb874f9c42effa0befa36
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,107 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this feedback to play a .haptic clip, optionally randomizing its level and frequency
/// </summary>
[AddComponentMenu("")]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Clip")]
#endif
[FeedbackHelp("This feedback will let you play a haptic clip, and randomize its level and frequency.")]
public class MMFeedbackNVClip : MMFeedback
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
#endif
[Header("Haptic Clip")]
/// the haptic clip to play with this feedback
[Tooltip("the haptic clip to play with this feedback")]
public HapticClip Clip;
/// a preset to play should the device you're running your game on doesn't support playing haptic clips
[Tooltip("a preset to play should the device you're running your game on doesn't support playing haptic clips")]
public HapticPatterns.PresetType FallbackPreset = HapticPatterns.PresetType.LightImpact;
/// whether or not this clip should play on a loop, until stopped (won't work on gamepads)
[Tooltip("whether or not this clip should play on a loop, until stopped (won't work on gamepads)")]
public bool Loop = false;
/// at what timestamp this clip should start playing
[Tooltip("at what timestamp this clip should start playing")]
public float SeekTime = 0f;
[Header("Level")]
/// the minimum level at which this clip should play (level will be randomized between MinLevel and MaxLevel)
[Tooltip("the minimum level at which this clip should play (level will be randomized between MinLevel and MaxLevel)")]
[Range(0f, 5f)]
public float MinLevel = 1f;
/// the maximum level at which this clip should play (level will be randomized between MinLevel and MaxLevel)
[Tooltip("the maximum level at which this clip should play (level will be randomized between MinLevel and MaxLevel)")]
[Range(0f, 5f)]
public float MaxLevel = 1f;
[Header("Frequency Shift")]
/// the minimum frequency shift at which this clip should play (frequency shift will be randomized between MinFrequencyShift and MaxLevel)
[Tooltip("the minimum frequency shift at which this clip should play (frequency shift will be randomized between MinFrequencyShift and MaxFrequencyShift)")]
[Range(-1f, 1f)]
public float MinFrequencyShift = 0f;
/// the maximum frequency shift at which this clip should play (frequency shift will be randomized between MinFrequencyShift and MaxLevel)
[Tooltip("the maximum frequency shift at which this clip should play (frequency shift will be randomized between MinFrequencyShift and MaxFrequencyShift)")]
[Range(-1f, 1f)]
public float MaxFrequencyShift = 0f;
[Header("Settings")]
/// a set of settings you can tweak to specify how and when exactly this haptic should play
[Tooltip("a set of settings you can tweak to specify how and when exactly this haptic should play")]
public MMFeedbackNVSettings HapticSettings;
/// <summary>
/// On play, we load our clip, set its settings and play it
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay() || (Clip == null))
{
return;
}
HapticController.Load(Clip);
HapticSettings.SetGamepad();
HapticController.fallbackPreset = FallbackPreset;
HapticController.Loop(Loop);
HapticController.Seek(SeekTime);
HapticController.clipLevel = Random.Range(MinLevel, MaxLevel);
HapticController.clipFrequencyShift = Random.Range(MinFrequencyShift, MaxFrequencyShift);
HapticController.Play();
}
/// <summary>
/// On stop we stop haptics
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
IsPlaying = false;
HapticController.Stop();
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1c751ed8d705d7848858f5b650bca7cb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,153 @@
using UnityEngine;
using System.Collections;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this feedback to play a continuous haptic of the specified amplitude and frequency over a certain duration. This feedback will also let you randomize these, and modulate them over time.
/// </summary>
[AddComponentMenu("")]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Continuous")]
#endif
[FeedbackHelp("Add this feedback to play a continuous haptic of the specified amplitude and frequency over a certain duration. This feedback will also let you randomize these, and modulate them over time.")]
public class MMFeedbackNVContinuous : MMFeedback
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
#endif
public override float FeedbackDuration { get { return ApplyTimeMultiplier(_duration); } set { _duration = value; } }
[Header("Haptic Amplitude")]
/// the minimum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)
[Tooltip("the minimum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)")]
[Range(0f, 1f)]
public float MinAmplitude = 1f;
/// the maximum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)
[Tooltip("the maximum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)")]
[Range(0f, 1f)]
public float MaxAmplitude = 1f;
[Header("Haptic Frequency")]
/// the minimum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)
[Tooltip("the minimum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)")]
[Range(0f, 1f)]
public float MinFrequency = 1f;
/// the maximum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)
[Tooltip("the maximum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)")]
[Range(0f, 1f)]
public float MaxFrequency = 1f;
[Header("Duration")]
/// the minimum duration at which this clip should play (duration will be randomized between MinDuration and MaxDuration)
[Tooltip("the minimum duration at which this clip should play (duration will be randomized between MinDuration and MaxDuration)")]
public float MinDuration = 1f;
/// the maximum duration at which this clip should play (duration will be randomized between MinDuration and MaxDuration)
[Tooltip("the maximum duration at which this clip should play (duration will be randomized between MinDuration and MaxDuration)")]
public float MaxDuration = 1f;
[Header("Real-time Modulation")]
/// whether or not to modulate the haptic signal at runtime
[Tooltip("whether or not to modulate the haptic signal at runtime")]
public bool UseRealTimeModulation = false;
/// if UseRealTimeModulation:true, the curve along which to modulate amplitude for this continuous haptic, over its total duration
[Tooltip("if UseRealTimeModulation:true, the curve along which to modulate amplitude for this continuous haptic, over its total duration")]
[MMFCondition("UseRealTimeModulation", true)]
public AnimationCurve AmplitudeMultiplication = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1f), new Keyframe(1, 0f));
/// if UseRealTimeModulation:true, the curve along which to modulate frequency for this continuous haptic, over its total duration
[Tooltip("if UseRealTimeModulation:true, the curve along which to modulate frequency for this continuous haptic, over its total duration")]
[MMFCondition("UseRealTimeModulation", true)]
public AnimationCurve ShiftFrequency = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1f), new Keyframe(1, 0f));
[Header("Settings")]
/// a set of settings you can tweak to specify how and when exactly this haptic should play
[Tooltip("a set of settings you can tweak to specify how and when exactly this haptic should play")]
public MMFeedbackNVSettings HapticSettings;
protected Coroutine _coroutine;
protected float _duration = 0f;
/// <summary>
/// On play we randomize our amplitude and frequency, trigger our haptic, and initialize real time modulation if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay())
{
return;
}
float amplitude = Random.Range(MinAmplitude, MaxAmplitude);
float frequency = Random.Range(MinFrequency, MaxFrequency);
_duration = Random.Range(MinDuration, MaxDuration);
HapticSettings.SetGamepad();
HapticPatterns.PlayConstant(amplitude, frequency, FeedbackDuration);
if (UseRealTimeModulation)
{
_coroutine = StartCoroutine(RealtimeModulationCo());
}
}
/// <summary>
/// A coroutine used to modulate frequency and amplitude at runtime
/// </summary>
/// <returns></returns>
protected virtual IEnumerator RealtimeModulationCo()
{
IsPlaying = true;
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
{
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
HapticController.clipLevel = AmplitudeMultiplication.Evaluate(remappedTime);
HapticController.clipFrequencyShift = ShiftFrequency.Evaluate(remappedTime);
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
yield return null;
}
HapticController.clipLevel = AmplitudeMultiplication.Evaluate(FinalNormalizedTime);
HapticController.clipFrequencyShift = ShiftFrequency.Evaluate(FinalNormalizedTime);
IsPlaying = false;
_coroutine = null;
yield return null;
}
/// <summary>
/// On stop we stop haptics and our coroutine
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
IsPlaying = false;
HapticController.Stop();
if (Active && (_coroutine != null))
{
StopCoroutine(_coroutine);
_coroutine = null;
}
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bc46122b60040b643a6bace1e13fe12f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this feedback to interact with haptics at a global level, stopping them all, enabling or disabling them, adjusting their global level or initializing/release the haptic engine
/// </summary>
[AddComponentMenu("")]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Control")]
#endif
[FeedbackHelp("Add this feedback to interact with haptics at a global level, stopping them all, enabling or disabling them, adjusting their global level or initializing/release the haptic engine.")]
public class MMFeedbackNVControl : MMFeedback
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
#endif
public enum ControlTypes { Stop, EnableHaptics, DisableHaptics, AdjustHapticsLevel, Initialize, Release }
[Header("Haptic Control")]
/// the type of control order to trigger when playing this feedback - check Nice Vibrations' documentation for the exact behaviour of these
[Tooltip("the type of control order to trigger when playing this feedback - check Nice Vibrations' documentation for the exact behaviour of these")]
public ControlTypes ControlType = ControlTypes.Stop;
/// the output level when in AdjustHapticsLevel mode
[Tooltip("the output level when in AdjustHapticsLevel mode")]
[MMFEnumCondition("ControlType", (int)ControlTypes.AdjustHapticsLevel)]
public float OutputLevel = 1f;
/// <summary>
/// On play we apply the specified order
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (ControlType)
{
case ControlTypes.Stop:
HapticController.Stop();
break;
case ControlTypes.EnableHaptics:
HapticController.hapticsEnabled = true;
break;
case ControlTypes.DisableHaptics:
HapticController.hapticsEnabled = false;
break;
case ControlTypes.AdjustHapticsLevel:
HapticController.outputLevel = OutputLevel;
break;
case ControlTypes.Initialize:
LofeltHaptics.Initialize();
HapticController.Init();
break;
case ControlTypes.Release:
LofeltHaptics.Release();
break;
}
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c231819339fb23c45895c315b619bb8d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Use this feedback to play an Emphasis haptics, short haptic bursts whose amplitude and frequency can be controlled in real time, also called Transients in CoreHaptics/iOS
/// </summary>
[AddComponentMenu("")]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Emphasis")]
#endif
[FeedbackHelp("Use this feedback to play an Emphasis haptics, short haptic bursts whose amplitude and frequency can be controlled in real time, also called Transients in CoreHaptics/iOS")]
public class MMFeedbackNVEmphasis : MMFeedback
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
#endif
[Header("Haptic Amplitude")]
/// the minimum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)
[Tooltip("the minimum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)")]
[Range(0f, 1f)]
public float MinAmplitude = 1f;
/// the maximum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)
[Tooltip("the maximum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)")]
[Range(0f, 1f)]
public float MaxAmplitude = 1f;
[Header("Haptic Frequency")]
/// the minimum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)
[Tooltip("the minimum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)")]
[Range(0f, 1f)]
public float MinFrequency = 1f;
/// the maximum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)
[Tooltip("the maximum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)")]
[Range(0f, 1f)]
public float MaxFrequency = 1f;
[Header("Settings")]
/// a set of settings you can tweak to specify how and when exactly this haptic should play
[Tooltip("a set of settings you can tweak to specify how and when exactly this haptic should play")]
public MMFeedbackNVSettings HapticSettings;
/// <summary>
/// On play, we randomize our amplitude and frequency and play our emphasis haptic
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay())
{
return;
}
float amplitude = Random.Range(MinAmplitude, MaxAmplitude);
float frequency = Random.Range(MinFrequency, MaxFrequency);
HapticSettings.SetGamepad();
HapticPatterns.PlayEmphasis(amplitude, frequency);
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fdb418cd35b9814489a6a893a3eeaad8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Use this feedback to play a preset haptic, limited but super simple predifined haptic patterns
/// </summary>
[AddComponentMenu("")]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Preset")]
#endif
[FeedbackHelp("Use this feedback to play a preset haptic, limited but super simple predifined haptic patterns")]
public class MMFeedbackNVPreset : MMFeedback
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
#endif
[Header("Haptic Preset")]
/// the preset to play with this feedback
[Tooltip("the preset to play with this feedback")]
public HapticPatterns.PresetType Preset = HapticPatterns.PresetType.LightImpact;
[Header("Settings")]
/// a set of settings you can tweak to specify how and when exactly this haptic should play
[Tooltip("a set of settings you can tweak to specify how and when exactly this haptic should play")]
public MMFeedbackNVSettings HapticSettings;
/// <summary>
/// On play we play our preset haptic
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay())
{
return;
}
HapticSettings.SetGamepad();
HapticPatterns.PlayPreset(Preset);
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 69e14417fec82fd45a6ccb78d3868d40
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
using UnityEngine;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// A class used to store and manage common Nice Vibrations feedback settings
/// </summary>
[System.Serializable]
public class MMFeedbackNVSettings
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// whether or not to force this haptic to play on a specific gamepad
[Tooltip("whether or not to force this haptic to play on a specific gamepad")]
public bool ForceGamepadID = false;
/// The ID of the gamepad on which to play this haptic
[Tooltip("The ID of the gamepad on which to play this haptic")]
public int GamepadID = 0;
/// whether or not this haptic should play only if haptics are supported
[Tooltip("whether or not this haptic should play only if haptics are supported")]
public bool OnlyPlayIfHapticsSupported = true;
/// whether or not this haptic should play only if advanced haptics requirements are met on the device
[Tooltip("whether or not this haptic should play only if advanced haptics requirements are met on the device")]
public bool OnlyPlayIfAdvancedRequirementsMet = false;
/// whether or not this haptic should play only if the device supports amplitude modulation
[Tooltip("whether or not this haptic should play only if the device supports amplitude modulation")]
public bool OnlyPlayIfAmplitudeModulationSupported = false;
/// whether or not this haptic should play only if the device supports frequency modulation
[Tooltip("whether or not this haptic should play only if the device supports frequency modulation")]
public bool OnlyPlayIfFrequencyModulationSupported = false;
/// <summary>
/// If necessary, forces the current haptic to play on a specific gamepad
/// </summary>
public virtual void SetGamepad()
{
if (ForceGamepadID)
{
GamepadRumbler.SetCurrentGamepad(GamepadID);
}
}
/// <summary>
/// Whether or not this haptic can play based on the specified conditions
/// </summary>
/// <returns></returns>
public virtual bool CanPlay()
{
#if UNITY_IOS || UNITY_ANDROID
if (OnlyPlayIfHapticsSupported && !DeviceCapabilities.isVersionSupported)
{
return false;
}
#endif
if (OnlyPlayIfAdvancedRequirementsMet && !DeviceCapabilities.meetsAdvancedRequirements)
{
return false;
}
if (OnlyPlayIfAmplitudeModulationSupported && !DeviceCapabilities.hasAmplitudeModulation)
{
return false;
}
if (OnlyPlayIfFrequencyModulationSupported && !DeviceCapabilities.hasFrequencyModulation)
{
return false;
}
return true;
}
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3abc70b7028a09449b0976268deba80b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this feedback to be able to trigger haptic feedbacks via the NiceVibration library.
/// It'll let you create transient or continuous vibrations, play presets or advanced patterns via AHAP files, and stop any vibration at any time
/// This feedback has been deprecated, and is just here to avoid errors in case you were to update from an old version. Use the new haptic feedbacks instead.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Haptics/Haptics DEPRECATED!")]
[FeedbackHelp("This feedback has been deprecated, and is just here to avoid errors in case you were to update from an old version. Use any of the new haptic feedbacks instead.")]
public class MMF_Haptics : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
[Header("Deprecated Feedback")]
/// if this is true, this feedback will output a warning when played
public bool OutputDeprecationWarning = true;
/// <summary>
/// When this feedback gets played
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
if (OutputDeprecationWarning)
{
Debug.LogWarning(Owner.name + " : the haptic feedback on this object is using the old version of Nice Vibrations, and won't work anymore. Replace it with any of the new haptic feedbacks.");
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dd8d60a3aa719934084bb1539d7e4ef3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,110 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this feedback to play a .haptic clip, optionally randomizing its level and frequency
/// </summary>
[AddComponentMenu("")]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Clip")]
#endif
[FeedbackHelp("This feedback will let you play a haptic clip, and randomize its level and frequency.")]
public class MMF_NVClip : MMF_Feedback
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
public override bool EvaluateRequiresSetup() { return (Clip == null); }
public override string RequiredTargetText { get { return Clip != null ? Clip.name : ""; } }
public override string RequiresSetupText { get { return "This feedback requires that a Clip be set to be able to work properly. You can set one below."; } }
#endif
[MMFInspectorGroup("Haptic Clip", true, 13, true)]
/// the haptic clip to play with this feedback
[Tooltip("the haptic clip to play with this feedback")]
public HapticClip Clip;
/// a preset to play should the device you're running your game on doesn't support playing haptic clips
[Tooltip("a preset to play should the device you're running your game on doesn't support playing haptic clips")]
public HapticPatterns.PresetType FallbackPreset = HapticPatterns.PresetType.LightImpact;
/// whether or not this clip should play on a loop, until stopped (won't work on gamepads)
[Tooltip("whether or not this clip should play on a loop, until stopped (won't work on gamepads)")]
public bool Loop = false;
/// at what timestamp this clip should start playing
[Tooltip("at what timestamp this clip should start playing")]
public float SeekTime = 0f;
[MMFInspectorGroup("Level", true, 14)]
/// the minimum level at which this clip should play (level will be randomized between MinLevel and MaxLevel)
[Tooltip("the minimum level at which this clip should play (level will be randomized between MinLevel and MaxLevel)")]
[Range(0f, 5f)]
public float MinLevel = 1f;
/// the maximum level at which this clip should play (level will be randomized between MinLevel and MaxLevel)
[Tooltip("the maximum level at which this clip should play (level will be randomized between MinLevel and MaxLevel)")]
[Range(0f, 5f)]
public float MaxLevel = 1f;
[MMFInspectorGroup("Frequency Shift", true, 15)]
/// the minimum frequency shift at which this clip should play (frequency shift will be randomized between MinFrequencyShift and MaxLevel)
[Tooltip("the minimum frequency shift at which this clip should play (frequency shift will be randomized between MinFrequencyShift and MaxFrequencyShift)")]
[Range(-1f, 1f)]
public float MinFrequencyShift = 0f;
/// the maximum frequency shift at which this clip should play (frequency shift will be randomized between MinFrequencyShift and MaxLevel)
[Tooltip("the maximum frequency shift at which this clip should play (frequency shift will be randomized between MinFrequencyShift and MaxFrequencyShift)")]
[Range(-1f, 1f)]
public float MaxFrequencyShift = 0f;
[MMFInspectorGroup("Settings", true, 16)]
/// a set of settings you can tweak to specify how and when exactly this haptic should play
[Tooltip("a set of settings you can tweak to specify how and when exactly this haptic should play")]
public MMFeedbackNVSettings HapticSettings;
/// <summary>
/// On play, we load our clip, set its settings and play it
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay() || (Clip == null))
{
return;
}
HapticController.Load(Clip);
HapticSettings.SetGamepad();
HapticController.fallbackPreset = FallbackPreset;
HapticController.Loop(Loop);
HapticController.Seek(SeekTime);
HapticController.clipLevel = Random.Range(MinLevel, MaxLevel);
HapticController.clipFrequencyShift = Random.Range(MinFrequencyShift, MaxFrequencyShift);
HapticController.Play();
}
/// <summary>
/// On stop we stop haptics
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
IsPlaying = false;
HapticController.Stop();
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7a7b40b69918c9840b090deb2a59d5eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,152 @@
using UnityEngine;
using System.Collections;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this feedback to play a continuous haptic of the specified amplitude and frequency over a certain duration. This feedback will also let you randomize these, and modulate them over time.
/// </summary>
[AddComponentMenu("")]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Continuous")]
#endif
[FeedbackHelp("Add this feedback to play a continuous haptic of the specified amplitude and frequency over a certain duration. This feedback will also let you randomize these, and modulate them over time.")]
public class MMF_NVContinuous : MMF_Feedback
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
#endif
public override float FeedbackDuration { get { return ApplyTimeMultiplier(_duration); } set { _duration = value; } }
[MMFInspectorGroup("Haptic Amplitude", true, 31)]
/// the minimum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)
[Tooltip("the minimum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)")]
[Range(0f, 1f)]
public float MinAmplitude = 1f;
/// the maximum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)
[Tooltip("the maximum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)")]
[Range(0f, 1f)]
public float MaxAmplitude = 1f;
[MMFInspectorGroup("Haptic Frequency", true, 32)]
/// the minimum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)
[Tooltip("the minimum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)")]
[Range(0f, 1f)]
public float MinFrequency = 1f;
/// the maximum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)
[Tooltip("the maximum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)")]
[Range(0f, 1f)]
public float MaxFrequency = 1f;
[MMFInspectorGroup("Duration", true, 33)]
/// the minimum duration at which this clip should play (duration will be randomized between MinDuration and MaxDuration)
[Tooltip("the minimum duration at which this clip should play (duration will be randomized between MinDuration and MaxDuration)")]
public float MinDuration = 1f;
/// the maximum duration at which this clip should play (duration will be randomized between MinDuration and MaxDuration)
[Tooltip("the maximum duration at which this clip should play (duration will be randomized between MinDuration and MaxDuration)")]
public float MaxDuration = 1f;
[MMFInspectorGroup("Real-time Modulation", true, 34)]
/// whether or not to modulate the haptic signal at runtime
[Tooltip("whether or not to modulate the haptic signal at runtime")]
public bool UseRealTimeModulation = false;
/// if UseRealTimeModulation:true, the curve along which to modulate amplitude for this continuous haptic, over its total duration
[Tooltip("if UseRealTimeModulation:true, the curve along which to modulate amplitude for this continuous haptic, over its total duration")]
[MMFCondition("UseRealTimeModulation", true)]
public AnimationCurve AmplitudeMultiplication = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1f), new Keyframe(1, 0f));
/// if UseRealTimeModulation:true, the curve along which to modulate frequency for this continuous haptic, over its total duration
[Tooltip("if UseRealTimeModulation:true, the curve along which to modulate frequency for this continuous haptic, over its total duration")]
[MMFCondition("UseRealTimeModulation", true)]
public AnimationCurve ShiftFrequency = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1f), new Keyframe(1, 0f));
[MMFInspectorGroup("Settings", true, 16)]
/// a set of settings you can tweak to specify how and when exactly this haptic should play
[Tooltip("a set of settings you can tweak to specify how and when exactly this haptic should play")]
public MMFeedbackNVSettings HapticSettings;
protected Coroutine _coroutine;
protected float _duration = 0f;
/// <summary>
/// On play we randomize our amplitude and frequency, trigger our haptic, and initialize real time modulation if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay())
{
return;
}
float amplitude = Random.Range(MinAmplitude, MaxAmplitude);
float frequency = Random.Range(MinFrequency, MaxFrequency);
_duration = Random.Range(MinDuration, MaxDuration);
HapticSettings.SetGamepad();
HapticPatterns.PlayConstant(amplitude, frequency, FeedbackDuration);
if (UseRealTimeModulation)
{
_coroutine = Owner.StartCoroutine(RealtimeModulationCo());
}
}
/// <summary>
/// A coroutine used to modulate frequency and amplitude at runtime
/// </summary>
/// <returns></returns>
protected virtual IEnumerator RealtimeModulationCo()
{
IsPlaying = true;
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
{
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
HapticController.clipLevel = AmplitudeMultiplication.Evaluate(remappedTime);
HapticController.clipFrequencyShift = ShiftFrequency.Evaluate(remappedTime);
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
yield return null;
}
HapticController.clipLevel = AmplitudeMultiplication.Evaluate(FinalNormalizedTime);
HapticController.clipFrequencyShift = ShiftFrequency.Evaluate(FinalNormalizedTime);
IsPlaying = false;
_coroutine = null;
yield return null;
}
/// <summary>
/// On stop we stop haptics and our coroutine
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
IsPlaying = false;
HapticController.Stop();
if (Active && (_coroutine != null))
{
Owner.StopCoroutine(_coroutine);
_coroutine = null;
}
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 67fc7d627b6e1074895b5ed483eb737d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this feedback to interact with haptics at a global level, stopping them all, enabling or disabling them, adjusting their global level or initializing/release the haptic engine
/// </summary>
[AddComponentMenu("")]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Control")]
#endif
[FeedbackHelp("Add this feedback to interact with haptics at a global level, stopping them all, enabling or disabling them, adjusting their global level or initializing/release the haptic engine.")]
public class MMF_NVControl : MMF_Feedback
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
public override string RequiredTargetText { get { return ControlType.ToString(); } }
#endif
public enum ControlTypes { Stop, EnableHaptics, DisableHaptics, AdjustHapticsLevel, Initialize, Release }
[MMFInspectorGroup("Haptic Control", true, 24)]
/// the type of control order to trigger when playing this feedback - check Nice Vibrations' documentation for the exact behaviour of these
[Tooltip("the type of control order to trigger when playing this feedback - check Nice Vibrations' documentation for the exact behaviour of these")]
public ControlTypes ControlType = ControlTypes.Stop;
/// the output level when in AdjustHapticsLevel mode
[Tooltip("the output level when in AdjustHapticsLevel mode")]
[MMFEnumCondition("ControlType", (int)ControlTypes.AdjustHapticsLevel)]
public float OutputLevel = 1f;
/// <summary>
/// On play we apply the specified order
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (ControlType)
{
case ControlTypes.Stop:
HapticController.Stop();
break;
case ControlTypes.EnableHaptics:
HapticController.hapticsEnabled = true;
break;
case ControlTypes.DisableHaptics:
HapticController.hapticsEnabled = false;
break;
case ControlTypes.AdjustHapticsLevel:
HapticController.outputLevel = OutputLevel;
break;
case ControlTypes.Initialize:
LofeltHaptics.Initialize();
HapticController.Init();
break;
case ControlTypes.Release:
LofeltHaptics.Release();
break;
}
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6a3a1491160f1b944b35c4ba60eaedb2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Use this feedback to play an Emphasis haptics, short haptic bursts whose amplitude and frequency can be controlled in real time, also called Transients in CoreHaptics/iOS
/// </summary>
[AddComponentMenu("")]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Emphasis")]
#endif
[FeedbackHelp("Use this feedback to play an Emphasis haptics, short haptic bursts whose amplitude and frequency can be controlled in real time, also called Transients in CoreHaptics/iOS")]
public class MMF_NVEmphasis : MMF_Feedback
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
#endif
[MMFInspectorGroup("Haptic Amplitude", true, 23)]
/// the minimum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)
[Tooltip("the minimum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)")]
[Range(0f, 1f)]
public float MinAmplitude = 1f;
/// the maximum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)
[Tooltip("the maximum amplitude at which this clip should play (amplitude will be randomized between MinAmplitude and MaxAmplitude)")]
[Range(0f, 1f)]
public float MaxAmplitude = 1f;
[MMFInspectorGroup("Haptic Frequency", true, 22)]
/// the minimum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)
[Tooltip("the minimum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)")]
[Range(0f, 1f)]
public float MinFrequency = 1f;
/// the maximum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)
[Tooltip("the maximum frequency at which this clip should play (frequency will be randomized between MinFrequency and MaxFrequency)")]
[Range(0f, 1f)]
public float MaxFrequency = 1f;
[MMFInspectorGroup("Settings", true, 16)]
/// a set of settings you can tweak to specify how and when exactly this haptic should play
[Tooltip("a set of settings you can tweak to specify how and when exactly this haptic should play")]
public MMFeedbackNVSettings HapticSettings;
/// <summary>
/// On play, we randomize our amplitude and frequency and play our emphasis haptic
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay())
{
return;
}
float amplitude = Random.Range(MinAmplitude, MaxAmplitude);
float frequency = Random.Range(MinFrequency, MaxFrequency);
HapticSettings.SetGamepad();
HapticPatterns.PlayEmphasis(amplitude, frequency);
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 72f4893994302d847bdb90bf4feead48
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,56 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Use this feedback to play a preset haptic, limited but super simple predifined haptic patterns
/// </summary>
[AddComponentMenu("")]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Preset")]
#endif
[FeedbackHelp("Use this feedback to play a preset haptic, limited but super simple predifined haptic patterns")]
public class MMF_NVPreset : MMF_Feedback
{
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.HapticsColor; } }
public override string RequiredTargetText { get { return Preset.ToString(); } }
#endif
[MMFInspectorGroup("Haptic Preset", true, 21)]
/// the preset to play with this feedback
[Tooltip("the preset to play with this feedback")]
public HapticPatterns.PresetType Preset = HapticPatterns.PresetType.LightImpact;
[MMFInspectorGroup("Settings", true, 16)]
/// a set of settings you can tweak to specify how and when exactly this haptic should play
[Tooltip("a set of settings you can tweak to specify how and when exactly this haptic should play")]
public MMFeedbackNVSettings HapticSettings;
/// <summary>
/// On play we play our preset haptic
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || !HapticSettings.CanPlay())
{
return;
}
HapticSettings.SetGamepad();
HapticPatterns.PlayPreset(Preset);
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ccb12f2582242744685c2cb083debab8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
{
"name": "MoreMountains.Feedbacks.NiceVibrations",
"references": [
"GUID:57a0b9bc628ab4740af4b6f1f0b2e134",
"GUID:8087d854c1f812e4b9a74437dfc524e0"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b7361f52a93c32c48a670c64f5ae2ab6
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: