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: c0cd952ed9971344c97734e47ae5bfdc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

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

View File

@@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
#if MM_CINEMACHINE
using Cinemachine;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
[FeedbackPath("Camera/Cinemachine Impulse")]
[FeedbackHelp("This feedback lets you trigger a Cinemachine Impulse event. You'll need a Cinemachine Impulse Listener on your camera for this to work.")]
public class MMFeedbackCinemachineImpulse : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
#endif
[Header("Cinemachine Impulse")]
#if MM_CINEMACHINE
/// the impulse definition to broadcast
[Tooltip("the impulse definition to broadcast")]
[CinemachineImpulseDefinitionProperty]
public CinemachineImpulseDefinition m_ImpulseDefinition;
#endif
/// the velocity to apply to the impulse shake
[Tooltip("the velocity to apply to the impulse shake")]
public Vector3 Velocity;
/// whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback
[Tooltip("whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback")]
public bool ClearImpulseOnStop = false;
#if MM_CINEMACHINE
/// the duration of this feedback is the duration of the impulse
public override float FeedbackDuration { get { return m_ImpulseDefinition.m_TimeEnvelope.Duration; } }
#endif
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE
CinemachineImpulseManager.Instance.IgnoreTimeScale = (Timing.TimescaleMode == TimescaleModes.Unscaled);
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
m_ImpulseDefinition.CreateEvent(position, Velocity * intensityMultiplier);
#endif
}
/// <summary>
/// Stops the animation if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized || !ClearImpulseOnStop)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
#if MM_CINEMACHINE
CinemachineImpulseManager.Instance.Clear();
#endif
}
}
}

View File

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

View File

@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
#if MM_CINEMACHINE
using Cinemachine;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
[FeedbackPath("Camera/Cinemachine Impulse Clear")]
[FeedbackHelp("This feedback lets you trigger a Cinemachine Impulse clear, stopping instantly any impulse that may be playing.")]
public class MMFeedbackCinemachineImpulseClear : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
#endif
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE
CinemachineImpulseManager.Instance.Clear();
#endif
}
}
}

View File

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

View File

@@ -0,0 +1,100 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MM_CINEMACHINE
using Cinemachine;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback will let you change the priorities of your cameras.
/// It requires a bit of setup : adding a MMCinemachinePriorityListener to your different cameras, with unique Channel values on them.
/// Optionally, you can add a MMCinemachinePriorityBrainListener on your Cinemachine Brain to handle different transition types and durations.
/// Then all you have to do is pick a channel and a new priority on your feedback, and play it. Magic transition!
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Camera/Cinemachine Transition")]
[FeedbackHelp("This feedback will let you change the priorities of your cameras. It requires a bit of setup : " +
"adding a MMCinemachinePriorityListener to your different cameras, with unique Channel values on them. " +
"Optionally, you can add a MMCinemachinePriorityBrainListener on your Cinemachine Brain to handle different transition types and durations. " +
"Then all you have to do is pick a channel and a new priority on your feedback, and play it. Magic transition!")]
public class MMFeedbackCinemachineTransition : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
public enum Modes { Event, Binding }
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
#endif
/// the duration of this feedback is the duration of the shake
#if MM_CINEMACHINE
public override float FeedbackDuration { get { return ApplyTimeMultiplier(BlendDefintion.m_Time); } set { BlendDefintion.m_Time = value; } }
#endif
[Header("Cinemachine Transition")]
/// the selected mode (either via event, or via direct binding of a specific camera)
[Tooltip("the selected mode (either via event, or via direct binding of a specific camera)")]
public Modes Mode = Modes.Event;
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
#if MM_CINEMACHINE
/// the virtual camera to target
[Tooltip("the virtual camera to target")]
[MMFEnumCondition("Mode", (int)Modes.Binding)]
public CinemachineVirtualCamera TargetVirtualCamera;
#endif
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetValuesAfterTransition = true;
[Header("Priority")]
/// the new priority to apply to all virtual cameras on the specified channel
[Tooltip("the new priority to apply to all virtual cameras on the specified channel")]
public int NewPriority = 10;
/// whether or not to force all virtual cameras on other channels to reset their priority to zero
[Tooltip("whether or not to force all virtual cameras on other channels to reset their priority to zero")]
public bool ForceMaxPriority = true;
/// whether or not to apply a new blend
[Tooltip("whether or not to apply a new blend")]
public bool ForceTransition = false;
#if MM_CINEMACHINE
/// the new blend definition to apply
[Tooltip("the new blend definition to apply")]
[MMFCondition("ForceTransition", true)]
public CinemachineBlendDefinition BlendDefintion;
protected CinemachineBlendDefinition _tempBlend;
#endif
/// <summary>
/// Triggers a priority change on listening virtual cameras
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE
_tempBlend = BlendDefintion;
_tempBlend.m_Time = FeedbackDuration;
if (Mode == Modes.Event)
{
MMCinemachinePriorityEvent.Trigger(ChannelData(Channel), ForceMaxPriority, NewPriority, ForceTransition, _tempBlend, ResetValuesAfterTransition, Timing.TimescaleMode);
}
else
{
MMCinemachinePriorityEvent.Trigger(ChannelData(Channel), ForceMaxPriority, 0, ForceTransition, _tempBlend, ResetValuesAfterTransition, Timing.TimescaleMode);
TargetVirtualCamera.Priority = NewPriority;
}
#endif
}
}
}

View File

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

View File

@@ -0,0 +1,73 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
#if MM_CINEMACHINE
using Cinemachine;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
#if MM_CINEMACHINE
[FeedbackPath("Camera/Cinemachine Impulse")]
#endif
[FeedbackHelp("This feedback lets you trigger a Cinemachine Impulse event. You'll need a Cinemachine Impulse Listener on your camera for this to work.")]
public class MMF_CinemachineImpulse : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
#endif
public override bool HasRandomness => true;
#if MM_CINEMACHINE
[MMFInspectorGroup("Cinemachine Impulse", true, 28)]
/// the impulse definition to broadcast
[Tooltip("the impulse definition to broadcast")]
public CinemachineImpulseDefinition m_ImpulseDefinition;
/// the velocity to apply to the impulse shake
[Tooltip("the velocity to apply to the impulse shake")]
public Vector3 Velocity;
/// whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback
[Tooltip("whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback")]
public bool ClearImpulseOnStop = false;
/// the duration of this feedback is the duration of the impulse
public override float FeedbackDuration { get { return m_ImpulseDefinition.m_TimeEnvelope.Duration; } }
#endif
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE
CinemachineImpulseManager.Instance.IgnoreTimeScale = !InScaledTimescaleMode;
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
m_ImpulseDefinition.CreateEvent(position, Velocity * intensityMultiplier);
#endif
}
/// <summary>
/// Stops the animation if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
#if MM_CINEMACHINE
if (!Active || !FeedbackTypeAuthorized || !ClearImpulseOnStop)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
CinemachineImpulseManager.Instance.Clear();
#endif
}
}
}

View File

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

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
#if MM_CINEMACHINE
using Cinemachine;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
#if MM_CINEMACHINE
[FeedbackPath("Camera/Cinemachine Impulse Clear")]
#endif
[FeedbackHelp("This feedback lets you trigger a Cinemachine Impulse clear, stopping instantly any impulse that may be playing.")]
public class MMF_CinemachineImpulseClear : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
#endif
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE
CinemachineImpulseManager.Instance.Clear();
#endif
}
}
}

View File

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

View File

@@ -0,0 +1,90 @@
using UnityEngine;
using MoreMountains.Feedbacks;
#if MM_CINEMACHINE
using Cinemachine;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
#if MM_CINEMACHINE
[FeedbackPath("Camera/Cinemachine Impulse Source")]
#endif
[FeedbackHelp("This feedback lets you generate an impulse on a Cinemachine Impulse source. You'll need a Cinemachine Impulse Listener on your camera for this to work.")]
public class MMF_CinemachineImpulseSource : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
#if MM_CINEMACHINE
public override bool EvaluateRequiresSetup() { return (ImpulseSource == null); }
public override string RequiredTargetText { get { return ImpulseSource != null ? ImpulseSource.name : ""; } }
#endif
public override string RequiresSetupText { get { return "This feedback requires that an ImpulseSource be set to be able to work properly. You can set one below."; } }
#endif
[MMFInspectorGroup("Cinemachine Impulse Source", true, 28)]
/// the velocity to apply to the impulse shake
[Tooltip("the velocity to apply to the impulse shake")]
public Vector3 Velocity = new Vector3(1f,1f,1f);
#if MM_CINEMACHINE
/// the impulse definition to broadcast
[Tooltip("the impulse definition to broadcast")]
public CinemachineImpulseSource ImpulseSource;
#endif
/// whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback
[Tooltip("whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback")]
public bool ClearImpulseOnStop = false;
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE
if (ImpulseSource != null)
{
ImpulseSource.GenerateImpulse(Velocity);
}
#endif
}
/// <summary>
/// Stops the animation if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized || !ClearImpulseOnStop)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
#if MM_CINEMACHINE
CinemachineImpulseManager.Instance.Clear();
#endif
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE
CinemachineImpulseManager.Instance.Clear();
#endif
}
}
}

View File

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

View File

@@ -0,0 +1,116 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
#if MM_CINEMACHINE
using Cinemachine;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback will let you change the priorities of your cameras.
/// It requires a bit of setup : adding a MMCinemachinePriorityListener to your different cameras, with unique Channel values on them.
/// Optionally, you can add a MMCinemachinePriorityBrainListener on your Cinemachine Brain to handle different transition types and durations.
/// Then all you have to do is pick a channel and a new priority on your feedback, and play it. Magic transition!
/// </summary>
[AddComponentMenu("")]
#if MM_CINEMACHINE
[FeedbackPath("Camera/Cinemachine Transition")]
#endif
[FeedbackHelp("This feedback will let you change the priorities of your cameras. It requires a bit of setup : " +
"adding a MMCinemachinePriorityListener to your different cameras, with unique Channel values on them. " +
"Optionally, you can add a MMCinemachinePriorityBrainListener on your Cinemachine Brain to handle different transition types and durations. " +
"Then all you have to do is pick a channel and a new priority on your feedback, and play it. Magic transition!")]
public class MMF_CinemachineTransition : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
public enum Modes { Event, Binding }
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
public override string RequiredTargetText => RequiredChannelText;
#endif
#if MM_CINEMACHINE
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(BlendDefintion.m_Time); } set { BlendDefintion.m_Time = value; } }
#endif
public override bool HasChannel => true;
[MMFInspectorGroup("Cinemachine Transition", true, 52)]
/// the selected mode (either via event, or via direct binding of a specific camera)
[Tooltip("the selected mode (either via event, or via direct binding of a specific camera)")]
public Modes Mode = Modes.Event;
#if MM_CINEMACHINE
/// the virtual camera to target
[Tooltip("the virtual camera to target")]
[MMFEnumCondition("Mode", (int)Modes.Binding)]
public CinemachineVirtualCamera TargetVirtualCamera;
#endif
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetValuesAfterTransition = true;
[Header("Priority")]
/// the new priority to apply to all virtual cameras on the specified channel
[Tooltip("the new priority to apply to all virtual cameras on the specified channel")]
public int NewPriority = 10;
/// whether or not to force all virtual cameras on other channels to reset their priority to zero
[Tooltip("whether or not to force all virtual cameras on other channels to reset their priority to zero")]
public bool ForceMaxPriority = true;
/// whether or not to apply a new blend
[Tooltip("whether or not to apply a new blend")]
public bool ForceTransition = false;
#if MM_CINEMACHINE
/// the new blend definition to apply
[Tooltip("the new blend definition to apply")]
[MMFCondition("ForceTransition", true)]
public CinemachineBlendDefinition BlendDefintion;
protected CinemachineBlendDefinition _tempBlend;
#endif
/// <summary>
/// Triggers a priority change on listening virtual cameras
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE
_tempBlend = BlendDefintion;
_tempBlend.m_Time = FeedbackDuration;
if (Mode == Modes.Event)
{
MMCinemachinePriorityEvent.Trigger(ChannelData, ForceMaxPriority, NewPriority, ForceTransition, _tempBlend, ResetValuesAfterTransition, ComputedTimescaleMode);
}
else
{
MMCinemachinePriorityEvent.Trigger(ChannelData, ForceMaxPriority, 0, ForceTransition, _tempBlend, ResetValuesAfterTransition, ComputedTimescaleMode);
TargetVirtualCamera.Priority = NewPriority;
}
#endif
}
/// <summary>
/// On restore, we restore our initial state
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_CINEMACHINE
MMCinemachinePriorityEvent.Trigger(ChannelData, ForceMaxPriority, 0, ForceTransition, _tempBlend, ResetValuesAfterTransition, ComputedTimescaleMode, true);
#endif
}
}
}

View File

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

View File

@@ -0,0 +1,23 @@
{
"name": "MoreMountains.Feedbacks.Cinemachine",
"references": [
"GUID:4307f53044263cf4b835bd812fc161a4",
"GUID:8087d854c1f812e4b9a74437dfc524e0",
"GUID:4a1cb1490dc4df8409b2580d6b44e75e"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [
{
"name": "com.unity.cinemachine",
"expression": "1.0.0",
"define": "MM_CINEMACHINE"
}
],
"noEngineReferences": false
}

View File

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

View File

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

View File

@@ -0,0 +1,205 @@
using System.Collections;
using UnityEngine;
#if MM_CINEMACHINE
using Cinemachine;
#endif
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this component to your Cinemachine Virtual Camera to have it shake when calling its ShakeCamera methods.
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MMCinemachineCameraShaker")]
#if MM_CINEMACHINE
[RequireComponent(typeof(CinemachineVirtualCamera))]
#endif
public class MMCinemachineCameraShaker : MonoBehaviour
{
[Header("Settings")]
/// whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what.
/// MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable
[Tooltip("whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what. " +
"MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable")]
public MMChannelModes ChannelMode = MMChannelModes.Int;
/// the channel to listen to - has to match the one on the feedback
[Tooltip("the channel to listen to - has to match the one on the feedback")]
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.Int)]
public int Channel = 0;
/// the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel,
/// right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name
[Tooltip("the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel, " +
"right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name")]
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.MMChannel)]
public MMChannel MMChannelDefinition = null;
/// The default amplitude that will be applied to your shakes if you don't specify one
[Tooltip("The default amplitude that will be applied to your shakes if you don't specify one")]
public float DefaultShakeAmplitude = .5f;
/// The default frequency that will be applied to your shakes if you don't specify one
[Tooltip("The default frequency that will be applied to your shakes if you don't specify one")]
public float DefaultShakeFrequency = 10f;
/// the amplitude of the camera's noise when it's idle
[Tooltip("the amplitude of the camera's noise when it's idle")]
[MMFReadOnly]
public float IdleAmplitude;
/// the frequency of the camera's noise when it's idle
[Tooltip("the frequency of the camera's noise when it's idle")]
[MMFReadOnly]
public float IdleFrequency = 1f;
/// the speed at which to interpolate the shake
[Tooltip("the speed at which to interpolate the shake")]
public float LerpSpeed = 5f;
[Header("Test")]
/// a duration (in seconds) to apply when testing this shake via the TestShake button
[Tooltip("a duration (in seconds) to apply when testing this shake via the TestShake button")]
public float TestDuration = 0.3f;
/// the amplitude to apply when testing this shake via the TestShake button
[Tooltip("the amplitude to apply when testing this shake via the TestShake button")]
public float TestAmplitude = 2f;
/// the frequency to apply when testing this shake via the TestShake button
[Tooltip("the frequency to apply when testing this shake via the TestShake button")]
public float TestFrequency = 20f;
[MMFInspectorButton("TestShake")]
public bool TestShakeButton;
#if MM_CINEMACHINE
public virtual float GetTime() { return (_timescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; }
public virtual float GetDeltaTime() { return (_timescaleMode == TimescaleModes.Scaled) ? Time.deltaTime : Time.unscaledDeltaTime; }
protected TimescaleModes _timescaleMode;
protected Vector3 _initialPosition;
protected Quaternion _initialRotation;
protected Cinemachine.CinemachineBasicMultiChannelPerlin _perlin;
protected Cinemachine.CinemachineVirtualCamera _virtualCamera;
protected float _targetAmplitude;
protected float _targetFrequency;
private Coroutine _shakeCoroutine;
/// <summary>
/// On awake we grab our components
/// </summary>
protected virtual void Awake()
{
_virtualCamera = this.gameObject.GetComponent<CinemachineVirtualCamera>();
_perlin = _virtualCamera.GetCinemachineComponent<Cinemachine.CinemachineBasicMultiChannelPerlin>();
}
/// <summary>
/// On Start we reset our camera to apply our base amplitude and frequency
/// </summary>
protected virtual void Start()
{
if (_perlin != null)
{
IdleAmplitude = _perlin.m_AmplitudeGain;
IdleFrequency = _perlin.m_FrequencyGain;
}
_targetAmplitude = IdleAmplitude;
_targetFrequency = IdleFrequency;
}
protected virtual void Update()
{
if (_perlin != null)
{
_perlin.m_AmplitudeGain = _targetAmplitude;
_perlin.m_FrequencyGain = Mathf.Lerp(_perlin.m_FrequencyGain, _targetFrequency, GetDeltaTime() * LerpSpeed);
}
}
/// <summary>
/// Use this method to shake the camera for the specified duration (in seconds) with the default amplitude and frequency
/// </summary>
/// <param name="duration">Duration.</param>
public virtual void ShakeCamera(float duration, bool infinite, bool useUnscaledTime = false)
{
StartCoroutine(ShakeCameraCo(duration, DefaultShakeAmplitude, DefaultShakeFrequency, infinite, useUnscaledTime));
}
/// <summary>
/// Use this method to shake the camera for the specified duration (in seconds), amplitude and frequency
/// </summary>
/// <param name="duration">Duration.</param>
/// <param name="amplitude">Amplitude.</param>
/// <param name="frequency">Frequency.</param>
public virtual void ShakeCamera(float duration, float amplitude, float frequency, bool infinite, bool useUnscaledTime = false)
{
if (_shakeCoroutine != null)
{
StopCoroutine(_shakeCoroutine);
}
_shakeCoroutine = StartCoroutine(ShakeCameraCo(duration, amplitude, frequency, infinite, useUnscaledTime));
}
/// <summary>
/// This coroutine will shake the
/// </summary>
/// <returns>The camera co.</returns>
/// <param name="duration">Duration.</param>
/// <param name="amplitude">Amplitude.</param>
/// <param name="frequency">Frequency.</param>
protected virtual IEnumerator ShakeCameraCo(float duration, float amplitude, float frequency, bool infinite, bool useUnscaledTime)
{
_targetAmplitude = amplitude;
_targetFrequency = frequency;
_timescaleMode = useUnscaledTime ? TimescaleModes.Unscaled : TimescaleModes.Scaled;
if (!infinite)
{
yield return new WaitForSeconds(duration);
CameraReset();
}
}
/// <summary>
/// Resets the camera's noise values to their idle values
/// </summary>
public virtual void CameraReset()
{
_targetAmplitude = IdleAmplitude;
_targetFrequency = IdleFrequency;
}
public virtual void OnCameraShakeEvent(float duration, float amplitude, float frequency, float amplitudeX, float amplitudeY, float amplitudeZ, bool infinite, MMChannelData channelData, bool useUnscaledTime)
{
if (!MMChannel.Match(channelData, ChannelMode, Channel, MMChannelDefinition))
{
return;
}
this.ShakeCamera(duration, amplitude, frequency, infinite, useUnscaledTime);
}
public virtual void OnCameraShakeStopEvent(MMChannelData channelData)
{
if (!MMChannel.Match(channelData, ChannelMode, Channel, MMChannelDefinition))
{
return;
}
if (_shakeCoroutine != null)
{
StopCoroutine(_shakeCoroutine);
}
CameraReset();
}
protected virtual void OnEnable()
{
MMCameraShakeEvent.Register(OnCameraShakeEvent);
MMCameraShakeStopEvent.Register(OnCameraShakeStopEvent);
}
protected virtual void OnDisable()
{
MMCameraShakeEvent.Unregister(OnCameraShakeEvent);
MMCameraShakeStopEvent.Unregister(OnCameraShakeStopEvent);
}
protected virtual void TestShake()
{
MMCameraShakeEvent.Trigger(TestDuration, TestAmplitude, TestFrequency, 0f, 0f, 0f, false, new MMChannelData(ChannelMode, Channel, MMChannelDefinition));
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,206 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if MM_CINEMACHINE
using Cinemachine;
#endif
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this to a Cinemachine virtual camera and it'll let you control its near and far clipping planes
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MMCinemachineClippingPlanesShaker")]
#if MM_CINEMACHINE
[RequireComponent(typeof(CinemachineVirtualCamera))]
#endif
public class MMCinemachineClippingPlanesShaker : MMShaker
{
[MMInspectorGroup("Clipping Planes", true, 45)]
/// whether or not to add to the initial value
public bool RelativeClippingPlanes = false;
[MMInspectorGroup("Near Plane", true, 46)]
/// the curve used to animate the intensity value on
[Tooltip("the curve used to animate the intensity value on")]
public AnimationCurve ShakeNear = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapNearZero = 0.3f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapNearOne = 100f;
[MMInspectorGroup("Far Plane", true, 47)]
/// the curve used to animate the intensity value on
[Tooltip("the curve used to animate the intensity value on")]
public AnimationCurve ShakeFar = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapFarZero = 1000f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapFarOne = 1000f;
#if MM_CINEMACHINE
protected CinemachineVirtualCamera _targetCamera;
protected float _initialNear;
protected float _initialFar;
protected float _originalShakeDuration;
protected bool _originalRelativeClippingPlanes;
protected AnimationCurve _originalShakeNear;
protected float _originalRemapNearZero;
protected float _originalRemapNearOne;
protected AnimationCurve _originalShakeFar;
protected float _originalRemapFarZero;
protected float _originalRemapFarOne;
/// <summary>
/// On init we initialize our values
/// </summary>
protected override void Initialization()
{
base.Initialization();
_targetCamera = this.gameObject.GetComponent<CinemachineVirtualCamera>();
}
/// <summary>
/// When that shaker gets added, we initialize its shake duration
/// </summary>
protected virtual void Reset()
{
ShakeDuration = 0.5f;
}
/// <summary>
/// Shakes values over time
/// </summary>
protected override void Shake()
{
float newNear = ShakeFloat(ShakeNear, RemapNearZero, RemapNearOne, RelativeClippingPlanes, _initialNear);
_targetCamera.m_Lens.NearClipPlane = newNear;
float newFar = ShakeFloat(ShakeFar, RemapFarZero, RemapFarOne, RelativeClippingPlanes, _initialFar);
_targetCamera.m_Lens.FarClipPlane = newFar;
}
/// <summary>
/// Collects initial values on the target
/// </summary>
protected override void GrabInitialValues()
{
_initialNear = _targetCamera.m_Lens.NearClipPlane;
_initialFar = _targetCamera.m_Lens.FarClipPlane;
}
/// <summary>
/// When we get the appropriate event, we trigger a shake
/// </summary>
/// <param name="distortionCurve"></param>
/// <param name="duration"></param>
/// <param name="amplitude"></param>
/// <param name="relativeDistortion"></param>
/// <param name="feedbacksIntensity"></param>
/// <param name="channel"></param>
public virtual void OnMMCameraClippingPlanesShakeEvent(AnimationCurve animNearCurve, float duration, float remapNearMin, float remapNearMax, AnimationCurve animFarCurve, float remapFarMin, float remapFarMax, bool relativeValues = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
if (!CheckEventAllowed(channelData))
{
return;
}
if (stop)
{
Stop();
return;
}
if (restore)
{
ResetTargetValues();
return;
}
if (!Interruptible && Shaking)
{
return;
}
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeNear = ShakeNear;
_originalShakeFar = ShakeFar;
_originalRemapNearZero = RemapNearZero;
_originalRemapNearOne = RemapNearOne;
_originalRemapFarZero = RemapFarZero;
_originalRemapFarOne = RemapFarOne;
_originalRelativeClippingPlanes = RelativeClippingPlanes;
}
TimescaleMode = timescaleMode;
ShakeDuration = duration;
ShakeNear = animNearCurve;
RemapNearZero = remapNearMin * feedbacksIntensity;
RemapNearOne = remapNearMax * feedbacksIntensity;
ShakeFar = animFarCurve;
RemapFarZero = remapFarMin * feedbacksIntensity;
RemapFarOne = remapFarMax * feedbacksIntensity;
RelativeClippingPlanes = relativeValues;
ForwardDirection = forwardDirection;
Play();
}
/// <summary>
/// Resets the target's values
/// </summary>
protected override void ResetTargetValues()
{
base.ResetTargetValues();
_targetCamera.m_Lens.NearClipPlane = _initialNear;
_targetCamera.m_Lens.FarClipPlane = _initialFar;
}
/// <summary>
/// Resets the shaker's values
/// </summary>
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeNear = _originalShakeNear;
ShakeFar = _originalShakeFar;
RemapNearZero = _originalRemapNearZero;
RemapNearOne = _originalRemapNearOne;
RemapFarZero = _originalRemapFarZero;
RemapFarOne = _originalRemapFarOne;
RelativeClippingPlanes = _originalRelativeClippingPlanes;
}
/// <summary>
/// Starts listening for events
/// </summary>
public override void StartListening()
{
base.StartListening();
MMCameraClippingPlanesShakeEvent.Register(OnMMCameraClippingPlanesShakeEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
public override void StopListening()
{
base.StopListening();
MMCameraClippingPlanesShakeEvent.Unregister(OnMMCameraClippingPlanesShakeEvent);
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,177 @@
using UnityEngine;
#if MM_CINEMACHINE
using Cinemachine;
#endif
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this to a Cinemachine virtual camera and it'll let you control its field of view over time, can be piloted by a MMFeedbackCameraFieldOfView
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MMCinemachineFieldOfViewShaker")]
#if MM_CINEMACHINE
[RequireComponent(typeof(CinemachineVirtualCamera))]
#endif
public class MMCinemachineFieldOfViewShaker : MMShaker
{
[MMInspectorGroup("Field of view", true, 41)]
/// whether or not to add to the initial value
[Tooltip("whether or not to add to the initial value")]
public bool RelativeFieldOfView = false;
/// the curve used to animate the intensity value on
[Tooltip("the curve used to animate the intensity value on")]
public AnimationCurve ShakeFieldOfView = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(0f, 179f)]
public float RemapFieldOfViewZero = 60f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(0f, 179f)]
public float RemapFieldOfViewOne = 120f;
#if MM_CINEMACHINE
protected CinemachineVirtualCamera _targetCamera;
protected float _initialFieldOfView;
protected float _originalShakeDuration;
protected bool _originalRelativeFieldOfView;
protected AnimationCurve _originalShakeFieldOfView;
protected float _originalRemapFieldOfViewZero;
protected float _originalRemapFieldOfViewOne;
/// <summary>
/// On init we initialize our values
/// </summary>
protected override void Initialization()
{
base.Initialization();
_targetCamera = this.gameObject.GetComponent<CinemachineVirtualCamera>();
}
/// <summary>
/// When that shaker gets added, we initialize its shake duration
/// </summary>
protected virtual void Reset()
{
ShakeDuration = 0.5f;
}
/// <summary>
/// Shakes values over time
/// </summary>
protected override void Shake()
{
float newFieldOfView = ShakeFloat(ShakeFieldOfView, RemapFieldOfViewZero, RemapFieldOfViewOne, RelativeFieldOfView, _initialFieldOfView);
_targetCamera.m_Lens.FieldOfView = newFieldOfView;
}
/// <summary>
/// Collects initial values on the target
/// </summary>
protected override void GrabInitialValues()
{
_initialFieldOfView = _targetCamera.m_Lens.FieldOfView;
}
/// <summary>
/// When we get the appropriate event, we trigger a shake
/// </summary>
/// <param name="distortionCurve"></param>
/// <param name="duration"></param>
/// <param name="amplitude"></param>
/// <param name="relativeDistortion"></param>
/// <param name="feedbacksIntensity"></param>
/// <param name="channel"></param>
public virtual void OnMMCameraFieldOfViewShakeEvent(AnimationCurve distortionCurve, float duration, float remapMin, float remapMax, bool relativeDistortion = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
if (!CheckEventAllowed(channelData))
{
return;
}
if (stop)
{
Stop();
return;
}
if (restore)
{
ResetTargetValues();
return;
}
if (!Interruptible && Shaking)
{
return;
}
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeFieldOfView = ShakeFieldOfView;
_originalRemapFieldOfViewZero = RemapFieldOfViewZero;
_originalRemapFieldOfViewOne = RemapFieldOfViewOne;
_originalRelativeFieldOfView = RelativeFieldOfView;
}
TimescaleMode = timescaleMode;
ShakeDuration = duration;
ShakeFieldOfView = distortionCurve;
RemapFieldOfViewZero = remapMin * feedbacksIntensity;
RemapFieldOfViewOne = remapMax * feedbacksIntensity;
RelativeFieldOfView = relativeDistortion;
ForwardDirection = forwardDirection;
Play();
}
/// <summary>
/// Resets the target's values
/// </summary>
protected override void ResetTargetValues()
{
base.ResetTargetValues();
_targetCamera.m_Lens.FieldOfView = _initialFieldOfView;
}
/// <summary>
/// Resets the shaker's values
/// </summary>
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeFieldOfView = _originalShakeFieldOfView;
RemapFieldOfViewZero = _originalRemapFieldOfViewZero;
RemapFieldOfViewOne = _originalRemapFieldOfViewOne;
RelativeFieldOfView = _originalRelativeFieldOfView;
}
/// <summary>
/// Starts listening for events
/// </summary>
public override void StartListening()
{
base.StartListening();
MMCameraFieldOfViewShakeEvent.Register(OnMMCameraFieldOfViewShakeEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
public override void StopListening()
{
base.StopListening();
MMCameraFieldOfViewShakeEvent.Unregister(OnMMCameraFieldOfViewShakeEvent);
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,217 @@
using UnityEngine;
#if MM_CINEMACHINE
using Cinemachine;
#endif
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This class will allow you to trigger zooms on your cinemachine camera by sending MMCameraZoomEvents from any other class
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MMCinemachineFreeLookZoom")]
#if MM_CINEMACHINE
[RequireComponent(typeof(Cinemachine.CinemachineFreeLook))]
#endif
public class MMCinemachineFreeLookZoom : MonoBehaviour
{
[Header("Channel")]
[MMFInspectorGroup("Shaker Settings", true, 3)]
/// whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what.
/// MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable
[Tooltip("whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what. " +
"MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable")]
public MMChannelModes ChannelMode = MMChannelModes.Int;
/// the channel to listen to - has to match the one on the feedback
[Tooltip("the channel to listen to - has to match the one on the feedback")]
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.Int)]
public int Channel = 0;
/// the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel,
/// right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name
[Tooltip("the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel, " +
"right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name")]
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.MMChannel)]
public MMChannel MMChannelDefinition = null;
[Header("Transition Speed")]
/// the animation curve to apply to the zoom transition
[Tooltip("the animation curve to apply to the zoom transition")]
public AnimationCurve ZoomCurve = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f));
[Header("Test Zoom")]
/// the mode to apply the zoom in when using the test button in the inspector
[Tooltip("the mode to apply the zoom in when using the test button in the inspector")]
public MMCameraZoomModes TestMode;
/// the target field of view to apply the zoom in when using the test button in the inspector
[Tooltip("the target field of view to apply the zoom in when using the test button in the inspector")]
public float TestFieldOfView = 30f;
/// the transition duration to apply the zoom in when using the test button in the inspector
[Tooltip("the transition duration to apply the zoom in when using the test button in the inspector")]
public float TestTransitionDuration = 0.1f;
/// the duration to apply the zoom in when using the test button in the inspector
[Tooltip("the duration to apply the zoom in when using the test button in the inspector")]
public float TestDuration = 0.05f;
[MMFInspectorButton("TestZoom")]
/// an inspector button to test the zoom in play mode
public bool TestZoomButton;
#if MM_CINEMACHINE
protected Cinemachine.CinemachineFreeLook _freeLookCamera;
protected float _initialFieldOfView;
protected MMCameraZoomModes _mode;
protected bool _zooming = false;
protected float _startFieldOfView;
protected float _transitionDuration;
protected float _duration;
protected float _targetFieldOfView;
protected float _delta = 0f;
protected int _direction = 1;
protected float _reachedDestinationTimestamp;
protected bool _destinationReached = false;
/// <summary>
/// On Awake we grab our virtual camera
/// </summary>
protected virtual void Awake()
{
_freeLookCamera = this.gameObject.GetComponent<Cinemachine.CinemachineFreeLook>();
_initialFieldOfView = _freeLookCamera.m_Lens.FieldOfView;
}
/// <summary>
/// On Update if we're zooming we modify our field of view accordingly
/// </summary>
protected virtual void Update()
{
if (!_zooming)
{
return;
}
if (_freeLookCamera.m_Lens.FieldOfView != _targetFieldOfView)
{
_delta += Time.deltaTime / _transitionDuration;
_freeLookCamera.m_Lens.FieldOfView = Mathf.LerpUnclamped(_startFieldOfView, _targetFieldOfView, ZoomCurve.Evaluate(_delta));
}
else
{
if (!_destinationReached)
{
_reachedDestinationTimestamp = Time.time;
_destinationReached = true;
}
if ((_mode == MMCameraZoomModes.For) && (_direction == 1))
{
if (Time.time - _reachedDestinationTimestamp > _duration)
{
_direction = -1;
_startFieldOfView = _targetFieldOfView;
_targetFieldOfView = _initialFieldOfView;
_delta = 0f;
}
}
else
{
_zooming = false;
}
}
}
/// <summary>
/// A method that triggers the zoom, ideally only to be called via an event, but public for convenience
/// </summary>
/// <param name="mode"></param>
/// <param name="newFieldOfView"></param>
/// <param name="transitionDuration"></param>
/// <param name="duration"></param>
public virtual void Zoom(MMCameraZoomModes mode, float newFieldOfView, float transitionDuration, float duration, bool relative = false)
{
if (_zooming)
{
return;
}
_zooming = true;
_delta = 0f;
_mode = mode;
_startFieldOfView = _freeLookCamera.m_Lens.FieldOfView;
_transitionDuration = transitionDuration;
_duration = duration;
_transitionDuration = transitionDuration;
_direction = 1;
_destinationReached = false;
switch (mode)
{
case MMCameraZoomModes.For:
_targetFieldOfView = newFieldOfView;
break;
case MMCameraZoomModes.Set:
_targetFieldOfView = newFieldOfView;
break;
case MMCameraZoomModes.Reset:
_targetFieldOfView = _initialFieldOfView;
break;
}
if (relative)
{
_targetFieldOfView += _initialFieldOfView;
}
}
/// <summary>
/// The method used by the test button to trigger a test zoom
/// </summary>
protected virtual void TestZoom()
{
Zoom(TestMode, TestFieldOfView, TestTransitionDuration, TestDuration);
}
/// <summary>
/// When we get an MMCameraZoomEvent we call our zoom method
/// </summary>
/// <param name="zoomEvent"></param>
public virtual void OnCameraZoomEvent(MMCameraZoomModes mode, float newFieldOfView, float transitionDuration, float duration, MMChannelData channelData, bool useUnscaledTime, bool stop = false, bool relative = false, bool restore = false)
{
if (!MMChannel.Match(channelData, ChannelMode, Channel, MMChannelDefinition))
{
return;
}
if (stop)
{
_zooming = false;
return;
}
if (restore)
{
_freeLookCamera.m_Lens.FieldOfView = _initialFieldOfView;
return;
}
this.Zoom(mode, newFieldOfView, transitionDuration, duration, relative);
}
/// <summary>
/// Starts listening for MMCameraZoomEvents
/// </summary>
protected virtual void OnEnable()
{
MMCameraZoomEvent.Register(OnCameraZoomEvent);
}
/// <summary>
/// Stops listening for MMCameraZoomEvents
/// </summary>
protected virtual void OnDisable()
{
MMCameraZoomEvent.Unregister(OnCameraZoomEvent);
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,173 @@
using UnityEngine;
#if MM_CINEMACHINE
using Cinemachine;
#endif
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this to a Cinemachine virtual camera and it'll let you control its orthographic size over time, can be piloted by a MMFeedbackCameraOrthographicSize
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MMCinemachineOrthographicSizeShaker")]
#if MM_CINEMACHINE
[RequireComponent(typeof(CinemachineVirtualCamera))]
#endif
public class MMCinemachineOrthographicSizeShaker : MMShaker
{
[MMInspectorGroup("Orthographic Size", true, 43)]
/// whether or not to add to the initial value
[Tooltip("whether or not to add to the initial value")]
public bool RelativeOrthographicSize = false;
/// the curve used to animate the intensity value on
[Tooltip("the curve used to animate the intensity value on")]
public AnimationCurve ShakeOrthographicSize = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapOrthographicSizeZero = 5f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapOrthographicSizeOne = 10f;
#if MM_CINEMACHINE
protected CinemachineVirtualCamera _targetCamera;
protected float _initialOrthographicSize;
protected float _originalShakeDuration;
protected bool _originalRelativeOrthographicSize;
protected AnimationCurve _originalShakeOrthographicSize;
protected float _originalRemapOrthographicSizeZero;
protected float _originalRemapOrthographicSizeOne;
/// <summary>
/// On init we initialize our values
/// </summary>
protected override void Initialization()
{
base.Initialization();
_targetCamera = this.gameObject.GetComponent<CinemachineVirtualCamera>();
}
/// <summary>
/// When that shaker gets added, we initialize its shake duration
/// </summary>
protected virtual void Reset()
{
ShakeDuration = 0.5f;
}
/// <summary>
/// Shakes values over time
/// </summary>
protected override void Shake()
{
float newOrthographicSize = ShakeFloat(ShakeOrthographicSize, RemapOrthographicSizeZero, RemapOrthographicSizeOne, RelativeOrthographicSize, _initialOrthographicSize);
_targetCamera.m_Lens.OrthographicSize = newOrthographicSize;
}
/// <summary>
/// Collects initial values on the target
/// </summary>
protected override void GrabInitialValues()
{
_initialOrthographicSize = _targetCamera.m_Lens.OrthographicSize;
}
/// <summary>
/// When we get the appropriate event, we trigger a shake
/// </summary>
/// <param name="distortionCurve"></param>
/// <param name="duration"></param>
/// <param name="amplitude"></param>
/// <param name="relativeDistortion"></param>
/// <param name="feedbacksIntensity"></param>
/// <param name="channel"></param>
public virtual void OnMMCameraOrthographicSizeShakeEvent(AnimationCurve distortionCurve, float duration, float remapMin, float remapMax, bool relativeDistortion = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true, bool stop = false, bool restore = false)
{
if (!CheckEventAllowed(channelData))
{
return;
}
if (stop)
{
Stop();
return;
}
if (restore)
{
ResetTargetValues();
return;
}
if (!Interruptible && Shaking)
{
return;
}
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeOrthographicSize = ShakeOrthographicSize;
_originalRemapOrthographicSizeZero = RemapOrthographicSizeZero;
_originalRemapOrthographicSizeOne = RemapOrthographicSizeOne;
_originalRelativeOrthographicSize = RelativeOrthographicSize;
}
ShakeDuration = duration;
ShakeOrthographicSize = distortionCurve;
RemapOrthographicSizeZero = remapMin * feedbacksIntensity;
RemapOrthographicSizeOne = remapMax * feedbacksIntensity;
RelativeOrthographicSize = relativeDistortion;
ForwardDirection = forwardDirection;
Play();
}
/// <summary>
/// Resets the target's values
/// </summary>
protected override void ResetTargetValues()
{
base.ResetTargetValues();
_targetCamera.m_Lens.OrthographicSize = _initialOrthographicSize;
}
/// <summary>
/// Resets the shaker's values
/// </summary>
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeOrthographicSize = _originalShakeOrthographicSize;
RemapOrthographicSizeZero = _originalRemapOrthographicSizeZero;
RemapOrthographicSizeOne = _originalRemapOrthographicSizeOne;
RelativeOrthographicSize = _originalRelativeOrthographicSize;
}
/// <summary>
/// Starts listening for events
/// </summary>
public override void StartListening()
{
base.StartListening();
MMCameraOrthographicSizeShakeEvent.Register(OnMMCameraOrthographicSizeShakeEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
public override void StopListening()
{
base.StopListening();
MMCameraOrthographicSizeShakeEvent.Unregister(OnMMCameraOrthographicSizeShakeEvent);
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,105 @@
using System.Collections;
using UnityEngine;
#if MM_CINEMACHINE
using Cinemachine;
#endif
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this to a Cinemachine brain and it'll be able to accept custom blend transitions (used with MMFeedbackCinemachineTransition)
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MMCinemachinePriorityBrainListener")]
#if MM_CINEMACHINE
[RequireComponent(typeof(CinemachineBrain))]
#endif
public class MMCinemachinePriorityBrainListener : MonoBehaviour
{
[HideInInspector]
public TimescaleModes TimescaleMode = TimescaleModes.Scaled;
public virtual float GetTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; }
public virtual float GetDeltaTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.deltaTime : Time.unscaledDeltaTime; }
#if MM_CINEMACHINE
protected CinemachineBrain _brain;
protected CinemachineBlendDefinition _initialDefinition;
protected Coroutine _coroutine;
/// <summary>
/// On Awake we grab our brain
/// </summary>
protected virtual void Awake()
{
_brain = this.gameObject.GetComponent<CinemachineBrain>();
}
/// <summary>
/// When getting an event we change our default transition if needed
/// </summary>
/// <param name="channel"></param>
/// <param name="forceMaxPriority"></param>
/// <param name="newPriority"></param>
/// <param name="forceTransition"></param>
/// <param name="blendDefinition"></param>
/// <param name="resetValuesAfterTransition"></param>
public virtual void OnMMCinemachinePriorityEvent(MMChannelData channelData, bool forceMaxPriority, int newPriority, bool forceTransition, CinemachineBlendDefinition blendDefinition, bool resetValuesAfterTransition, TimescaleModes timescaleMode, bool restore = false)
{
if (forceTransition)
{
if (_coroutine != null)
{
StopCoroutine(_coroutine);
}
else
{
_initialDefinition = _brain.m_DefaultBlend;
}
_brain.m_DefaultBlend = blendDefinition;
TimescaleMode = timescaleMode;
_coroutine = StartCoroutine(ResetBlendDefinition(blendDefinition.m_Time));
}
}
/// <summary>
/// a coroutine used to reset the default transition to its initial value
/// </summary>
/// <param name="delay"></param>
/// <returns></returns>
protected virtual IEnumerator ResetBlendDefinition(float delay)
{
for (float timer = 0; timer < delay; timer += GetDeltaTime())
{
yield return null;
}
_brain.m_DefaultBlend = _initialDefinition;
_coroutine = null;
}
/// <summary>
/// On enable we start listening for events
/// </summary>
protected virtual void OnEnable()
{
_coroutine = null;
MMCinemachinePriorityEvent.Register(OnMMCinemachinePriorityEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
protected virtual void OnDisable()
{
if (_coroutine != null)
{
StopCoroutine(_coroutine);
}
_coroutine = null;
MMCinemachinePriorityEvent.Unregister(OnMMCinemachinePriorityEvent);
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,127 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if MM_CINEMACHINE
using Cinemachine;
#endif
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this to a Cinemachine virtual camera and it'll be able to listen to MMCinemachinePriorityEvent, usually triggered by a MMFeedbackCinemachineTransition
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MMCinemachinePriorityListener")]
#if MM_CINEMACHINE
[RequireComponent(typeof(CinemachineVirtualCameraBase))]
#endif
public class MMCinemachinePriorityListener : MonoBehaviour
{
[HideInInspector]
public TimescaleModes TimescaleMode = TimescaleModes.Scaled;
public virtual float GetTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; }
public virtual float GetDeltaTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.deltaTime : Time.unscaledDeltaTime; }
[Header("Priority Listener")]
[Tooltip("whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what. " +
"MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable")]
public MMChannelModes ChannelMode = MMChannelModes.Int;
/// the channel to listen to - has to match the one on the feedback
[Tooltip("the channel to listen to - has to match the one on the feedback")]
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.Int)]
public int Channel = 0;
/// the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel,
/// right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name
[Tooltip("the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel, " +
"right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name")]
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.MMChannel)]
public MMChannel MMChannelDefinition = null;
#if MM_CINEMACHINE
protected CinemachineVirtualCameraBase _camera;
protected int _initialPriority;
/// <summary>
/// On Awake we store our virtual camera
/// </summary>
protected virtual void Awake()
{
_camera = this.gameObject.GetComponent<CinemachineVirtualCameraBase>();
_initialPriority = _camera.Priority;
}
/// <summary>
/// When we get an event we change our priorities if needed
/// </summary>
/// <param name="channel"></param>
/// <param name="forceMaxPriority"></param>
/// <param name="newPriority"></param>
/// <param name="forceTransition"></param>
/// <param name="blendDefinition"></param>
/// <param name="resetValuesAfterTransition"></param>
public virtual void OnMMCinemachinePriorityEvent(MMChannelData channelData, bool forceMaxPriority, int newPriority, bool forceTransition, CinemachineBlendDefinition blendDefinition, bool resetValuesAfterTransition, TimescaleModes timescaleMode, bool restore = false)
{
TimescaleMode = timescaleMode;
if (MMChannel.Match(channelData, ChannelMode, Channel, MMChannelDefinition))
{
if (restore)
{
_camera.Priority = _initialPriority;
return;
}
_camera.Priority = newPriority;
}
else
{
if (forceMaxPriority)
{
if (restore)
{
_camera.Priority = _initialPriority;
return;
}
_camera.Priority = 0;
}
}
}
/// <summary>
/// On enable we start listening for events
/// </summary>
protected virtual void OnEnable()
{
MMCinemachinePriorityEvent.Register(OnMMCinemachinePriorityEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
protected virtual void OnDisable()
{
MMCinemachinePriorityEvent.Unregister(OnMMCinemachinePriorityEvent);
}
#endif
}
/// <summary>
/// An event used to pilot priorities on cinemachine virtual cameras and brain transitions
/// </summary>
public struct MMCinemachinePriorityEvent
{
#if MM_CINEMACHINE
static private event Delegate OnEvent;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void RuntimeInitialization() { OnEvent = null; }
static public void Register(Delegate callback) { OnEvent += callback; }
static public void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(MMChannelData channelData, bool forceMaxPriority, int newPriority, bool forceTransition, CinemachineBlendDefinition blendDefinition, bool resetValuesAfterTransition, TimescaleModes timescaleMode, bool restore = false);
static public void Trigger(MMChannelData channelData, bool forceMaxPriority, int newPriority, bool forceTransition, CinemachineBlendDefinition blendDefinition, bool resetValuesAfterTransition, TimescaleModes timescaleMode, bool restore = false)
{
OnEvent?.Invoke(channelData, forceMaxPriority, newPriority, forceTransition, blendDefinition, resetValuesAfterTransition, timescaleMode, restore);
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,222 @@
using UnityEngine;
#if MM_CINEMACHINE
using Cinemachine;
#endif
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This class will allow you to trigger zooms on your cinemachine camera by sending MMCameraZoomEvents from any other class
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MMCinemachineZoom")]
#if MM_CINEMACHINE
[RequireComponent(typeof(Cinemachine.CinemachineVirtualCamera))]
#endif
public class MMCinemachineZoom : MonoBehaviour
{
[Header("Channel")]
[MMFInspectorGroup("Shaker Settings", true, 3)]
/// whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what.
/// MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable
[Tooltip("whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what. " +
"MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable")]
public MMChannelModes ChannelMode = MMChannelModes.Int;
/// the channel to listen to - has to match the one on the feedback
[Tooltip("the channel to listen to - has to match the one on the feedback")]
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.Int)]
public int Channel = 0;
/// the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel,
/// right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name
[Tooltip("the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel, " +
"right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name")]
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.MMChannel)]
public MMChannel MMChannelDefinition = null;
[Header("Transition Speed")]
/// the animation curve to apply to the zoom transition
[Tooltip("the animation curve to apply to the zoom transition")]
public AnimationCurve ZoomCurve = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f));
[Header("Test Zoom")]
/// the mode to apply the zoom in when using the test button in the inspector
[Tooltip("the mode to apply the zoom in when using the test button in the inspector")]
public MMCameraZoomModes TestMode;
/// the target field of view to apply the zoom in when using the test button in the inspector
[Tooltip("the target field of view to apply the zoom in when using the test button in the inspector")]
public float TestFieldOfView = 30f;
/// the transition duration to apply the zoom in when using the test button in the inspector
[Tooltip("the transition duration to apply the zoom in when using the test button in the inspector")]
public float TestTransitionDuration = 0.1f;
/// the duration to apply the zoom in when using the test button in the inspector
[Tooltip("the duration to apply the zoom in when using the test button in the inspector")]
public float TestDuration = 0.05f;
[MMFInspectorButton("TestZoom")]
/// an inspector button to test the zoom in play mode
public bool TestZoomButton;
public virtual float GetTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; }
public virtual float GetDeltaTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.deltaTime : Time.unscaledDeltaTime; }
public TimescaleModes TimescaleMode { get; set; }
#if MM_CINEMACHINE
protected Cinemachine.CinemachineVirtualCamera _virtualCamera;
protected float _initialFieldOfView;
protected MMCameraZoomModes _mode;
protected bool _zooming = false;
protected float _startFieldOfView;
protected float _transitionDuration;
protected float _duration;
protected float _targetFieldOfView;
protected float _delta = 0f;
protected int _direction = 1;
protected float _reachedDestinationTimestamp;
protected bool _destinationReached = false;
/// <summary>
/// On Awake we grab our virtual camera
/// </summary>
protected virtual void Awake()
{
_virtualCamera = this.gameObject.GetComponent<Cinemachine.CinemachineVirtualCamera>();
_initialFieldOfView = _virtualCamera.m_Lens.FieldOfView;
}
/// <summary>
/// On Update if we're zooming we modify our field of view accordingly
/// </summary>
protected virtual void Update()
{
if (!_zooming)
{
return;
}
if (_virtualCamera.m_Lens.FieldOfView != _targetFieldOfView)
{
_delta += GetDeltaTime() / _transitionDuration;
_virtualCamera.m_Lens.FieldOfView = Mathf.LerpUnclamped(_startFieldOfView, _targetFieldOfView, ZoomCurve.Evaluate(_delta));
}
else
{
if (!_destinationReached)
{
_reachedDestinationTimestamp = GetTime();
_destinationReached = true;
}
if ((_mode == MMCameraZoomModes.For) && (_direction == 1))
{
if (GetTime() - _reachedDestinationTimestamp > _duration)
{
_direction = -1;
_startFieldOfView = _targetFieldOfView;
_targetFieldOfView = _initialFieldOfView;
_delta = 0f;
}
}
else
{
_zooming = false;
}
}
}
/// <summary>
/// A method that triggers the zoom, ideally only to be called via an event, but public for convenience
/// </summary>
/// <param name="mode"></param>
/// <param name="newFieldOfView"></param>
/// <param name="transitionDuration"></param>
/// <param name="duration"></param>
public virtual void Zoom(MMCameraZoomModes mode, float newFieldOfView, float transitionDuration, float duration, bool useUnscaledTime, bool relative = false)
{
if (_zooming)
{
return;
}
_zooming = true;
_delta = 0f;
_mode = mode;
TimescaleMode = useUnscaledTime ? TimescaleModes.Unscaled : TimescaleModes.Scaled;
_startFieldOfView = _virtualCamera.m_Lens.FieldOfView;
_transitionDuration = transitionDuration;
_duration = duration;
_transitionDuration = transitionDuration;
_direction = 1;
_destinationReached = false;
switch (mode)
{
case MMCameraZoomModes.For:
_targetFieldOfView = newFieldOfView;
break;
case MMCameraZoomModes.Set:
_targetFieldOfView = newFieldOfView;
break;
case MMCameraZoomModes.Reset:
_targetFieldOfView = _initialFieldOfView;
break;
}
if (relative)
{
_targetFieldOfView += _initialFieldOfView;
}
}
/// <summary>
/// The method used by the test button to trigger a test zoom
/// </summary>
protected virtual void TestZoom()
{
Zoom(TestMode, TestFieldOfView, TestTransitionDuration, TestDuration, false);
}
/// <summary>
/// When we get an MMCameraZoomEvent we call our zoom method
/// </summary>
/// <param name="zoomEvent"></param>
public virtual void OnCameraZoomEvent(MMCameraZoomModes mode, float newFieldOfView, float transitionDuration, float duration, MMChannelData channelData, bool useUnscaledTime, bool stop = false, bool relative = false, bool restore = false)
{
if (!MMChannel.Match(channelData, ChannelMode, Channel, MMChannelDefinition))
{
return;
}
if (stop)
{
_zooming = false;
return;
}
if (restore)
{
_virtualCamera.m_Lens.FieldOfView = _initialFieldOfView;
return;
}
this.Zoom(mode, newFieldOfView, transitionDuration, duration, useUnscaledTime, relative);
}
/// <summary>
/// Starts listening for MMCameraZoomEvents
/// </summary>
protected virtual void OnEnable()
{
MMCameraZoomEvent.Register(OnCameraZoomEvent);
}
/// <summary>
/// Stops listening for MMCameraZoomEvents
/// </summary>
protected virtual void OnDisable()
{
MMCameraZoomEvent.Unregister(OnCameraZoomEvent);
}
#endif
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,100 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control bloom intensity and threshold over time. It requires you have in your scene an object with a Volume with Bloom active, and a MMBloomShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback allows you to control bloom intensity and threshold over time. It requires you have in your scene an object with a Volume " +
"with Bloom active, and a MMBloomShaker_HDRP component.")]
[FeedbackPath("PostProcess/Bloom HDRP")]
public class MMFeedbackBloom_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("Bloom")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the feedback, in seconds
[Tooltip("the duration of the feedback, in seconds")]
public float ShakeDuration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeValues = true;
[Header("Intensity")]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapIntensityOne = 1f;
[Header("Threshold")]
/// the curve to animate the threshold on
[Tooltip("the curve to animate the threshold on")]
public AnimationCurve ShakeThreshold = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapThresholdZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapThresholdOne = 0f;
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(ShakeDuration); } set { ShakeDuration = value; } }
/// <summary>
/// Triggers a bloom shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float attenuation = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMBloomShakeEvent_HDRP.Trigger(ShakeIntensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, ShakeThreshold, RemapThresholdZero, RemapThresholdOne,
RelativeValues, attenuation, ChannelData(Channel), ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMBloomShakeEvent_HDRP.Trigger(ShakeIntensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, ShakeThreshold, RemapThresholdZero, RemapThresholdOne,
RelativeValues, channelData:ChannelData(Channel), stop:true);
}
}
}

View File

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

View File

@@ -0,0 +1,126 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control channel mixer's red, green and blue over time.
/// It requires you have in your scene an object with a Volume
/// with Channel Mixer active, and a MMChannelMixerShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("PostProcess/Channel Mixer HDRP")]
[FeedbackHelp("This feedback allows you to control channel mixer's red, green and blue over time." +
"It requires you have in your scene an object with a Volume" +
"with Channel Mixer active, and a MMChannelMixerShaker_HDRP component.")]
public class MMFeedbackChannelMixer_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("Color Grading")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float ShakeDuration = 1f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = true;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[Header("Red")]
/// the curve used to animate the red value on
[Tooltip("the curve used to animate the red value on")]
public AnimationCurve ShakeRed = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-200f, 200f)]
public float RemapRedZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-200f, 200f)]
public float RemapRedOne = 200f;
[Header("Green")]
/// the curve used to animate the green value on
[Tooltip("the curve used to animate the green value on")]
public AnimationCurve ShakeGreen = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-200f, 200f)]
public float RemapGreenZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-200f, 200f)]
public float RemapGreenOne = 200f;
[Header("Blue")]
/// the curve used to animate the blue value on
[Tooltip("the curve used to animate the blue value on")]
public AnimationCurve ShakeBlue = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-200f, 200f)]
public float RemapBlueZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-200f, 200f)]
public float RemapBlueOne = 200f;
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(ShakeDuration); } set { ShakeDuration = value; } }
/// <summary>
/// Triggers a color adjustments shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
MMChannelMixerShakeEvent_HDRP.Trigger(ShakeRed, RemapRedZero, RemapRedOne,
ShakeGreen, RemapGreenZero, RemapGreenOne,
ShakeBlue, RemapBlueZero, RemapBlueOne,
FeedbackDuration,
RelativeIntensity, intensityMultiplier, ChannelData(Channel), ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMChannelMixerShakeEvent_HDRP.Trigger(ShakeRed, RemapRedZero, RemapRedOne,
ShakeGreen, RemapGreenZero, RemapGreenOne,
ShakeBlue, RemapBlueZero, RemapBlueOne,
FeedbackDuration,
RelativeIntensity, channelData:ChannelData(Channel), stop:true);
}
}
}

View File

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

View File

@@ -0,0 +1,95 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control chromatic aberration intensity over time. It requires you have in your scene an object with a Volume
/// with HDRP Chromatic Aberration active, and a MMChromaticAberrationShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("PostProcess/Chromatic Aberration HDRP")]
[FeedbackHelp("This feedback allows you to control chromatic aberration intensity over time. It requires you have in your scene an object with a Volume " +
"with Chromatic Aberration active, and a MMChromaticAberrationShaker_HDRP component.")]
public class MMFeedbackChromaticAberration_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("Chromatic Aberration")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(0f, 1f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(0f, 1f)]
public float RemapIntensityOne = 1f;
[Header("Intensity")]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve Intensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the multiplier to apply to the intensity curve
[Tooltip("the multiplier to apply to the intensity curve")]
[Range(0f, 1f)]
public float Amplitude = 1.0f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = false;
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
/// <summary>
/// Triggers a chromatic aberration shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
MMChromaticAberrationShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, intensityMultiplier,
ChannelData(Channel), ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMChromaticAberrationShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, channelData:ChannelData(Channel), stop:true);
}
}
}

View File

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

View File

@@ -0,0 +1,167 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control color adjustments' post exposure, hue shift, saturation and contrast over time.
/// It requires you have in your scene an object with a Volume
/// with Color Adjustments active, and a MMColorAdjustmentsShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("PostProcess/Color Adjustments HDRP")]
[FeedbackHelp("This feedback allows you to control color adjustments' post exposure, hue shift, saturation and contrast over time. " +
"It requires you have in your scene an object with a Volume " +
"with Color Adjustments active, and a MMColorAdjustmentsShaker_HDRP component.")]
public class MMFeedbackColorAdjustments_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("Color Grading")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float ShakeDuration = 1f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = true;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[Header("Post Exposure")]
/// the curve used to animate the focus distance value on
[Tooltip("the curve used to animate the focus distance value on")]
public AnimationCurve ShakePostExposure = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapPostExposureZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapPostExposureOne = 1f;
[Header("Hue Shift")]
/// the curve used to animate the aperture value on
[Tooltip("the curve used to animate the aperture value on")]
public AnimationCurve ShakeHueShift = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-180f, 180f)]
public float RemapHueShiftZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-180f, 180f)]
public float RemapHueShiftOne = 180f;
[Header("Saturation")]
/// the curve used to animate the focal length value on
[Tooltip("the curve used to animate the focal length value on")]
public AnimationCurve ShakeSaturation = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapSaturationZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapSaturationOne = 100f;
[Header("Contrast")]
/// the curve used to animate the focal length value on
[Tooltip("the curve used to animate the focal length value on")]
public AnimationCurve ShakeContrast = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapContrastZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapContrastOne = 100f;
[Header("Color Filter")]
/// the selected color filter mode :
/// None : nothing will happen,
/// gradient : evaluates the color over time on that gradient, from left to right,
/// interpolate : lerps from the current color to the destination one
[Tooltip("the selected color filter mode :" +
"None : nothing will happen," +
"gradient : evaluates the color over time on that gradient, from left to right," +
"interpolate : lerps from the current color to the destination one ")]
public MMColorAdjustmentsShaker_HDRP.ColorFilterModes ColorFilterMode = MMColorAdjustmentsShaker_HDRP.ColorFilterModes.None;
/// the gradient to use to animate the color filter over time
[Tooltip("the gradient to use to animate the color filter over time")]
[MMFEnumCondition("ColorFilterMode", (int)MMColorAdjustmentsShaker_HDRP.ColorFilterModes.Gradient)]
[GradientUsage(true)]
public Gradient ColorFilterGradient;
/// the destination color when in interpolate mode
[Tooltip("the destination color when in interpolate mode")]
[MMFEnumCondition("ColorFilterMode", (int) MMColorAdjustmentsShaker_HDRP.ColorFilterModes.Interpolate)]
public Color ColorFilterDestination = Color.yellow;
/// the curve to use when interpolating towards the destination color
[Tooltip("the curve to use when interpolating towards the destination color")]
[MMFEnumCondition("ColorFilterMode", (int) MMColorAdjustmentsShaker_HDRP.ColorFilterModes.Interpolate)]
public AnimationCurve ColorFilterCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(ShakeDuration); } set { ShakeDuration = value; } }
/// <summary>
/// Triggers a color adjustments shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
MMColorAdjustmentsShakeEvent_HDRP.Trigger(ShakePostExposure, RemapPostExposureZero, RemapPostExposureOne,
ShakeHueShift, RemapHueShiftZero, RemapHueShiftOne,
ShakeSaturation, RemapSaturationZero, RemapSaturationOne,
ShakeContrast, RemapContrastZero, RemapContrastOne,
ColorFilterMode, ColorFilterGradient, ColorFilterDestination, ColorFilterCurve,
FeedbackDuration,
RelativeIntensity, intensityMultiplier, ChannelData(Channel), ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMColorAdjustmentsShakeEvent_HDRP.Trigger(ShakePostExposure, RemapPostExposureZero, RemapPostExposureOne,
ShakeHueShift, RemapHueShiftZero, RemapHueShiftOne,
ShakeSaturation, RemapSaturationZero, RemapSaturationOne,
ShakeContrast, RemapContrastZero, RemapContrastOne,
ColorFilterMode, ColorFilterGradient, ColorFilterDestination, ColorFilterCurve,
FeedbackDuration,
RelativeIntensity, channelData:ChannelData(Channel), stop:true);
}
}
}

View File

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

View File

@@ -0,0 +1,93 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control HDRP exposure intensity over time.
/// It requires you have in your scene an object with a Volume
/// with Exposure active, and a MMExposureShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("PostProcess/Exposure HDRP")]
[FeedbackHelp("This feedback allows you to control Exposure intensity over time. " +
"It requires you have in your scene an object with a Volume " +
"with Exposure active, and a MMExposureShaker_HDRP component.")]
public class MMFeedbackExposure_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("Exposure")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[Header("Intensity")]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve FixedExposure = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapFixedExposureZero = 8.5f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapFixedExposureOne = 6f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeFixedExposure = false;
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
/// <summary>
/// Triggers a Exposure shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
MMExposureShakeEvent_HDRP.Trigger(FixedExposure, FeedbackDuration, RemapFixedExposureZero, RemapFixedExposureOne, RelativeFixedExposure, intensityMultiplier,
ChannelData(Channel), ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMExposureShakeEvent_HDRP.Trigger(FixedExposure, FeedbackDuration, RemapFixedExposureZero, RemapFixedExposureOne, RelativeFixedExposure, channelData:ChannelData(Channel), stop:true);
}
}
}

View File

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

View File

@@ -0,0 +1,94 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control HDRP Film Grain intensity over time.
/// It requires you have in your scene an object with a Volume
/// with Film Grain active, and a MMFilmGrainShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("PostProcess/Film Grain HDRP")]
[FeedbackHelp("This feedback allows you to control Film Grain intensity over time. " +
"It requires you have in your scene an object with a Volume " +
"with Film Grain active, and a MMFilmGrainShaker_HDRP component.")]
public class MMFeedbackFilmGrain_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("Film Grain")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[Header("Intensity")]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve Intensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's zero to
[Tooltip("the value to remap the curve's zero to")]
[Range(0f, 1f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's one to
[Tooltip("the value to remap the curve's one to")]
[Range(0f, 1f)]
public float RemapIntensityOne = 1.0f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = false;
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
/// <summary>
/// Triggers a Film Grain shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
MMFilmGrainShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, intensityMultiplier,
ChannelData(Channel), ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMFilmGrainShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, channelData:ChannelData(Channel), stop:true);
}
}
}

View File

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

View File

@@ -0,0 +1,103 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control HDRP lens distortion intensity over time.
/// It requires you have in your scene an object with a Volume
/// with Lens Distortion active, and a MMLensDistortionShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("PostProcess/Lens Distortion HDRP")]
[FeedbackHelp("This feedback allows you to control HDRP lens distortion intensity over time. " +
"It requires you have in your scene an object with a Volume " +
"with Lens Distortion active, and a MMLensDistortionShaker_HDRP component.")]
public class MMFeedbackLensDistortion_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("Lens Distortion")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the shake in seconds
[Tooltip("the duration of the shake in seconds")]
public float Duration = 0.8f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[Header("Intensity")]
/// whether or not to add to the initial intensity value
[Tooltip("whether or not to add to the initial intensity value")]
public bool RelativeIntensity = false;
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve Intensity = new AnimationCurve(new Keyframe(0, 0),
new Keyframe(0.2f, 1),
new Keyframe(0.25f, -1),
new Keyframe(0.35f, 0.7f),
new Keyframe(0.4f, -0.7f),
new Keyframe(0.6f, 0.3f),
new Keyframe(0.65f, -0.3f),
new Keyframe(0.8f, 0.1f),
new Keyframe(0.85f, -0.1f),
new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapIntensityOne = 0.5f;
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
/// <summary>
/// Triggers a lens distortion shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
MMLensDistortionShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, intensityMultiplier,
ChannelData(Channel), ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMLensDistortionShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne,
RelativeIntensity, channelData: ChannelData(Channel), stop: true);
}
}
}

View File

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

View File

@@ -0,0 +1,91 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control HDRP motion blur intensity over time.
/// It requires you have in your scene an object with a Volume
/// with MotionBlur active, and a MMMotionBlurShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("PostProcess/Motion Blur HDRP")]
[FeedbackHelp("This feedback allows you to control motion blur intensity over time. " +
"It requires you have in your scene an object with a Volume " +
"with MotionBlur active, and a MMMotionBlurShaker_HDRP component.")]
public class MMFeedbackMotionBlur_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("Motion Blur")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[Header("Intensity")]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve Intensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to which to remap the curve's zero to
[Tooltip("the value to which to remap the curve's zero to")]
public float RemapIntensityZero = 0f;
/// the value to which to remap the curve's one to
[Tooltip("the value to which to remap the curve's one to")]
public float RemapIntensityOne = 1000f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = false;
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
/// <summary>
/// Triggers a motion blur shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
MMMotionBlurShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, intensityMultiplier,
ChannelData(Channel), ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMMotionBlurShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne,
RelativeIntensity, channelData:ChannelData(Channel), stop: true);
}
}
}

View File

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

View File

@@ -0,0 +1,91 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control Panini Projection distance and crop to fit over time.
/// It requires you have in your scene an object with a Volume with Bloom active, and a MMPaniniProjectionShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback allows you to control Panini Projection distance and crop to fit over time. " +
"It requires you have in your scene an object with a Volume " +
"with PaniniProjection active, and a MMPaniniProjectionShaker_HDRP component.")]
[FeedbackPath("PostProcess/Panini Projection HDRP")]
public class MMFeedbackPaniniProjection_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("Panini Projection")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[Header("Distance")]
/// whether or not to add to the initial value
[Tooltip("whether or not to add to the initial value")]
public bool RelativeDistance = false;
/// the curve used to animate the distance value on
[Tooltip("the curve used to animate the distance value on")]
public AnimationCurve ShakeDistance = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(0f, 1f)]
public float RemapDistanceZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(0f, 1f)]
public float RemapDistanceOne = 1f;
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
/// <summary>
/// Triggers a bloom shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
MMPaniniProjectionShakeEvent_HDRP.Trigger(ShakeDistance, FeedbackDuration, RemapDistanceZero, RemapDistanceOne, RelativeDistance, intensityMultiplier, ChannelData(Channel),
ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMPaniniProjectionShakeEvent_HDRP.Trigger(ShakeDistance, FeedbackDuration, RemapDistanceZero, RemapDistanceOne, RelativeDistance, channelData:ChannelData(Channel), stop:true);
}
}
}

View File

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

View File

@@ -0,0 +1,92 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control HDRP vignette intensity over time.
/// It requires you have in your scene an object with a Volume
/// with Vignette active, and a MMVignetteShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("PostProcess/Vignette HDRP")]
[FeedbackHelp("This feedback allows you to control vignette intensity over time. " +
"It requires you have in your scene an object with a Volume " +
"with Vignette active, and a MMVignetteShaker_HDRP component.")]
public class MMFeedbackVignette_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("Vignette")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[Header("Intensity")]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve Intensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's zero to
[Tooltip("the value to remap the curve's zero to")]
[Range(0f, 1f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's one to
[Tooltip("the value to remap the curve's one to")]
[Range(0f, 1f)]
public float RemapIntensityOne = 1.0f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = false;
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
/// <summary>
/// Triggers a vignette shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
MMVignetteShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, intensityMultiplier,
ChannelData(Channel), ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMVignetteShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, channelData:ChannelData(Channel), stop:true);
}
}
}

View File

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

View File

@@ -0,0 +1,105 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control white balance temperature and tint over time.
/// It requires you have in your scene an object with a Volume with White Balance active, and a MMWhiteBalanceShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback allows you to control white balance temperature and tint over time. " +
"It requires you have in your scene an object with a Volume " +
"with WhiteBalance active, and a MMWhiteBalanceShaker_HDRP component.")]
[FeedbackPath("PostProcess/White Balance HDRP")]
public class MMFeedbackWhiteBalance_HDRP : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
[Header("White Balance")]
/// the channel to emit on
[Tooltip("the channel to emit on")]
public int Channel = 0;
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float ShakeDuration = 1f;
/// whether or not to add to the initial value
[Tooltip("whether or not to add to the initial value")]
public bool RelativeValues = true;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[Header("Temperature")]
/// the curve used to animate the temperature value on
[Tooltip("the curve used to animate the temperature value on")]
public AnimationCurve ShakeTemperature = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapTemperatureZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapTemperatureOne = 100f;
[Header("Tint")]
/// the curve used to animate the tint value on
[Tooltip("the curve used to animate the tint value on")]
public AnimationCurve ShakeTint = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapTintZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapTintOne = 100f;
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(ShakeDuration); } set { ShakeDuration = value; } }
/// <summary>
/// Triggers a white balance shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
MMWhiteBalanceShakeEvent_HDRP.Trigger(ShakeTemperature, FeedbackDuration, RemapTemperatureZero, RemapTemperatureOne,
ShakeTint, RemapTintZero, RemapTintOne, RelativeValues, intensityMultiplier,
ChannelData(Channel), ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, Timing.TimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMWhiteBalanceShakeEvent_HDRP.Trigger(ShakeTemperature, FeedbackDuration, RemapTemperatureZero, RemapTemperatureOne,
ShakeTint, RemapTintZero, RemapTintOne, RelativeValues, channelData:ChannelData(Channel), stop:true);
}
}
}

View File

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

View File

@@ -0,0 +1,117 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control bloom intensity and threshold over time. It requires you have in your scene an object with a Volume with Bloom active, and a MMBloomShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback allows you to control bloom intensity and threshold over time. It requires you have in your scene an object with a Volume " +
"with Bloom active, and a MMBloomShaker_HDRP component.")]
#if MM_HDRP
[FeedbackPath("PostProcess/Bloom HDRP")]
#endif
public class MMF_Bloom_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(ShakeDuration); } set { ShakeDuration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("Bloom", true, 3)]
/// the duration of the feedback, in seconds
[Tooltip("the duration of the feedback, in seconds")]
public float ShakeDuration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeValues = true;
[MMFInspectorGroup("Intensity", true, 4)]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapIntensityOne = 1f;
[MMFInspectorGroup("Threshold", true, 5)]
/// the curve to animate the threshold on
[Tooltip("the curve to animate the threshold on")]
public AnimationCurve ShakeThreshold = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapThresholdZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapThresholdOne = 0f;
/// <summary>
/// Triggers a bloom shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float attenuation = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
attenuation = ComputeIntensity(attenuation, position);
MMBloomShakeEvent_HDRP.Trigger(ShakeIntensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, ShakeThreshold, RemapThresholdZero, RemapThresholdOne,
RelativeValues, attenuation, ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMBloomShakeEvent_HDRP.Trigger(ShakeIntensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, ShakeThreshold, RemapThresholdZero, RemapThresholdOne,
RelativeValues, channelData:ChannelData, stop:true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMBloomShakeEvent_HDRP.Trigger(ShakeIntensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, ShakeThreshold, RemapThresholdZero, RemapThresholdOne,
RelativeValues, channelData:ChannelData, restore:true);
}
}
}

View File

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

View File

@@ -0,0 +1,141 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control channel mixer's red, green and blue over time.
/// It requires you have in your scene an object with a Volume
/// with Channel Mixer active, and a MMChannelMixerShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
#if MM_HDRP
[FeedbackPath("PostProcess/Channel Mixer HDRP")]
#endif
[FeedbackHelp("This feedback allows you to control channel mixer's red, green and blue over time." +
"It requires you have in your scene an object with a Volume" +
"with Channel Mixer active, and a MM Channel Mixer HDRP component.")]
public class MMF_ChannelMixer_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(ShakeDuration); } set { ShakeDuration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("Color Grading", true, 10)]
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float ShakeDuration = 1f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = true;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[MMFInspectorGroup("Red", true, 13)]
/// the curve used to animate the red value on
[Tooltip("the curve used to animate the red value on")]
public AnimationCurve ShakeRed = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-200f, 200f)]
public float RemapRedZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-200f, 200f)]
public float RemapRedOne = 200f;
[MMFInspectorGroup("Green", true, 12)]
/// the curve used to animate the green value on
[Tooltip("the curve used to animate the green value on")]
public AnimationCurve ShakeGreen = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-200f, 200f)]
public float RemapGreenZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-200f, 200f)]
public float RemapGreenOne = 200f;
[MMFInspectorGroup("Blue", true, 11)]
/// the curve used to animate the blue value on
[Tooltip("the curve used to animate the blue value on")]
public AnimationCurve ShakeBlue = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-200f, 200f)]
public float RemapBlueZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-200f, 200f)]
public float RemapBlueOne = 200f;
/// <summary>
/// Triggers a color adjustments shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
MMChannelMixerShakeEvent_HDRP.Trigger(ShakeRed, RemapRedZero, RemapRedOne,
ShakeGreen, RemapGreenZero, RemapGreenOne,
ShakeBlue, RemapBlueZero, RemapBlueOne,
FeedbackDuration,
RelativeIntensity, intensityMultiplier, ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMChannelMixerShakeEvent_HDRP.Trigger(ShakeRed, RemapRedZero, RemapRedOne,
ShakeGreen, RemapGreenZero, RemapGreenOne,
ShakeBlue, RemapBlueZero, RemapBlueOne,
FeedbackDuration,
RelativeIntensity, channelData:ChannelData, stop:true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMChannelMixerShakeEvent_HDRP.Trigger(ShakeRed, RemapRedZero, RemapRedOne,
ShakeGreen, RemapGreenZero, RemapGreenOne,
ShakeBlue, RemapBlueZero, RemapBlueOne,
FeedbackDuration,
RelativeIntensity, channelData:ChannelData, restore:true);
}
}
}

View File

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

View File

@@ -0,0 +1,109 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control chromatic aberration intensity over time. It requires you have in your scene an object with a Volume
/// with HDRP Chromatic Aberration active, and a MMChromaticAberrationShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
#if MM_HDRP
[FeedbackPath("PostProcess/Chromatic Aberration HDRP")]
#endif
[FeedbackHelp("This feedback allows you to control chromatic aberration intensity over time. It requires you have in your scene an object with a Volume " +
"with Chromatic Aberration active, and a MMChromaticAberrationShaker_HDRP component.")]
public class MMF_ChromaticAberration_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("Chromatic Aberration", true, 10)]
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(0f, 1f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(0f, 1f)]
public float RemapIntensityOne = 1f;
[MMFInspectorGroup("Intensity", true, 11)]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve Intensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the multiplier to apply to the intensity curve
[Tooltip("the multiplier to apply to the intensity curve")]
[Range(0f, 1f)]
public float Amplitude = 1.0f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = false;
/// <summary>
/// Triggers a chromatic aberration shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
MMChromaticAberrationShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, intensityMultiplier,
ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMChromaticAberrationShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, channelData:ChannelData, stop:true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMChromaticAberrationShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, channelData:ChannelData, restore:true);
}
}
}

View File

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

View File

@@ -0,0 +1,187 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control color adjustments' post exposure, hue shift, saturation and contrast over time.
/// It requires you have in your scene an object with a Volume
/// with Color Adjustments active, and a MMColorAdjustmentsShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
#if MM_HDRP
[FeedbackPath("PostProcess/Color Adjustments HDRP")]
#endif
[FeedbackHelp("This feedback allows you to control color adjustments' post exposure, hue shift, saturation and contrast over time. " +
"It requires you have in your scene an object with a Volume " +
"with Color Adjustments active, and a MMColorAdjustmentsShaker_HDRP component.")]
public class MMF_ColorAdjustments_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(ShakeDuration); } set { ShakeDuration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("Color Grading", true, 16)]
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float ShakeDuration = 1f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = true;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[MMFInspectorGroup("Post Exposure", true, 15)]
/// the curve used to animate the focus distance value on
[Tooltip("the curve used to animate the focus distance value on")]
public AnimationCurve ShakePostExposure = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapPostExposureZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapPostExposureOne = 1f;
[MMFInspectorGroup("Hue Shift", true, 14)]
/// the curve used to animate the aperture value on
[Tooltip("the curve used to animate the aperture value on")]
public AnimationCurve ShakeHueShift = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-180f, 180f)]
public float RemapHueShiftZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-180f, 180f)]
public float RemapHueShiftOne = 180f;
[MMFInspectorGroup("Saturation", true, 13)]
/// the curve used to animate the focal length value on
[Tooltip("the curve used to animate the focal length value on")]
public AnimationCurve ShakeSaturation = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapSaturationZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapSaturationOne = 100f;
[MMFInspectorGroup("Contrast", true, 12)]
/// the curve used to animate the focal length value on
[Tooltip("the curve used to animate the focal length value on")]
public AnimationCurve ShakeContrast = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapContrastZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapContrastOne = 100f;
[Header("Color Filter")]
/// the selected color filter mode :
/// None : nothing will happen,
/// gradient : evaluates the color over time on that gradient, from left to right,
/// interpolate : lerps from the current color to the destination one
[Tooltip("the selected color filter mode :" +
"None : nothing will happen," +
"gradient : evaluates the color over time on that gradient, from left to right," +
"interpolate : lerps from the current color to the destination one ")]
public MMColorAdjustmentsShaker_HDRP.ColorFilterModes ColorFilterMode = MMColorAdjustmentsShaker_HDRP.ColorFilterModes.None;
/// the gradient to use to animate the color filter over time
[Tooltip("the gradient to use to animate the color filter over time")]
[MMFEnumCondition("ColorFilterMode", (int)MMColorAdjustmentsShaker_HDRP.ColorFilterModes.Gradient)]
[GradientUsage(true)]
public Gradient ColorFilterGradient;
/// the destination color when in interpolate mode
[Tooltip("the destination color when in interpolate mode")]
[MMFEnumCondition("ColorFilterMode", (int) MMColorAdjustmentsShaker_HDRP.ColorFilterModes.Interpolate)]
public Color ColorFilterDestination = Color.yellow;
/// the curve to use when interpolating towards the destination color
[Tooltip("the curve to use when interpolating towards the destination color")]
[MMFEnumCondition("ColorFilterMode", (int) MMColorAdjustmentsShaker_HDRP.ColorFilterModes.Interpolate)]
public AnimationCurve ColorFilterCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// <summary>
/// Triggers a color adjustments shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
MMColorAdjustmentsShakeEvent_HDRP.Trigger(ShakePostExposure, RemapPostExposureZero, RemapPostExposureOne,
ShakeHueShift, RemapHueShiftZero, RemapHueShiftOne,
ShakeSaturation, RemapSaturationZero, RemapSaturationOne,
ShakeContrast, RemapContrastZero, RemapContrastOne,
ColorFilterMode, ColorFilterGradient, ColorFilterDestination, ColorFilterCurve,
FeedbackDuration,
RelativeIntensity, intensityMultiplier, ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMColorAdjustmentsShakeEvent_HDRP.Trigger(ShakePostExposure, RemapPostExposureZero, RemapPostExposureOne,
ShakeHueShift, RemapHueShiftZero, RemapHueShiftOne,
ShakeSaturation, RemapSaturationZero, RemapSaturationOne,
ShakeContrast, RemapContrastZero, RemapContrastOne,
ColorFilterMode, ColorFilterGradient, ColorFilterDestination, ColorFilterCurve,
FeedbackDuration,
RelativeIntensity, channelData:ChannelData, stop:true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMColorAdjustmentsShakeEvent_HDRP.Trigger(ShakePostExposure, RemapPostExposureZero, RemapPostExposureOne,
ShakeHueShift, RemapHueShiftZero, RemapHueShiftOne,
ShakeSaturation, RemapSaturationZero, RemapSaturationOne,
ShakeContrast, RemapContrastZero, RemapContrastOne,
ColorFilterMode, ColorFilterGradient, ColorFilterDestination, ColorFilterCurve,
FeedbackDuration,
RelativeIntensity, channelData:ChannelData, restore:true);
}
}
}

View File

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

View File

@@ -0,0 +1,108 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control HDRP exposure intensity over time.
/// It requires you have in your scene an object with a Volume
/// with Exposure active, and a MMExposureShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
#if MM_HDRP
[FeedbackPath("PostProcess/Exposure HDRP")]
#endif
[FeedbackHelp("This feedback allows you to control Exposure intensity over time. " +
"It requires you have in your scene an object with a Volume " +
"with Exposure active, and a MMExposureShaker_HDRP component.")]
public class MMF_Exposure_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("Exposure", true, 17)]
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[MMFInspectorGroup("Intensity", true, 18)]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve FixedExposure = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapFixedExposureZero = 8.5f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapFixedExposureOne = 6f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeFixedExposure = false;
/// <summary>
/// Triggers a Exposure shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
MMExposureShakeEvent_HDRP.Trigger(FixedExposure, FeedbackDuration, RemapFixedExposureZero, RemapFixedExposureOne, RelativeFixedExposure, intensityMultiplier,
ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMExposureShakeEvent_HDRP.Trigger(FixedExposure, FeedbackDuration, RemapFixedExposureZero,
RemapFixedExposureOne, RelativeFixedExposure, channelData:ChannelData, stop:true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMExposureShakeEvent_HDRP.Trigger(FixedExposure, FeedbackDuration, RemapFixedExposureZero,
RemapFixedExposureOne, RelativeFixedExposure, channelData:ChannelData, restore:true);
}
}
}

View File

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

View File

@@ -0,0 +1,107 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control HDRP Film Grain intensity over time.
/// It requires you have in your scene an object with a Volume
/// with Film Grain active, and a MMFilmGrainShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
#if MM_HDRP
[FeedbackPath("PostProcess/Film Grain HDRP")]
#endif
[FeedbackHelp("This feedback allows you to control Film Grain intensity over time. " +
"It requires you have in your scene an object with a Volume " +
"with Film Grain active, and a MMFilmGrainShaker_HDRP component.")]
public class MMF_FilmGrain_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("Film Grain", true, 20)]
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[MMFInspectorGroup("Intensity", true, 21)]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve Intensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's zero to
[Tooltip("the value to remap the curve's zero to")]
[Range(0f, 1f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's one to
[Tooltip("the value to remap the curve's one to")]
[Range(0f, 1f)]
public float RemapIntensityOne = 1.0f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = false;
/// <summary>
/// Triggers a Film Grain shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
MMFilmGrainShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, intensityMultiplier,
ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMFilmGrainShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, channelData:ChannelData, stop:true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMFilmGrainShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, channelData:ChannelData, restore:true);
}
}
}

View File

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

View File

@@ -0,0 +1,118 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control HDRP lens distortion intensity over time.
/// It requires you have in your scene an object with a Volume
/// with Lens Distortion active, and a MMLensDistortionShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
#if MM_HDRP
[FeedbackPath("PostProcess/Lens Distortion HDRP")]
#endif
[FeedbackHelp("This feedback allows you to control HDRP lens distortion intensity over time. " +
"It requires you have in your scene an object with a Volume " +
"with Lens Distortion active, and a MMLensDistortionShaker_HDRP component.")]
public class MMF_LensDistortion_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("Lens Distortion", true, 22)]
/// the duration of the shake in seconds
[Tooltip("the duration of the shake in seconds")]
public float Duration = 0.8f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[MMFInspectorGroup("Intensity", true, 23)]
/// whether or not to add to the initial intensity value
[Tooltip("whether or not to add to the initial intensity value")]
public bool RelativeIntensity = false;
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve Intensity = new AnimationCurve(new Keyframe(0, 0),
new Keyframe(0.2f, 1),
new Keyframe(0.25f, -1),
new Keyframe(0.35f, 0.7f),
new Keyframe(0.4f, -0.7f),
new Keyframe(0.6f, 0.3f),
new Keyframe(0.65f, -0.3f),
new Keyframe(0.8f, 0.1f),
new Keyframe(0.85f, -0.1f),
new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-1f, 1f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-1f, 1f)]
public float RemapIntensityOne = 0.5f;
/// <summary>
/// Triggers a lens distortion shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
MMLensDistortionShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, intensityMultiplier,
ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMLensDistortionShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne,
RelativeIntensity, channelData:ChannelData, stop: true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMLensDistortionShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne,
RelativeIntensity, channelData:ChannelData, restore: true);
}
}
}

View File

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

View File

@@ -0,0 +1,106 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control HDRP motion blur intensity over time.
/// It requires you have in your scene an object with a Volume
/// with MotionBlur active, and a MMMotionBlurShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
#if MM_HDRP
[FeedbackPath("PostProcess/Motion Blur HDRP")]
#endif
[FeedbackHelp("This feedback allows you to control motion blur intensity over time. " +
"It requires you have in your scene an object with a Volume " +
"with MotionBlur active, and a MMMotionBlurShaker_HDRP component.")]
public class MMF_MotionBlur_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("Motion Blur", true, 24)]
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[MMFInspectorGroup("Intensity", true, 25)]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve Intensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to which to remap the curve's zero to
[Tooltip("the value to which to remap the curve's zero to")]
public float RemapIntensityZero = 0f;
/// the value to which to remap the curve's one to
[Tooltip("the value to which to remap the curve's one to")]
public float RemapIntensityOne = 1000f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = false;
/// <summary>
/// Triggers a motion blur shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
MMMotionBlurShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, intensityMultiplier,
ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMMotionBlurShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne,
RelativeIntensity, channelData:ChannelData, stop: true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMMotionBlurShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne,
RelativeIntensity, channelData:ChannelData, restore: true);
}
}
}

View File

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

View File

@@ -0,0 +1,104 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control Panini Projection distance and crop to fit over time.
/// It requires you have in your scene an object with a Volume with Bloom active, and a MMPaniniProjectionShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback allows you to control Panini Projection distance and crop to fit over time. " +
"It requires you have in your scene an object with a Volume " +
"with PaniniProjection active, and a MMPaniniProjectionShaker_HDRP component.")]
#if MM_HDRP
[FeedbackPath("PostProcess/Panini Projection HDRP")]
#endif
public class MMF_PaniniProjection_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("Panini Projection", true, 26)]
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[MMFInspectorGroup("Distance", true, 27)]
/// whether or not to add to the initial value
[Tooltip("whether or not to add to the initial value")]
public bool RelativeDistance = false;
/// the curve used to animate the distance value on
[Tooltip("the curve used to animate the distance value on")]
public AnimationCurve ShakeDistance = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(0f, 1f)]
public float RemapDistanceZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(0f, 1f)]
public float RemapDistanceOne = 1f;
/// <summary>
/// Triggers a bloom shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
MMPaniniProjectionShakeEvent_HDRP.Trigger(ShakeDistance, FeedbackDuration, RemapDistanceZero, RemapDistanceOne, RelativeDistance, intensityMultiplier, ChannelData,
ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMPaniniProjectionShakeEvent_HDRP.Trigger(ShakeDistance, FeedbackDuration, RemapDistanceZero, RemapDistanceOne, RelativeDistance, channelData:ChannelData, stop:true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMPaniniProjectionShakeEvent_HDRP.Trigger(ShakeDistance, FeedbackDuration, RemapDistanceZero, RemapDistanceOne, RelativeDistance, channelData:ChannelData, restore:true);
}
}
}

View File

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

View File

@@ -0,0 +1,105 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control HDRP vignette intensity over time.
/// It requires you have in your scene an object with a Volume
/// with Vignette active, and a MMVignetteShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
#if MM_HDRP
[FeedbackPath("PostProcess/Vignette HDRP")]
#endif
[FeedbackHelp("This feedback allows you to control vignette intensity over time. " +
"It requires you have in your scene an object with a Volume " +
"with Vignette active, and a MMVignetteShaker_HDRP component.")]
public class MMF_Vignette_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("Vignette", true, 28)]
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 0.2f;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[MMFInspectorGroup("Intensity", true, 29)]
/// the curve to animate the intensity on
[Tooltip("the curve to animate the intensity on")]
public AnimationCurve Intensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's zero to
[Tooltip("the value to remap the curve's zero to")]
[Range(0f, 1f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's one to
[Tooltip("the value to remap the curve's one to")]
[Range(0f, 1f)]
public float RemapIntensityOne = 1.0f;
/// whether or not to add to the initial intensity
[Tooltip("whether or not to add to the initial intensity")]
public bool RelativeIntensity = false;
/// <summary>
/// Triggers a vignette shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
MMVignetteShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, intensityMultiplier,
ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMVignetteShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, channelData:ChannelData, stop:true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMVignetteShakeEvent_HDRP.Trigger(Intensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, channelData:ChannelData, restore:true);
}
}
}

View File

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

View File

@@ -0,0 +1,120 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// This feedback allows you to control white balance temperature and tint over time.
/// It requires you have in your scene an object with a Volume with White Balance active, and a MMWhiteBalanceShaker_HDRP component.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback allows you to control white balance temperature and tint over time. " +
"It requires you have in your scene an object with a Volume " +
"with WhiteBalance active, and a MMWhiteBalanceShaker_HDRP component.")]
#if MM_HDRP
[FeedbackPath("PostProcess/White Balance HDRP")]
#endif
public class MMF_WhiteBalance_HDRP : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
#endif
/// the duration of this feedback is the duration of the shake
public override float FeedbackDuration { get { return ApplyTimeMultiplier(ShakeDuration); } set { ShakeDuration = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
[MMFInspectorGroup("White Balance", true, 32)]
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float ShakeDuration = 1f;
/// whether or not to add to the initial value
[Tooltip("whether or not to add to the initial value")]
public bool RelativeValues = true;
/// whether or not to reset shaker values after shake
[Tooltip("whether or not to reset shaker values after shake")]
public bool ResetShakerValuesAfterShake = true;
/// whether or not to reset the target's values after shake
[Tooltip("whether or not to reset the target's values after shake")]
public bool ResetTargetValuesAfterShake = true;
[MMFInspectorGroup("Temperature", true, 33)]
/// the curve used to animate the temperature value on
[Tooltip("the curve used to animate the temperature value on")]
public AnimationCurve ShakeTemperature = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapTemperatureZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapTemperatureOne = 100f;
[MMFInspectorGroup("Tint", true, 34)]
/// the curve used to animate the tint value on
[Tooltip("the curve used to animate the tint value on")]
public AnimationCurve ShakeTint = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapTintZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapTintOne = 100f;
/// <summary>
/// Triggers a white balance shake
/// </summary>
/// <param name="position"></param>
/// <param name="attenuation"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
MMWhiteBalanceShakeEvent_HDRP.Trigger(ShakeTemperature, FeedbackDuration, RemapTemperatureZero, RemapTemperatureOne,
ShakeTint, RemapTintZero, RemapTintOne, RelativeValues, intensityMultiplier,
ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake, NormalPlayDirection, ComputedTimescaleMode);
}
/// <summary>
/// On stop we stop our transition
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMWhiteBalanceShakeEvent_HDRP.Trigger(ShakeTemperature, FeedbackDuration, RemapTemperatureZero, RemapTemperatureOne,
ShakeTint, RemapTintZero, RemapTintOne, RelativeValues, channelData:ChannelData, stop:true);
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMWhiteBalanceShakeEvent_HDRP.Trigger(ShakeTemperature, FeedbackDuration, RemapTemperatureZero, RemapTemperatureOne,
ShakeTint, RemapTintZero, RemapTintOne, RelativeValues, channelData:ChannelData, restore:true);
}
}
}

View File

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

View File

@@ -0,0 +1,24 @@
{
"name": "MoreMountains.Feedbacks.HDRP",
"references": [
"GUID:457756d89b35d2941b3e7b37b4ece6f1",
"GUID:df380645f10b7bc4b97d4f5eb6303d95",
"GUID:8087d854c1f812e4b9a74437dfc524e0",
"GUID:4a1cb1490dc4df8409b2580d6b44e75e"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [
{
"name": "com.unity.render-pipelines.high-definition",
"expression": "1.0.0",
"define": "MM_HDRP"
}
],
"noEngineReferences": false
}

View File

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

View File

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

View File

@@ -0,0 +1,222 @@
using UnityEngine;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
using UnityEngine.Rendering;
#if MM_HDRP
using UnityEngine.Rendering.HighDefinition;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this class to a Camera with a HDRP bloom post processing and it'll be able to "shake" its values by getting events
/// </summary>
#if MM_HDRP
[RequireComponent(typeof(Volume))]
#endif
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MMBloomShaker_HDRP")]
public class MMBloomShaker_HDRP : MMShaker
{
/// whether or not to add to the initial value
public bool RelativeValues = true;
[MMInspectorGroup("Bloom Intensity", true, 42)]
/// the curve used to animate the intensity value on
[Tooltip("the curve used to animate the intensity value on")]
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapIntensityOne = 1f;
[MMInspectorGroup("Bloom Threshold", true, 43)]
/// the curve used to animate the threshold value on
[Tooltip("the curve used to animate the threshold value on")]
public AnimationCurve ShakeThreshold = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapThresholdZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapThresholdOne = 0f;
#if MM_HDRP
protected Volume _volume;
protected Bloom _bloom;
protected float _initialIntensity;
protected float _initialThreshold;
protected float _originalShakeDuration;
protected bool _originalRelativeIntensity;
protected AnimationCurve _originalShakeIntensity;
protected float _originalRemapIntensityZero;
protected float _originalRemapIntensityOne;
protected AnimationCurve _originalShakeThreshold;
protected float _originalRemapThresholdZero;
protected float _originalRemapThresholdOne;
/// <summary>
/// On init we initialize our values
/// </summary>
protected override void Initialization()
{
base.Initialization();
_volume = this.gameObject.GetComponent<Volume>();
_volume.profile.TryGet(out _bloom);
}
/// <summary>
/// Shakes values over time
/// </summary>
protected override void Shake()
{
float newIntensity = ShakeFloat(ShakeIntensity, RemapIntensityZero, RemapIntensityOne, RelativeValues, _initialIntensity);
_bloom.intensity.Override(newIntensity);
float newThreshold = ShakeFloat(ShakeThreshold, RemapThresholdZero, RemapThresholdOne, RelativeValues, _initialThreshold);
_bloom.threshold.Override(newThreshold);
}
/// <summary>
/// Collects initial values on the target
/// </summary>
protected override void GrabInitialValues()
{
_initialIntensity = _bloom.intensity.value;
_initialThreshold = _bloom.threshold.value;
}
/// <summary>
/// When we get the appropriate event, we trigger a shake
/// </summary>
/// <param name="intensity"></param>
/// <param name="duration"></param>
/// <param name="amplitude"></param>
/// <param name="relativeIntensity"></param>
/// <param name="attenuation"></param>
/// <param name="channel"></param>
public virtual void OnBloomShakeEvent(AnimationCurve intensity, float duration, float remapMin, float remapMax,
AnimationCurve threshold, float remapThresholdMin, float remapThresholdMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true,
bool resetTargetValuesAfterShake = true, bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled,
bool stop = false, bool restore = false)
{
if (!CheckEventAllowed(channelData) || (!Interruptible && Shaking))
{
return;
}
if (stop)
{
Stop();
return;
}
if (restore)
{
ResetTargetValues();
return;
}
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeIntensity = ShakeIntensity;
_originalRemapIntensityZero = RemapIntensityZero;
_originalRemapIntensityOne = RemapIntensityOne;
_originalRelativeIntensity = RelativeValues;
_originalShakeThreshold = ShakeThreshold;
_originalRemapThresholdZero = RemapThresholdZero;
_originalRemapThresholdOne = RemapThresholdOne;
}
TimescaleMode = timescaleMode;
ShakeDuration = duration;
ShakeIntensity = intensity;
RemapIntensityZero = remapMin * attenuation;
RemapIntensityOne = remapMax * attenuation;
RelativeValues = relativeIntensity;
ShakeThreshold = threshold;
RemapThresholdZero = remapThresholdMin;
RemapThresholdOne = remapThresholdMax;
ForwardDirection = forwardDirection;
Play();
}
/// <summary>
/// Resets the target's values
/// </summary>
protected override void ResetTargetValues()
{
base.ResetTargetValues();
_bloom.intensity.Override(_initialIntensity);
_bloom.threshold.Override(_initialThreshold);
}
/// <summary>
/// Resets the shaker's values
/// </summary>
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeIntensity = _originalShakeIntensity;
RemapIntensityZero = _originalRemapIntensityZero;
RemapIntensityOne = _originalRemapIntensityOne;
RelativeValues = _originalRelativeIntensity;
ShakeThreshold = _originalShakeThreshold;
RemapThresholdZero = _originalRemapThresholdZero;
RemapThresholdOne = _originalRemapThresholdOne;
}
/// <summary>
/// Starts listening for events
/// </summary>
public override void StartListening()
{
base.StartListening();
MMBloomShakeEvent_HDRP.Register(OnBloomShakeEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
public override void StopListening()
{
base.StopListening();
MMBloomShakeEvent_HDRP.Unregister(OnBloomShakeEvent);
}
#endif
}
/// <summary>
/// An event used to trigger vignette shakes
/// </summary>
public struct MMBloomShakeEvent_HDRP
{
static private event Delegate OnEvent;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void RuntimeInitialization() { OnEvent = null; }
static public void Register(Delegate callback) { OnEvent += callback; }
static public void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(AnimationCurve intensity, float duration, float remapMin, float remapMax,
AnimationCurve threshold, float remapThresholdMin, float remapThresholdMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true,
bool resetTargetValuesAfterShake = true, bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled,
bool stop = false, bool restore = false);
static public void Trigger(AnimationCurve intensity, float duration, float remapMin, float remapMax,
AnimationCurve threshold, float remapThresholdMin, float remapThresholdMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true,
bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
OnEvent?.Invoke(intensity, duration, remapMin, remapMax, threshold, remapThresholdMin, remapThresholdMax, relativeIntensity,
attenuation, channelData, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore);
}
}
}

View File

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

View File

@@ -0,0 +1,274 @@
using UnityEngine;
using UnityEngine.Rendering;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
#if MM_HDRP
using UnityEngine.Rendering.HighDefinition;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this class to a Camera with a HDRP color adjustments post processing and it'll be able to "shake" its values by getting events
/// </summary>
#if MM_HDRP
[RequireComponent(typeof(Volume))]
#endif
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MMChannelMixerShaker_HDRP")]
public class MMChannelMixerShaker_HDRP : MMShaker
{
/// whether or not to add to the initial value
public bool RelativeValues = true;
[MMInspectorGroup("Red", true, 42)]
/// the curve used to animate the red value on
[Tooltip("the curve used to animate the red value on")]
public AnimationCurve ShakeRed = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-200f, 200f)]
public float RemapRedZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-200f, 200f)]
public float RemapRedOne = 200f;
[MMInspectorGroup("Green", true, 43)]
/// the curve used to animate the green value on
[Tooltip("the curve used to animate the green value on")]
public AnimationCurve ShakeGreen = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-200f, 200f)]
public float RemapGreenZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-200f, 200f)]
public float RemapGreenOne = 200f;
[MMInspectorGroup("Blue", true, 44)]
/// the curve used to animate the blue value on
[Tooltip("the curve used to animate the blue value on")]
public AnimationCurve ShakeBlue = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-200f, 200f)]
public float RemapBlueZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-200f, 200f)]
public float RemapBlueOne = 200f;
#if MM_HDRP
protected Volume _volume;
protected ChannelMixer _channelMixer;
protected float _initialRed;
protected float _initialGreen;
protected float _initialBlue;
protected float _initialContrast;
protected Color _initialColorFilterColor;
protected float _originalShakeDuration;
protected bool _originalRelativeValues;
protected AnimationCurve _originalShakeRed;
protected float _originalRemapRedZero;
protected float _originalRemapRedOne;
protected AnimationCurve _originalShakeGreen;
protected float _originalRemapGreenZero;
protected float _originalRemapGreenOne;
protected AnimationCurve _originalShakeBlue;
protected float _originalRemapBlueZero;
protected float _originalRemapBlueOne;
/// <summary>
/// On init we initialize our values
/// </summary>
protected override void Initialization()
{
base.Initialization();
_volume = this.gameObject.GetComponent<Volume>();
_volume.profile.TryGet(out _channelMixer);
}
/// <summary>
/// When that shaker gets added, we initialize its shake duration
/// </summary>
protected virtual void Reset()
{
ShakeDuration = 0.8f;
}
/// <summary>
/// Shakes values over time
/// </summary>
protected override void Shake()
{
float newRed = ShakeFloat(ShakeRed, RemapRedZero, RemapRedOne, RelativeValues, _initialRed);
_channelMixer.redOutRedIn.Override(newRed);
float newGreen = ShakeFloat(ShakeGreen, RemapGreenZero, RemapGreenOne, RelativeValues, _initialGreen);
_channelMixer.greenOutGreenIn.Override(newGreen);
float newBlue = ShakeFloat(ShakeBlue, RemapBlueZero, RemapBlueOne, RelativeValues, _initialBlue);
_channelMixer.blueOutBlueIn.Override(newBlue);
}
/// <summary>
/// Collects initial values on the target
/// </summary>
protected override void GrabInitialValues()
{
_initialRed = _channelMixer.redOutRedIn.value;
_initialGreen = _channelMixer.greenOutGreenIn.value;
_initialBlue = _channelMixer.blueOutBlueIn.value;
}
/// <summary>
/// When we get the appropriate event, we trigger a shake
/// </summary>
/// <param name="intensity"></param>
/// <param name="duration"></param>
/// <param name="amplitude"></param>
/// <param name="relativeIntensity"></param>
/// <param name="attenuation"></param>
/// <param name="channel"></param>
public virtual void OnMMChannelMixerShakeEvent(AnimationCurve shakeRed, float remapRedZero, float remapRedOne,
AnimationCurve shakeGreen, float remapGreenZero, float remapGreenOne,
AnimationCurve shakeBlue, float remapBlueZero, float remapBlueOne,
float duration, bool relativeValues = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
if (!CheckEventAllowed(channelData) || (!Interruptible && Shaking))
{
return;
}
if (stop)
{
Stop();
return;
}
if (restore)
{
ResetTargetValues();
return;
}
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalRelativeValues = RelativeValues;
_originalShakeRed = ShakeRed;
_originalRemapRedZero = RemapRedZero;
_originalRemapRedOne = RemapRedOne;
_originalShakeGreen = ShakeGreen;
_originalRemapGreenZero = RemapGreenZero;
_originalRemapGreenOne = RemapGreenOne;
_originalShakeBlue = ShakeBlue;
_originalRemapBlueZero = RemapBlueZero;
_originalRemapBlueOne = RemapBlueOne;
}
TimescaleMode = timescaleMode;
ShakeDuration = duration;
RelativeValues = relativeValues;
ShakeRed = shakeRed;
RemapRedZero = remapRedZero;
RemapRedOne = remapRedOne;
ShakeGreen = shakeGreen;
RemapGreenZero = remapGreenZero;
RemapGreenOne = remapGreenOne;
ShakeBlue = shakeBlue;
RemapBlueZero = remapBlueZero;
RemapBlueOne = remapBlueOne;
ForwardDirection = forwardDirection;
Play();
}
/// <summary>
/// Resets the target's values
/// </summary>
protected override void ResetTargetValues()
{
base.ResetTargetValues();
_channelMixer.redOutRedIn.Override(_initialRed);
_channelMixer.greenOutGreenIn.Override(_initialGreen);
_channelMixer.blueOutBlueIn.Override(_initialBlue);
}
/// <summary>
/// Resets the shaker's values
/// </summary>
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
RelativeValues = _originalRelativeValues;
ShakeRed = _originalShakeRed;
RemapRedZero = _originalRemapRedZero;
RemapRedOne = _originalRemapRedOne;
ShakeGreen = _originalShakeGreen;
RemapGreenZero = _originalRemapGreenZero;
RemapGreenOne = _originalRemapGreenOne;
ShakeBlue = _originalShakeBlue;
RemapBlueZero = _originalRemapBlueZero;
RemapBlueOne = _originalRemapBlueOne;
}
/// <summary>
/// Starts listening for events
/// </summary>
public override void StartListening()
{
base.StartListening();
MMChannelMixerShakeEvent_HDRP.Register(OnMMChannelMixerShakeEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
public override void StopListening()
{
base.StopListening();
MMChannelMixerShakeEvent_HDRP.Unregister(OnMMChannelMixerShakeEvent);
}
#endif
}
/// <summary>
/// An event used to trigger vignette shakes
/// </summary>
public struct MMChannelMixerShakeEvent_HDRP
{
static private event Delegate OnEvent;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void RuntimeInitialization() { OnEvent = null; }
static public void Register(Delegate callback) { OnEvent += callback; }
static public void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(
AnimationCurve shakeRed, float remapRedZero, float remapRedOne,
AnimationCurve shakeGreen, float remapGreenZero, float remapGreenOne,
AnimationCurve shakeBlue, float remapBlueZero, float remapBlueOne,
float duration, bool relativeValues = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false);
static public void Trigger(
AnimationCurve shakeRed, float remapRedZero, float remapRedOne,
AnimationCurve shakeGreen, float remapGreenZero, float remapGreenOne,
AnimationCurve shakeBlue, float remapBlueZero, float remapBlueOne,
float duration, bool relativeValues = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
OnEvent?.Invoke(shakeRed, remapRedZero, remapRedOne,
shakeGreen, remapGreenZero, remapGreenOne,
shakeBlue, remapBlueZero, remapBlueOne,
duration, relativeValues, attenuation, channelData, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore);
}
}
}

View File

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

View File

@@ -0,0 +1,190 @@
using UnityEngine;
using UnityEngine.Rendering;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
#if MM_HDRP
using UnityEngine.Rendering.HighDefinition;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this class to a Camera with a HDRP chromatic aberration post processing and it'll be able to "shake" its values by getting events
/// </summary>
#if MM_HDRP
[RequireComponent(typeof(Volume))]
#endif
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MMChromaticAberrationShaker_HDRP")]
public class MMChromaticAberrationShaker_HDRP : MMShaker
{
[MMInspectorGroup("Chromatic Aberration Intensity", true, 44)]
/// whether or not to add to the initial value
[Tooltip("whether or not to add to the initial value")]
public bool RelativeIntensity = false;
/// the curve used to animate the intensity value on
[Tooltip("the curve used to animate the intensity value on")]
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(0f, 1f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(0f, 1f)]
public float RemapIntensityOne = 1f;
#if MM_HDRP
protected Volume _volume;
protected ChromaticAberration _chromaticAberration;
protected float _initialIntensity;
protected float _originalShakeDuration;
protected AnimationCurve _originalShakeIntensity;
protected float _originalRemapIntensityZero;
protected float _originalRemapIntensityOne;
protected bool _originalRelativeIntensity;
/// <summary>
/// On init we initialize our values
/// </summary>
protected override void Initialization()
{
base.Initialization();
_volume = this.gameObject.GetComponent<Volume>();
_volume.profile.TryGet(out _chromaticAberration);
}
/// <summary>
/// Shakes values over time
/// </summary>
protected override void Shake()
{
float newValue = ShakeFloat(ShakeIntensity, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, _initialIntensity);
_chromaticAberration.intensity.Override(newValue);
}
/// <summary>
/// Collects initial values on the target
/// </summary>
protected override void GrabInitialValues()
{
_initialIntensity = _chromaticAberration.intensity.value;
}
/// <summary>
/// When we get the appropriate event, we trigger a shake
/// </summary>
/// <param name="intensity"></param>
/// <param name="duration"></param>
/// <param name="amplitude"></param>
/// <param name="relativeIntensity"></param>
/// <param name="attenuation"></param>
/// <param name="channel"></param>
public virtual void OnMMChromaticAberrationShakeEvent(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
if (!CheckEventAllowed(channelData) || (!Interruptible && Shaking))
{
return;
}
if (stop)
{
Stop();
return;
}
if (restore)
{
ResetTargetValues();
return;
}
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeIntensity = ShakeIntensity;
_originalRemapIntensityZero = RemapIntensityZero;
_originalRemapIntensityOne = RemapIntensityOne;
_originalRelativeIntensity = RelativeIntensity;
}
TimescaleMode = timescaleMode;
ShakeDuration = duration;
ShakeIntensity = intensity;
RemapIntensityZero = remapMin * attenuation;
RemapIntensityOne = remapMax * attenuation;
RelativeIntensity = relativeIntensity;
ForwardDirection = forwardDirection;
Play();
}
/// <summary>
/// Resets the target's values
/// </summary>
protected override void ResetTargetValues()
{
base.ResetTargetValues();
_chromaticAberration.intensity.Override(_initialIntensity);
}
/// <summary>
/// Resets the shaker's values
/// </summary>
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeIntensity = _originalShakeIntensity;
RemapIntensityZero = _originalRemapIntensityZero;
RemapIntensityOne = _originalRemapIntensityOne;
RelativeIntensity = _originalRelativeIntensity;
}
/// <summary>
/// Starts listening for events
/// </summary>
public override void StartListening()
{
base.StartListening();
MMChromaticAberrationShakeEvent_HDRP.Register(OnMMChromaticAberrationShakeEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
public override void StopListening()
{
base.StopListening();
MMChromaticAberrationShakeEvent_HDRP.Unregister(OnMMChromaticAberrationShakeEvent);
}
#endif
}
/// <summary>
/// An event used to trigger vignette shakes
/// </summary>
public struct MMChromaticAberrationShakeEvent_HDRP
{
static private event Delegate OnEvent;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void RuntimeInitialization() { OnEvent = null; }
static public void Register(Delegate callback) { OnEvent += callback; }
static public void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false);
static public void Trigger(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
OnEvent?.Invoke(intensity, duration, remapMin, remapMax, relativeIntensity, attenuation, channelData, resetShakerValuesAfterShake,
resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore);
}
}
}

View File

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

View File

@@ -0,0 +1,356 @@
using UnityEngine;
using UnityEngine.Rendering;
using MoreMountains.Tools;
using MoreMountains.Feedbacks;
#if MM_HDRP
using UnityEngine.Rendering.HighDefinition;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this class to a Camera with a HDRP color adjustments post processing and it'll be able to "shake" its values by getting events
/// </summary>
#if MM_HDRP
[RequireComponent(typeof(Volume))]
#endif
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MMColorAdjustmentsShaker_HDRP")]
public class MMColorAdjustmentsShaker_HDRP : MMShaker
{
/// whether or not to add to the initial value
public bool RelativeValues = true;
[MMInspectorGroup("Post Exposure", true, 44)]
/// the curve used to animate the focus distance value on
[Tooltip("the curve used to animate the focus distance value on")]
public AnimationCurve ShakePostExposure = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapPostExposureZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapPostExposureOne = 1f;
[MMInspectorGroup("Hue Shift", true, 45)]
/// the curve used to animate the aperture value on
[Tooltip("the curve used to animate the aperture value on")]
public AnimationCurve ShakeHueShift = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Range(-180f, 180f)]
[Tooltip("the value to remap the curve's 0 to")]
public float RemapHueShiftZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-180f, 180f)]
public float RemapHueShiftOne = 180f;
[MMInspectorGroup("Saturation", true, 46)]
/// the curve used to animate the focal length value on
[Tooltip("the curve used to animate the focal length value on")]
public AnimationCurve ShakeSaturation = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapSaturationZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapSaturationOne = 100f;
[MMInspectorGroup("Contrast", true, 47)]
/// the curve used to animate the focal length value on
[Tooltip("the curve used to animate the focal length value on")]
public AnimationCurve ShakeContrast = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapContrastZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapContrastOne = 100f;
public enum ColorFilterModes { None, Gradient, Interpolate }
[MMInspectorGroup("Color Filter", true, 48)]
/// the color filter mode to work with (none, over a gradient, or interpolate to a destination color
[Tooltip("the color filter mode to work with (none, over a gradient, or interpolate to a destination color")]
public ColorFilterModes ColorFilterMode = ColorFilterModes.None;
/// the gradient over which to modify the color filter
[Tooltip("the gradient over which to modify the color filter")]
[MMFEnumCondition("ColorFilterMode", (int)ColorFilterModes.Gradient)]
[GradientUsage(true)]
public Gradient ColorFilterGradient;
/// the destination color to match when in Interpolate mode
[Tooltip("the destination color to match when in Interpolate mode")]
[MMFEnumCondition("ColorFilterMode", (int) ColorFilterModes.Interpolate)]
public Color ColorFilterDestination = Color.yellow;
/// the curve over which to interpolate the color filter
[Tooltip("the curve over which to interpolate the color filter")]
[MMFEnumCondition("ColorFilterMode", (int) ColorFilterModes.Interpolate)]
public AnimationCurve ColorFilterCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
#if MM_HDRP
protected Volume _volume;
protected ColorAdjustments _colorAdjustments;
protected float _initialPostExposure;
protected float _initialHueShift;
protected float _initialSaturation;
protected float _initialContrast;
protected Color _initialColorFilterColor;
protected float _originalShakeDuration;
protected bool _originalRelativeValues;
protected AnimationCurve _originalShakePostExposure;
protected float _originalRemapPostExposureZero;
protected float _originalRemapPostExposureOne;
protected AnimationCurve _originalShakeHueShift;
protected float _originalRemapHueShiftZero;
protected float _originalRemapHueShiftOne;
protected AnimationCurve _originalShakeSaturation;
protected float _originalRemapSaturationZero;
protected float _originalRemapSaturationOne;
protected AnimationCurve _originalShakeContrast;
protected float _originalRemapContrastZero;
protected float _originalRemapContrastOne;
protected ColorFilterModes _originalColorFilterMode;
protected Gradient _originalColorFilterGradient;
protected Color _originalColorFilterDestination;
protected AnimationCurve _originalColorFilterCurve;
/// <summary>
/// On init we initialize our values
/// </summary>
protected override void Initialization()
{
base.Initialization();
_volume = this.gameObject.GetComponent<Volume>();
_volume.profile.TryGet(out _colorAdjustments);
}
/// <summary>
/// When that shaker gets added, we initialize its shake duration
/// </summary>
protected virtual void Reset()
{
ShakeDuration = 0.8f;
}
/// <summary>
/// Shakes values over time
/// </summary>
protected override void Shake()
{
float newPostExposure = ShakeFloat(ShakePostExposure, RemapPostExposureZero, RemapPostExposureOne, RelativeValues, _initialPostExposure);
_colorAdjustments.postExposure.Override(newPostExposure);
float newHueShift = ShakeFloat(ShakeHueShift, RemapHueShiftZero, RemapHueShiftOne, RelativeValues, _initialHueShift);
_colorAdjustments.hueShift.Override(newHueShift);
float newSaturation = ShakeFloat(ShakeSaturation, RemapSaturationZero, RemapSaturationOne, RelativeValues, _initialSaturation);
_colorAdjustments.saturation.Override(newSaturation);
float newContrast = ShakeFloat(ShakeContrast, RemapContrastZero, RemapContrastOne, RelativeValues, _initialContrast);
_colorAdjustments.contrast.Override(newContrast);
_remappedTimeSinceStart = MMFeedbacksHelpers.Remap(Time.time - _shakeStartedTimestamp, 0f, ShakeDuration, 0f, 1f);
if (ColorFilterMode == ColorFilterModes.Gradient)
{
_colorAdjustments.colorFilter.Override(ColorFilterGradient.Evaluate(_remappedTimeSinceStart));
}
else if (ColorFilterMode == ColorFilterModes.Interpolate)
{
float factor = ColorFilterCurve.Evaluate(_remappedTimeSinceStart);
_colorAdjustments.colorFilter.Override(Color.LerpUnclamped(_initialColorFilterColor, ColorFilterDestination, factor));
}
}
/// <summary>
/// Collects initial values on the target
/// </summary>
protected override void GrabInitialValues()
{
_initialPostExposure = _colorAdjustments.postExposure.value;
_initialHueShift = _colorAdjustments.hueShift.value;
_initialSaturation = _colorAdjustments.saturation.value;
_initialContrast = _colorAdjustments.contrast.value;
_initialColorFilterColor = _colorAdjustments.colorFilter.value;
}
/// <summary>
/// When we get the appropriate event, we trigger a shake
/// </summary>
/// <param name="intensity"></param>
/// <param name="duration"></param>
/// <param name="amplitude"></param>
/// <param name="relativeIntensity"></param>
/// <param name="attenuation"></param>
/// <param name="channel"></param>
public virtual void OnMMColorGradingShakeEvent(AnimationCurve shakePostExposure, float remapPostExposureZero, float remapPostExposureOne,
AnimationCurve shakeHueShift, float remapHueShiftZero, float remapHueShiftOne,
AnimationCurve shakeSaturation, float remapSaturationZero, float remapSaturationOne,
AnimationCurve shakeContrast, float remapContrastZero, float remapContrastOne,
ColorFilterModes colorFilterMode, Gradient colorFilterGradient, Color colorFilterDestination,AnimationCurve colorFilterCurve,
float duration, bool relativeValues = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
if (!CheckEventAllowed(channelData) || (!Interruptible && Shaking))
{
return;
}
if (stop)
{
Stop();
return;
}
if (restore)
{
ResetTargetValues();
return;
}
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalRelativeValues = RelativeValues;
_originalShakePostExposure = ShakePostExposure;
_originalRemapPostExposureZero = RemapPostExposureZero;
_originalRemapPostExposureOne = RemapPostExposureOne;
_originalShakeHueShift = ShakeHueShift;
_originalRemapHueShiftZero = RemapHueShiftZero;
_originalRemapHueShiftOne = RemapHueShiftOne;
_originalShakeSaturation = ShakeSaturation;
_originalRemapSaturationZero = RemapSaturationZero;
_originalRemapSaturationOne = RemapSaturationOne;
_originalShakeContrast = ShakeContrast;
_originalRemapContrastZero = RemapContrastZero;
_originalRemapContrastOne = RemapContrastOne;
_originalColorFilterMode = ColorFilterMode;
_originalColorFilterGradient = ColorFilterGradient;
_originalColorFilterDestination = ColorFilterDestination;
_originalColorFilterCurve = ColorFilterCurve;
}
TimescaleMode = timescaleMode;
ShakeDuration = duration;
RelativeValues = relativeValues;
ShakePostExposure = shakePostExposure;
RemapPostExposureZero = remapPostExposureZero;
RemapPostExposureOne = remapPostExposureOne;
ShakeHueShift = shakeHueShift;
RemapHueShiftZero = remapHueShiftZero;
RemapHueShiftOne = remapHueShiftOne;
ShakeSaturation = shakeSaturation;
RemapSaturationZero = remapSaturationZero;
RemapSaturationOne = remapSaturationOne;
ShakeContrast = shakeContrast;
RemapContrastZero = remapContrastZero;
RemapContrastOne = remapContrastOne;
ColorFilterMode = colorFilterMode;
ColorFilterGradient = colorFilterGradient;
ColorFilterDestination = colorFilterDestination;
ColorFilterCurve = colorFilterCurve;
ForwardDirection = forwardDirection;
Play();
}
/// <summary>
/// Resets the target's values
/// </summary>
protected override void ResetTargetValues()
{
base.ResetTargetValues();
_colorAdjustments.postExposure.Override(_initialPostExposure);
_colorAdjustments.hueShift.Override(_initialHueShift);
_colorAdjustments.saturation.Override(_initialSaturation);
_colorAdjustments.contrast.Override(_initialContrast);
_colorAdjustments.colorFilter.Override(_initialColorFilterColor);
}
/// <summary>
/// Resets the shaker's values
/// </summary>
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
RelativeValues = _originalRelativeValues;
ShakePostExposure = _originalShakePostExposure;
RemapPostExposureZero = _originalRemapPostExposureZero;
RemapPostExposureOne = _originalRemapPostExposureOne;
ShakeHueShift = _originalShakeHueShift;
RemapHueShiftZero = _originalRemapHueShiftZero;
RemapHueShiftOne = _originalRemapHueShiftOne;
ShakeSaturation = _originalShakeSaturation;
RemapSaturationZero = _originalRemapSaturationZero;
RemapSaturationOne = _originalRemapSaturationOne;
ShakeContrast = _originalShakeContrast;
RemapContrastZero = _originalRemapContrastZero;
RemapContrastOne = _originalRemapContrastOne;
ColorFilterMode = _originalColorFilterMode;
ColorFilterGradient = _originalColorFilterGradient;
ColorFilterDestination = _originalColorFilterDestination;
ColorFilterCurve = _originalColorFilterCurve;
}
/// <summary>
/// Starts listening for events
/// </summary>
public override void StartListening()
{
base.StartListening();
MMColorAdjustmentsShakeEvent_HDRP.Register(OnMMColorGradingShakeEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
public override void StopListening()
{
base.StopListening();
MMColorAdjustmentsShakeEvent_HDRP.Unregister(OnMMColorGradingShakeEvent);
}
#endif
}
/// <summary>
/// An event used to trigger vignette shakes
/// </summary>
public struct MMColorAdjustmentsShakeEvent_HDRP
{
static private event Delegate OnEvent;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void RuntimeInitialization() { OnEvent = null; }
static public void Register(Delegate callback) { OnEvent += callback; }
static public void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(AnimationCurve shakePostExposure, float remapPostExposureZero, float remapPostExposureOne,
AnimationCurve shakeHueShift, float remapHueShiftZero, float remapHueShiftOne,
AnimationCurve shakeSaturation, float remapSaturationZero, float remapSaturationOne,
AnimationCurve shakeContrast, float remapContrastZero, float remapContrastOne,
MMColorAdjustmentsShaker_HDRP.ColorFilterModes colorFilterMode, Gradient colorFilterGradient, Color colorFilterDestination,AnimationCurve colorFilterCurve,
float duration, bool relativeValues = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false);
static public void Trigger(AnimationCurve shakePostExposure, float remapPostExposureZero, float remapPostExposureOne,
AnimationCurve shakeHueShift, float remapHueShiftZero, float remapHueShiftOne,
AnimationCurve shakeSaturation, float remapSaturationZero, float remapSaturationOne,
AnimationCurve shakeContrast, float remapContrastZero, float remapContrastOne,
MMColorAdjustmentsShaker_HDRP.ColorFilterModes colorFilterMode, Gradient colorFilterGradient, Color colorFilterDestination,AnimationCurve colorFilterCurve,
float duration, bool relativeValues = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
OnEvent?.Invoke(shakePostExposure, remapPostExposureZero, remapPostExposureOne,
shakeHueShift, remapHueShiftZero, remapHueShiftOne,
shakeSaturation, remapSaturationZero, remapSaturationOne,
shakeContrast, remapContrastZero, remapContrastOne,
colorFilterMode, colorFilterGradient, colorFilterDestination, colorFilterCurve,
duration, relativeValues, attenuation, channelData, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore);
}
}
}

View File

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

View File

@@ -0,0 +1,188 @@
using UnityEngine;
using UnityEngine.Rendering;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
#if MM_HDRP
using UnityEngine.Rendering.HighDefinition;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this class to a Camera with a HDRP exposure post processing and it'll be able to "shake" its values by getting events
/// </summary>
#if MM_HDRP
[RequireComponent(typeof(Volume))]
#endif
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MMExposureShaker_HDRP")]
public class MMExposureShaker_HDRP : MMShaker
{
[MMInspectorGroup("Exposure Intensity", true, 46)]
/// whether or not to add to the initial value
[Tooltip("whether or not to add to the initial value")]
public bool RelativeIntensity = false;
/// the curve used to animate the intensity value on
[Tooltip("the curve used to animate the intensity value on")]
public AnimationCurve ShakeFixedExposure = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
public float RemapFixedExposureZero = 8.5f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
public float RemapFixedExposureOne = 6f;
#if MM_HDRP
protected Volume _volume;
protected Exposure _exposure;
protected float _initialFixedExposure;
protected float _originalShakeDuration;
protected AnimationCurve _originalShakeFixedExposure;
protected float _originalRemapFixedExposureZero;
protected float _originalRemapFixedExposureOne;
protected bool _originalRelativeFixedExposure;
/// <summary>
/// On init we initialize our values
/// </summary>
protected override void Initialization()
{
base.Initialization();
_volume = this.gameObject.GetComponent<Volume>();
_volume.profile.TryGet(out _exposure);
}
/// <summary>
/// Shakes values over time
/// </summary>
protected override void Shake()
{
float newValue = ShakeFloat(ShakeFixedExposure, RemapFixedExposureZero, RemapFixedExposureOne, RelativeIntensity, _initialFixedExposure);
_exposure.fixedExposure.Override(newValue);
}
/// <summary>
/// Collects initial values on the target
/// </summary>
protected override void GrabInitialValues()
{
_initialFixedExposure = _exposure.fixedExposure.value;
}
/// <summary>
/// When we get the appropriate event, we trigger a shake
/// </summary>
/// <param name="intensity"></param>
/// <param name="duration"></param>
/// <param name="amplitude"></param>
/// <param name="relativeIntensity"></param>
/// <param name="attenuation"></param>
/// <param name="channel"></param>
public virtual void OnExposureShakeEvent(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
if (!CheckEventAllowed(channelData) || (!Interruptible && Shaking))
{
return;
}
if (stop)
{
Stop();
return;
}
if (restore)
{
ResetTargetValues();
return;
}
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeFixedExposure = ShakeFixedExposure;
_originalRemapFixedExposureZero = RemapFixedExposureZero;
_originalRemapFixedExposureOne = RemapFixedExposureOne;
_originalRelativeFixedExposure = RelativeIntensity;
}
TimescaleMode = timescaleMode;
ShakeDuration = duration;
ShakeFixedExposure = intensity;
RemapFixedExposureZero = remapMin * attenuation;
RemapFixedExposureOne = remapMax * attenuation;
RelativeIntensity = relativeIntensity;
ForwardDirection = forwardDirection;
Play();
}
/// <summary>
/// Resets the target's values
/// </summary>
protected override void ResetTargetValues()
{
base.ResetTargetValues();
_exposure.fixedExposure.Override(_initialFixedExposure);
}
/// <summary>
/// Resets the shaker's values
/// </summary>
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeFixedExposure = _originalShakeFixedExposure;
RemapFixedExposureZero = _originalRemapFixedExposureZero;
RemapFixedExposureOne = _originalRemapFixedExposureOne;
RelativeIntensity = _originalRelativeFixedExposure;
}
/// <summary>
/// Starts listening for events
/// </summary>
public override void StartListening()
{
base.StartListening();
MMExposureShakeEvent_HDRP.Register(OnExposureShakeEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
public override void StopListening()
{
base.StopListening();
MMExposureShakeEvent_HDRP.Unregister(OnExposureShakeEvent);
}
#endif
}
/// <summary>
/// An event used to trigger exposure shakes
/// </summary>
public struct MMExposureShakeEvent_HDRP
{
static private event Delegate OnEvent;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void RuntimeInitialization() { OnEvent = null; }
static public void Register(Delegate callback) { OnEvent += callback; }
static public void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(AnimationCurve fixedExposure, float duration, float remapMin, float remapMax, bool relativeFixedExposure = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false);
static public void Trigger(AnimationCurve fixedExposure, float duration, float remapMin, float remapMax, bool relativeFixedExposure = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
OnEvent?.Invoke(fixedExposure, duration, remapMin, remapMax, relativeFixedExposure, attenuation, channelData, resetShakerValuesAfterShake,
resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore);
}
}
}

View File

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

View File

@@ -0,0 +1,189 @@
using UnityEngine;
using UnityEngine.Rendering;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
#if MM_HDRP
using UnityEngine.Rendering.HighDefinition;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this class to a Camera with a HDRP FilmGrain post processing and it'll be able to "shake" its values by getting events
/// </summary>
#if MM_HDRP
[RequireComponent(typeof(Volume))]
#endif
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MMFilmGrainShaker_HDRP")]
public class MMFilmGrainShaker_HDRP : MMShaker
{
[MMInspectorGroup("Film Grain Intensity", true, 47)]
/// whether or not to add to the initial value
[Tooltip("whether or not to add to the initial value")]
public bool RelativeIntensity = false;
/// the curve used to animate the intensity value on
[Tooltip("the curve used to animate the intensity value on")]
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(0f, 1f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(0f, 1f)]
public float RemapIntensityOne = 1f;
#if MM_HDRP
protected Volume _volume;
protected FilmGrain _filmGrain;
protected float _initialIntensity;
protected float _originalShakeDuration;
protected AnimationCurve _originalShakeIntensity;
protected float _originalRemapIntensityZero;
protected float _originalRemapIntensityOne;
protected bool _originalRelativeIntensity;
/// <summary>
/// On init we initialize our values
/// </summary>
protected override void Initialization()
{
base.Initialization();
_volume = this.gameObject.GetComponent<Volume>();
_volume.profile.TryGet(out _filmGrain);
}
/// <summary>
/// Shakes values over time
/// </summary>
protected override void Shake()
{
float newValue = ShakeFloat(ShakeIntensity, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, _initialIntensity);
_filmGrain.intensity.Override(newValue);
}
/// <summary>
/// Collects initial values on the target
/// </summary>
protected override void GrabInitialValues()
{
_initialIntensity = _filmGrain.intensity.value;
}
/// <summary>
/// When we get the appropriate event, we trigger a shake
/// </summary>
/// <param name="intensity"></param>
/// <param name="duration"></param>
/// <param name="amplitude"></param>
/// <param name="relativeIntensity"></param>
/// <param name="attenuation"></param>
/// <param name="channel"></param>
public virtual void OnFilmGrainShakeEvent(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
if (!CheckEventAllowed(channelData) || (!Interruptible && Shaking))
{
return;
}
if (stop)
{
Stop();
return;
}
if (restore)
{
ResetTargetValues();
return;
}
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeIntensity = ShakeIntensity;
_originalRemapIntensityZero = RemapIntensityZero;
_originalRemapIntensityOne = RemapIntensityOne;
_originalRelativeIntensity = RelativeIntensity;
}
TimescaleMode = timescaleMode;
ShakeDuration = duration;
ShakeIntensity = intensity;
RemapIntensityZero = remapMin * attenuation;
RemapIntensityOne = remapMax * attenuation;
RelativeIntensity = relativeIntensity;
ForwardDirection = forwardDirection;
Play();
}
/// <summary>
/// Resets the target's values
/// </summary>
protected override void ResetTargetValues()
{
base.ResetTargetValues();
_filmGrain.intensity.Override(_initialIntensity);
}
/// <summary>
/// Resets the shaker's values
/// </summary>
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeIntensity = _originalShakeIntensity;
RemapIntensityZero = _originalRemapIntensityZero;
RemapIntensityOne = _originalRemapIntensityOne;
RelativeIntensity = _originalRelativeIntensity;
}
/// <summary>
/// Starts listening for events
/// </summary>
public override void StartListening()
{
base.StartListening();
MMFilmGrainShakeEvent_HDRP.Register(OnFilmGrainShakeEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
public override void StopListening()
{
base.StopListening();
MMFilmGrainShakeEvent_HDRP.Unregister(OnFilmGrainShakeEvent);
}
#endif
}
/// <summary>
/// An event used to trigger FilmGrain shakes
/// </summary>
public struct MMFilmGrainShakeEvent_HDRP
{
static private event Delegate OnEvent;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void RuntimeInitialization() { OnEvent = null; }
static public void Register(Delegate callback) { OnEvent += callback; }
static public void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false);
static public void Trigger(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
OnEvent?.Invoke(intensity, duration, remapMin, remapMax, relativeIntensity, attenuation, channelData, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore);
}
}
}

View File

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

View File

@@ -0,0 +1,207 @@
using UnityEngine;
using UnityEngine.Rendering;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
#if MM_HDRP
using UnityEngine.Rendering.HighDefinition;
#endif
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// Add this class to a Camera with a HDRP lens distortion post processing and it'll be able to "shake" its values by getting events
/// </summary>
#if MM_HDRP
[RequireComponent(typeof(Volume))]
#endif
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MMLensDistortionShaker_HDRP")]
public class MMLensDistortionShaker_HDRP : MMShaker
{
[MMInspectorGroup("Lens Distortion Intensity", true, 47)]
/// whether or not to add to the initial value
[Tooltip("whether or not to add to the initial value")]
public bool RelativeIntensity = false;
/// the curve used to animate the intensity value on
[Tooltip("the curve used to animate the intensity value on")]
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0),
new Keyframe(0.2f, 1),
new Keyframe(0.25f, -1),
new Keyframe(0.35f, 0.7f),
new Keyframe(0.4f, -0.7f),
new Keyframe(0.6f, 0.3f),
new Keyframe(0.65f, -0.3f),
new Keyframe(0.8f, 0.1f),
new Keyframe(0.85f, -0.1f),
new Keyframe(1, 0));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[Range(-100f, 100f)]
public float RemapIntensityZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[Range(-100f, 100f)]
public float RemapIntensityOne = 0.5f;
#if MM_HDRP
protected Volume _volume;
protected LensDistortion _lensDistortion;
protected float _initialIntensity;
protected float _originalShakeDuration;
protected AnimationCurve _originalShakeIntensity;
protected float _originalRemapIntensityZero;
protected float _originalRemapIntensityOne;
protected bool _originalRelativeIntensity;
/// <summary>
/// On init we initialize our values
/// </summary>
protected override void Initialization()
{
base.Initialization();
_volume = this.gameObject.GetComponent<Volume>();
_volume.profile.TryGet(out _lensDistortion);
}
/// <summary>
/// When that shaker gets added, we initialize its shake duration
/// </summary>
protected virtual void Reset()
{
ShakeDuration = 0.8f;
}
/// <summary>
/// Shakes values over time
/// </summary>
protected override void Shake()
{
float newValue = ShakeFloat(ShakeIntensity, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, _initialIntensity);
_lensDistortion.intensity.Override(newValue);
}
/// <summary>
/// Collects initial values on the target
/// </summary>
protected override void GrabInitialValues()
{
_initialIntensity = _lensDistortion.intensity.value;
}
/// <summary>
/// When we get the appropriate event, we trigger a shake
/// </summary>
/// <param name="intensity"></param>
/// <param name="duration"></param>
/// <param name="amplitude"></param>
/// <param name="relativeIntensity"></param>
/// <param name="attenuation"></param>
/// <param name="channel"></param>
public virtual void OnMMLensDistortionShakeEvent(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
if (!CheckEventAllowed(channelData) || (!Interruptible && Shaking))
{
return;
}
if (stop)
{
Stop();
return;
}
if (restore)
{
ResetTargetValues();
return;
}
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeIntensity = ShakeIntensity;
_originalRemapIntensityZero = RemapIntensityZero;
_originalRemapIntensityOne = RemapIntensityOne;
_originalRelativeIntensity = RelativeIntensity;
}
TimescaleMode = timescaleMode;
ShakeDuration = duration;
ShakeIntensity = intensity;
RemapIntensityZero = remapMin * attenuation;
RemapIntensityOne = remapMax * attenuation;
RelativeIntensity = relativeIntensity;
ForwardDirection = forwardDirection;
Play();
}
/// <summary>
/// Resets the target's values
/// </summary>
protected override void ResetTargetValues()
{
base.ResetTargetValues();
_lensDistortion.intensity.Override(_initialIntensity);
}
/// <summary>
/// Resets the shaker's values
/// </summary>
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeIntensity = _originalShakeIntensity;
RemapIntensityZero = _originalRemapIntensityZero;
RemapIntensityOne = _originalRemapIntensityOne;
RelativeIntensity = _originalRelativeIntensity;
}
/// <summary>
/// Starts listening for events
/// </summary>
public override void StartListening()
{
base.StartListening();
MMLensDistortionShakeEvent_HDRP.Register(OnMMLensDistortionShakeEvent);
}
/// <summary>
/// Stops listening for events
/// </summary>
public override void StopListening()
{
base.StopListening();
MMLensDistortionShakeEvent_HDRP.Unregister(OnMMLensDistortionShakeEvent);
}
#endif
}
/// <summary>
/// An event used to trigger vignette shakes
/// </summary>
public struct MMLensDistortionShakeEvent_HDRP
{
static private event Delegate OnEvent;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void RuntimeInitialization() { OnEvent = null; }
static public void Register(Delegate callback) { OnEvent += callback; }
static public void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false);
static public void Trigger(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float attenuation = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true,
bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
{
OnEvent?.Invoke(intensity, duration, remapMin, remapMax, relativeIntensity, attenuation, channelData,
resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore);
}
}
}

View File

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

Some files were not shown because too many files have changed in this diff Show More