架构大更
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using UnityEngine;
|
||||
using MoreMountains.Feedbacks;
|
||||
using UnityEngine.Rendering;
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
#if MM_HDRP
|
||||
using UnityEngine.Rendering.HighDefinition;
|
||||
#endif
|
||||
@@ -9,31 +8,33 @@ using UnityEngine.Rendering.HighDefinition;
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
/// <summary>
|
||||
/// Add this class to a Camera with a HDRP vignette post processing and it'll be able to "shake" its values by getting events
|
||||
/// Add this class to a Camera with a HDRP vignette post processing and it'll be able to "shake" its values by getting
|
||||
/// events
|
||||
/// </summary>
|
||||
#if MM_HDRP
|
||||
#if MM_HDRP
|
||||
[RequireComponent(typeof(Volume))]
|
||||
#endif
|
||||
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MM Panini Projection Shaker HDRP")]
|
||||
public class MMPaniniProjectionShaker_HDRP : MMShaker
|
||||
{
|
||||
[MMInspectorGroup("Panini Projection Distance", true, 49)]
|
||||
/// 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;
|
||||
#endif
|
||||
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MM Panini Projection Shaker HDRP")]
|
||||
public class MMPaniniProjectionShaker_HDRP : MMShaker
|
||||
{
|
||||
[MMInspectorGroup("Panini Projection Distance", true, 49)]
|
||||
/// whether or not to add to the initial value
|
||||
[Tooltip("whether or not to add to the initial value")]
|
||||
public bool RelativeDistance;
|
||||
|
||||
#if MM_HDRP
|
||||
/// the curve used to animate the distance value on
|
||||
[Tooltip("the curve used to animate the distance value on")]
|
||||
public AnimationCurve ShakeDistance = new(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;
|
||||
|
||||
/// 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;
|
||||
|
||||
#if MM_HDRP
|
||||
protected Volume _volume;
|
||||
protected PaniniProjection _paniniProjection;
|
||||
protected float _initialDistance;
|
||||
@@ -58,7 +59,8 @@ namespace MoreMountains.FeedbacksForThirdParty
|
||||
/// </summary>
|
||||
protected override void Shake()
|
||||
{
|
||||
float newValue = ShakeFloat(ShakeDistance, RemapDistanceZero, RemapDistanceOne, RelativeDistance, _initialDistance);
|
||||
float newValue =
|
||||
ShakeFloat(ShakeDistance, RemapDistanceZero, RemapDistanceOne, RelativeDistance, _initialDistance);
|
||||
_paniniProjection.distance.Override(newValue);
|
||||
}
|
||||
|
||||
@@ -79,9 +81,12 @@ namespace MoreMountains.FeedbacksForThirdParty
|
||||
/// <param name="relativeDistance"></param>
|
||||
/// <param name="attenuation"></param>
|
||||
/// <param name="channel"></param>
|
||||
public virtual void OnPaniniProjectionShakeEvent(AnimationCurve distance, float duration, float remapMin, float remapMax, bool relativeDistance = 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)
|
||||
public virtual void OnPaniniProjectionShakeEvent(AnimationCurve distance, float duration, float remapMin, float remapMax, bool relativeDistance
|
||||
= 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))
|
||||
{
|
||||
@@ -165,29 +170,49 @@ namespace MoreMountains.FeedbacksForThirdParty
|
||||
base.StopListening();
|
||||
MMPaniniProjectionShakeEvent_HDRP.Unregister(OnPaniniProjectionShakeEvent);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An event used to trigger vignette shakes
|
||||
/// An event used to trigger vignette shakes
|
||||
/// </summary>
|
||||
public struct MMPaniniProjectionShakeEvent_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 distance, float duration, float remapMin, float remapMax, bool relativeDistance = 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 distance, float duration, float remapMin, float remapMax, bool relativeDistance = 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(distance, duration, remapMin, remapMax, relativeDistance, attenuation, channelData, resetShakerValuesAfterShake,
|
||||
resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore);
|
||||
}
|
||||
}
|
||||
{
|
||||
private static event Delegate OnEvent;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private static void RuntimeInitialization()
|
||||
{
|
||||
OnEvent = null;
|
||||
}
|
||||
|
||||
public static void Register(Delegate callback)
|
||||
{
|
||||
OnEvent += callback;
|
||||
}
|
||||
|
||||
public static void Unregister(Delegate callback)
|
||||
{
|
||||
OnEvent -= callback;
|
||||
}
|
||||
|
||||
public delegate void Delegate(AnimationCurve distance, float duration, float remapMin, float remapMax,
|
||||
bool relativeDistance = 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);
|
||||
|
||||
public static void Trigger(AnimationCurve distance, float duration, float remapMin, float remapMax,
|
||||
bool relativeDistance = 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(distance, duration, remapMin, remapMax, relativeDistance, attenuation, channelData,
|
||||
resetShakerValuesAfterShake,
|
||||
resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user