Added Feel plugin

This commit is contained in:
journaliciouz
2025-12-11 14:49:16 +01:00
parent 97dce4aaf6
commit 1942a531d4
2820 changed files with 257786 additions and 9 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,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,18 @@
fileFormatVersion: 2
guid: 3abc70b7028a09449b0976268deba80b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/NiceVibrations/Feedbacks/Legacy/MMFeedbackNVSettings.cs
uploadId: 830868

View File

@@ -0,0 +1,44 @@
using UnityEngine;
using MoreMountains.Feedbacks;
using UnityEngine.Scripting.APIUpdating;
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("")]
[System.Serializable]
[FeedbackPath("Haptics/Haptics DEPRECATED!")]
[MovedFrom(false, null, "MoreMountains.Feedbacks.NiceVibrations")]
[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,18 @@
fileFormatVersion: 2
guid: dd8d60a3aa719934084bb1539d7e4ef3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/NiceVibrations/Feedbacks/MMF_Haptics.cs
uploadId: 830868

View File

@@ -0,0 +1,262 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
using MoreMountains.Tools;
#endif
#if UNITY_EDITOR
using UnityEditor;
using System.IO;
#endif
using UnityEngine.Scripting.APIUpdating;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this feedback to play a .haptic clip, optionally randomizing its level and frequency
/// </summary>
[AddComponentMenu("")]
[System.Serializable]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Clip")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.NiceVibrations")]
[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 bool HasCustomInspectors => true;
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;
/// a debug button that lets you test the haptic file from its inspector
public MMF_Button TestHapticButton;
[MMFInspectorGroup("Audio To Haptic", true, 14)]
/// the label of the MMSM Sound feedback you want to convert the audio clip from. If left empty, will find the first on this MMF Player
[Tooltip("the label of the MMSM Sound feedback you want to convert the audio clip from. If left empty, will find the first on this MMF Player")]
[MMFInformation("While you can set a clip in the field above, this feedback also offers the option to automatically convert a MMSM Sound feedback's audio clip into a haptic clip. " +
"This is a great way to save time, while retaining fine control over amplitude and frequency.\n\n " +
"To do it, you'll need a MMSM Sound feedback with a clip on that same MMF Player. If you have more than one, you can specify the label of the feedback you're after in the field below. " +
"Then, press the convert button. You can then press the Test button below to try your haptic and audio together and see if you like them.\n\n" +
"You can then normalize amplitude and/or frequency for gamepad to your liking. The first curve shows the haptic file for iOS/Android, the second curve shows rumble data.", MMFInformationAttribute.InformationType.Info, false)]
public string MMSMSoundFeedbackLabel;
/// the sample count is the resolution at which the haptic clip will be computed
[Tooltip("the sample count is the resolution at which the haptic clip will be computed")]
public int SampleCount = 256;
[Header("Amplitude")]
/// whether or not to normalize amplitude for the gamepad rumble
[Tooltip("whether or not to normalize amplitude for the gamepad rumble")]
public bool NormalizeAmplitude = true;
/// the factor to use when normalizing amplitude
[Tooltip("the factor to use when normalizing amplitude")]
[MMFCondition("NormalizeAmplitude", true)]
public float NormalizeAmplitudeFactor = 1f;
[Header("Frequency")]
/// whether or not to normalize frequency for the gamepad rumble
[Tooltip("whether or not to normalize frequency for the gamepad rumble")]
public bool NormalizeFrequency = true;
/// the factor to use when normalizing frequency
[Tooltip("the factor to use when normalizing frequency")]
[MMFCondition("NormalizeFrequency", true)]
public float NormalizeFrequencyFactor = 1f;
/// a test button to convert the MMSM Sound feedback's audio clip into a haptic clip and assign it to this feedback
public MMF_Button ConvertButton;
/// a test button to play both the haptic and sound at once
public MMF_Button TestHapticAudioButton;
public NVHapticData HapticData;
[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 == null || !HapticSettings.CanPlay() || (Clip == null))
{
return;
}
PlayHapticClip();
}
/// <summary>
/// Plays the haptic clip
/// </summary>
protected virtual void PlayHapticClip()
{
if (Clip == null)
{
return;
}
HapticSettings.SetGamepad();
HapticController.Load(Clip);
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();
}
/// <summary>
/// Initializes custom buttons
/// </summary>
public override void InitializeCustomAttributes()
{
base.InitializeCustomAttributes();
ConvertButton = new MMF_Button("Convert MMSM Sound feedback Audio Clip to Haptic", Convert);
TestHapticAudioButton = new MMF_Button("Test Haptic and Audio", TestHapticAndAudio);
TestHapticButton = new MMF_Button("Test Haptic", PlayHapticClip);
}
/// <summary>
/// A debug method used from the inspector to test both the haptic and audio files playing at once
/// </summary>
protected virtual void TestHapticAndAudio()
{
MMF_MMSoundManagerSound soundFeedback = Owner.GetFeedbackOfType<MMF_MMSoundManagerSound>(MMSMSoundFeedbackLabel);
if (soundFeedback != null)
{
soundFeedback.TestPlaySound();
}
PlayHapticClip();
}
/// <summary>
/// Tries and converts the MMSM Sound feedback's audio clip on the same MMF Player into a haptic clip and sets it as this feedback's haptic clip
/// </summary>
protected virtual void Convert()
{
#if UNITY_EDITOR
MMF_MMSoundManagerSound soundFeedback;
if ((MMSMSoundFeedbackLabel == null) || (MMSMSoundFeedbackLabel == ""))
{
soundFeedback = Owner.GetFeedbackOfType<MMF_MMSoundManagerSound>();
if (soundFeedback != null)
{
MMSMSoundFeedbackLabel = soundFeedback.Label;
}
else
{
Debug.LogError(this.Owner.name + " - NV Clip feedback : there is no MM Sound Manager Sound feedback on this MMF Player, nothing to convert.");
return;
}
}
else
{
soundFeedback = Owner.GetFeedbackOfType<MMF_MMSoundManagerSound>(MMSMSoundFeedbackLabel);
if (soundFeedback == null)
{
Debug.LogError(this.Owner.name + " - NV Clip feedback : couldn't find a MM Sound Manager Sound feedback with this label: " + MMSMSoundFeedbackLabel);
return;
}
}
AudioClip clip = soundFeedback.Sfx;
if (clip == null)
{
if (soundFeedback.RandomSfx.Length > 0)
{
clip = soundFeedback.RandomSfx[0];
}
if (clip == null)
{
Debug.LogError(this.Owner.name + " - NV Clip feedback : thee MM Sound Manager Sound feedback on this MMF Player doesn't have a clip, nothing to convert.");
return;
}
}
string filePath = AssetDatabase.GetAssetPath(clip);
string folderPath = Path.GetDirectoryName(filePath);
string newFileName = Path.GetFileNameWithoutExtension(filePath)+".haptic";
HapticData = AudioToHapticConverter.GenerateHapticFile(clip, folderPath, newFileName,
NormalizeAmplitude, NormalizeAmplitudeFactor,
NormalizeFrequency, NormalizeFrequencyFactor,
SampleCount);
Clip = HapticData.Clip;
CacheRequiresSetup();
#endif
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7a7b40b69918c9840b090deb2a59d5eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/NiceVibrations/Feedbacks/MMF_NVClip.cs
uploadId: 830868

View File

@@ -0,0 +1,155 @@
using UnityEngine;
using System.Collections;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
using UnityEngine.Scripting.APIUpdating;
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("")]
[System.Serializable]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Continuous")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.NiceVibrations")]
[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 == null || !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,18 @@
fileFormatVersion: 2
guid: 67fc7d627b6e1074895b5ed483eb737d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/NiceVibrations/Feedbacks/MMF_NVContinuous.cs
uploadId: 830868

View File

@@ -0,0 +1,80 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
using UnityEngine.Scripting.APIUpdating;
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("")]
[System.Serializable]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Control")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.NiceVibrations")]
[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,18 @@
fileFormatVersion: 2
guid: 6a3a1491160f1b944b35c4ba60eaedb2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/NiceVibrations/Feedbacks/MMF_NVControl.cs
uploadId: 830868

View File

@@ -0,0 +1,97 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
using UnityEngine.Scripting.APIUpdating;
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("")]
[System.Serializable]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Emphasis")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.NiceVibrations")]
[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 bool HasCustomInspectors => true;
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 debug button that lets you test the haptic file from its inspector
public MMF_Button PlayEmphasisButton;
/// 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>
/// Initializes custom buttons
/// </summary>
public override void InitializeCustomAttributes()
{
base.InitializeCustomAttributes();
PlayEmphasisButton = new MMF_Button("Test Emphasis", PlayEmphasis);
}
/// <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 == null || !HapticSettings.CanPlay())
{
return;
}
PlayEmphasis();
}
/// <summary>
/// Plays the specified emphasis haptic
/// </summary>
protected virtual void PlayEmphasis()
{
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,18 @@
fileFormatVersion: 2
guid: 72f4893994302d847bdb90bf4feead48
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/NiceVibrations/Feedbacks/MMF_NVEmphasis.cs
uploadId: 830868

View File

@@ -0,0 +1,80 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
using Lofelt.NiceVibrations;
#endif
using UnityEngine.Scripting.APIUpdating;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Use this feedback to play a preset haptic, limited but super simple predifined haptic patterns
/// </summary>
[AddComponentMenu("")]
[System.Serializable]
#if MOREMOUNTAINS_NICEVIBRATIONS_INSTALLED
[FeedbackPath("Haptics/Haptic Preset")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.NiceVibrations")]
[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 bool HasCustomInspectors => true;
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;
/// a debug button that lets you test the haptic file from its inspector
public MMF_Button PlayPresetButton;
[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>
/// Initializes custom buttons
/// </summary>
public override void InitializeCustomAttributes()
{
base.InitializeCustomAttributes();
PlayPresetButton = new MMF_Button("Test Preset", PlayPreset);
}
/// <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 == null || !HapticSettings.CanPlay())
{
return;
}
PlayPreset();
}
/// <summary>
/// Plays the target preset
/// </summary>
protected virtual void PlayPreset()
{
HapticSettings.SetGamepad();
HapticPatterns.PlayPreset(Preset);
}
#else
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { }
#endif
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: ccb12f2582242744685c2cb083debab8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/NiceVibrations/Feedbacks/MMF_NVPreset.cs
uploadId: 830868

View File

@@ -0,0 +1,3 @@
{
"reference": "GUID:4a1cb1490dc4df8409b2580d6b44e75e"
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: c05f8d9b1617d624cba54512d0bda394
AssemblyDefinitionReferenceImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/NiceVibrations/MoreMountains.Feedbacks.NiceVibrations.asmref
uploadId: 830868