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

View File

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

View File

@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will trigger a MMBlink object, letting you blink something
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you trigger a blink on an MMBlink object.")]
[FeedbackPath("Renderer/MMBlink")]
public class MMFeedbackBlink : 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.RendererColor; } }
#endif
/// the possible modes for this feedback, that correspond to MMBlink's public methods
public enum BlinkModes { Toggle, Start, Stop }
[Header("Blink")]
/// the target object to blink
[Tooltip("the target object to blink")]
public MMBlink TargetBlink;
/// the selected mode for this feedback
[Tooltip("the selected mode for this feedback")]
public BlinkModes BlinkMode = BlinkModes.Toggle;
/// <summary>
/// On Custom play, we trigger our MMBlink object
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || (TargetBlink == null))
{
return;
}
TargetBlink.TimescaleMode = Timing.TimescaleMode;
switch (BlinkMode)
{
case BlinkModes.Toggle:
TargetBlink.ToggleBlinking();
break;
case BlinkModes.Start:
TargetBlink.StartBlinking();
break;
case BlinkModes.Stop:
TargetBlink.StopBlinking();
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,97 @@
using MoreMountains.Tools;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you broadcast a float value to the MMRadio system
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you broadcast a float value to the MMRadio system.")]
[FeedbackPath("GameObject/Broadcast")]
public class MMFeedbackBroadcast : MMFeedbackBase
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.UIColor; } }
#endif
[Header("Target Channel")]
/// the channel to write the level to
[Tooltip("the channel to write the level to")]
public int Channel;
[Header("Level")]
/// the curve to tween the intensity on
[Tooltip("the curve to tween the intensity on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType Curve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the intensity curve's 0 to
[Tooltip("the value to remap the intensity curve's 0 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public float RemapZero = 0f;
/// the value to remap the intensity curve's 1 to
[Tooltip("the value to remap the intensity curve's 1 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public float RemapOne = 1f;
/// the value to move the intensity to in instant mode
[Tooltip("the value to move the intensity to in instant mode")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.Instant)]
public float InstantChange;
/// a debug view of the current level being broadcasted
[Tooltip("a debug view of the current level being broadcasted")]
[MMReadOnly]
public float DebugLevel;
/// whether or not a broadcast is in progress (will be false while the value is not changing, and thus not broadcasting)
[Tooltip("whether or not a broadcast is in progress (will be false while the value is not changing, and thus not broadcasting)")]
[MMReadOnly]
public bool BroadcastInProgress = false;
public float ThisLevel { get; set; }
protected float _levelLastFrame;
/// <summary>
/// We setup our target with this object
/// </summary>
protected override void FillTargets()
{
MMFeedbackBaseTarget target = new MMFeedbackBaseTarget();
MMPropertyReceiver receiver = new MMPropertyReceiver();
receiver.TargetObject = this.gameObject;
receiver.TargetComponent = this;
receiver.TargetPropertyName = "ThisLevel";
receiver.RelativeValue = RelativeValues;
target.Target = receiver;
target.LevelCurve = Curve;
target.RemapLevelZero = RemapZero;
target.RemapLevelOne = RemapOne;
target.InstantLevel = InstantChange;
_targets.Add(target);
}
/// <summary>
/// On Update we process our broadcast
/// </summary>
protected virtual void Update()
{
ProcessBroadcast();
}
/// <summary>
/// Broadcasts the value if needed
/// </summary>
protected virtual void ProcessBroadcast()
{
BroadcastInProgress = false;
if (ThisLevel != _levelLastFrame)
{
MMRadioLevelEvent.Trigger(Channel, ThisLevel);
BroadcastInProgress = true;
}
DebugLevel = ThisLevel;
_levelLastFrame = ThisLevel;
}
}
}

View File

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

View File

@@ -0,0 +1,65 @@
using MoreMountains.Tools;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you control the opacity of a canvas group over time
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you control the opacity of a canvas group over time.")]
[FeedbackPath("UI/CanvasGroup")]
public class MMFeedbackCanvasGroup : MMFeedbackBase
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.UIColor; } }
#endif
[Header("Target")]
/// the receiver to write the level to
[Tooltip("the receiver to write the level to")]
public CanvasGroup TargetCanvasGroup;
[Header("Level")]
/// the curve to tween the opacity on
[Tooltip("the curve to tween the opacity on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType AlphaCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the opacity curve's 0 to
[Tooltip("the value to remap the opacity curve's 0 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public float RemapZero = 0f;
/// the value to remap the opacity curve's 1 to
[Tooltip("the value to remap the opacity curve's 1 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public float RemapOne = 1f;
/// the value to move the opacity to in instant mode
[Tooltip("the value to move the opacity to in instant mode")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.Instant)]
public float InstantAlpha;
protected override void FillTargets()
{
if (TargetCanvasGroup == null)
{
return;
}
MMFeedbackBaseTarget target = new MMFeedbackBaseTarget();
MMPropertyReceiver receiver = new MMPropertyReceiver();
receiver.TargetObject = TargetCanvasGroup.gameObject;
receiver.TargetComponent = TargetCanvasGroup;
receiver.TargetPropertyName = "alpha";
receiver.RelativeValue = RelativeValues;
target.Target = receiver;
target.LevelCurve = AlphaCurve;
target.RemapLevelZero = RemapZero;
target.RemapLevelOne = RemapOne;
target.InstantLevel = InstantAlpha;
_targets.Add(target);
}
}
}

View File

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

View File

@@ -0,0 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback doesn't do anything by default, it's just meant as a comment, you can store text in it for future reference, maybe to remember how you setup a particular MMFeedbacks. Optionally it can also output that comment to the console on Play.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback doesn't do anything by default, it's just meant as a comment, you can store text in it for future reference, maybe to remember how you setup a particular MMFeedbacks. Optionally it can also output that comment to the console on Play.")]
[FeedbackPath("Debug/Comment")]
public class MMFeedbackDebugComment : 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.DebugColor; } }
#endif
/// the comment / note associated to this feedback
[Tooltip("the comment / note associated to this feedback")]
[TextArea(10,30)]
public string Comment;
/// if this is true, the comment will be output to the console on Play
[Tooltip("if this is true, the comment will be output to the console on Play")]
public bool LogComment = false;
/// the color of the message when in DebugLogTime mode
[Tooltip("the color of the message when in DebugLogTime mode")]
[MMCondition("LogComment", true)]
public Color DebugColor = Color.gray;
/// <summary>
/// On Play we output our message to the console if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || !LogComment)
{
return;
}
Debug.Log(Comment);
}
}
}

View File

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

View File

@@ -0,0 +1,80 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you output a message to the console, using a custom MM debug method, or Log, Assertion, Error or Warning logs.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will let you output a message to the console, using a custom MM debug method, or Log, Assertion, Error or Warning logs.")]
[FeedbackPath("Debug/Log")]
public class MMFeedbackDebugLog : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// the duration of this feedback is the duration of the light, or 0 if instant
public override float FeedbackDuration { get { return 0f; } }
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.DebugColor; } }
#endif
/// the possible debug modes
public enum DebugLogModes { DebugLogTime, Log, Assertion, Error, Warning }
[Header("Debug")]
/// the selected debug mode
[Tooltip("the selected debug mode")]
public DebugLogModes DebugLogMode = DebugLogModes.DebugLogTime;
/// the message to display
[Tooltip("the message to display")]
[TextArea]
public string DebugMessage;
/// the color of the message when in DebugLogTime mode
[Tooltip("the color of the message when in DebugLogTime mode")]
[MMFEnumCondition("DebugLogMode", (int) DebugLogModes.DebugLogTime)]
public Color DebugColor = Color.cyan;
/// whether or not to display the frame count when in DebugLogTime mode
[Tooltip("whether or not to display the frame count when in DebugLogTime mode")]
[MMFEnumCondition("DebugLogMode", (int) DebugLogModes.DebugLogTime)]
public bool DisplayFrameCount = true;
/// <summary>
/// On Play we output our message to the console using the selected mode
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (DebugLogMode)
{
case DebugLogModes.Assertion:
Debug.LogAssertion(DebugMessage);
break;
case DebugLogModes.Log:
Debug.Log(DebugMessage);
break;
case DebugLogModes.Error:
Debug.LogError(DebugMessage);
break;
case DebugLogModes.Warning:
Debug.LogWarning(DebugMessage);
break;
case DebugLogModes.DebugLogTime:
string color = "#" + ColorUtility.ToHtmlStringRGB(DebugColor);
MMDebug.DebugLogTime(DebugMessage, color, 3, DisplayFrameCount);
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,151 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will trigger a one time play on a target FloatController
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you trigger a fade event.")]
[FeedbackPath("Camera/Fade")]
public class MMFeedbackFade : 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
/// the different possible types of fades
public enum FadeTypes { FadeIn, FadeOut, Custom }
/// the different ways to send the position to the fader :
/// - FeedbackPosition : fade at the position of the feedback, plus an optional offset
/// - Transform : fade at the specified Transform's position, plus an optional offset
/// - WorldPosition : fade at the specified world position vector, plus an optional offset
/// - Script : the position passed in parameters when calling the feedback
public enum PositionModes { FeedbackPosition, Transform, WorldPosition, Script }
[Header("Fade")]
/// the type of fade we want to use when this feedback gets played
[Tooltip("the type of fade we want to use when this feedback gets played")]
public FadeTypes FadeType;
/// the ID of the fader(s) to pilot
[Tooltip("the ID of the fader(s) to pilot")]
public int ID = 0;
/// the duration (in seconds) of the fade
[Tooltip("the duration (in seconds) of the fade")]
public float Duration = 1f;
/// the curve to use for this fade
[Tooltip("the curve to use for this fade")]
public MMTweenType Curve = new MMTweenType(MMTween.MMTweenCurve.EaseInCubic);
/// whether or not this fade should ignore timescale
[Tooltip("whether or not this fade should ignore timescale")]
public bool IgnoreTimeScale = true;
[Header("Custom")]
/// the target alpha we're aiming for with this fade
[Tooltip("the target alpha we're aiming for with this fade")]
public float TargetAlpha;
[Header("Position")]
/// the chosen way to position the fade
[Tooltip("the chosen way to position the fade")]
public PositionModes PositionMode = PositionModes.FeedbackPosition;
/// the transform on which to center the fade
[Tooltip("the transform on which to center the fade")]
[MMFEnumCondition("PositionMode", (int)PositionModes.Transform)]
public Transform TargetTransform;
/// the coordinates on which to center the fadet
[Tooltip("the coordinates on which to center the fade")]
[MMFEnumCondition("PositionMode", (int)PositionModes.WorldPosition)]
public Vector3 TargetPosition;
/// the position offset to apply when centering the fade
[Tooltip("the position offset to apply when centering the fade")]
public Vector3 PositionOffset;
/// the duration of this feedback is the duration of the fade
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
protected Vector3 _position;
protected FadeTypes _fadeType;
/// <summary>
/// On play we trigger the selected fade event
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
_position = GetPosition(position);
_fadeType = FadeType;
if (!NormalPlayDirection)
{
if (FadeType == FadeTypes.FadeIn)
{
_fadeType = FadeTypes.FadeOut;
}
else if (FadeType == FadeTypes.FadeOut)
{
_fadeType = FadeTypes.FadeIn;
}
}
switch (_fadeType)
{
case FadeTypes.Custom:
MMFadeEvent.Trigger(FeedbackDuration, TargetAlpha, Curve, ID, IgnoreTimeScale, _position);
break;
case FadeTypes.FadeIn:
MMFadeInEvent.Trigger(FeedbackDuration, Curve, ID, IgnoreTimeScale, _position);
break;
case FadeTypes.FadeOut:
MMFadeOutEvent.Trigger(FeedbackDuration, Curve, ID, IgnoreTimeScale, _position);
break;
}
}
/// <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)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMFadeStopEvent.Trigger(ID);
}
/// <summary>
/// Computes the proper position for this fade
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
protected virtual Vector3 GetPosition(Vector3 position)
{
switch (PositionMode)
{
case PositionModes.FeedbackPosition:
return this.transform.position + PositionOffset;
case PositionModes.Transform:
return TargetTransform.position + PositionOffset;
case PositionModes.WorldPosition:
return TargetPosition + PositionOffset;
case PositionModes.Script:
return position + PositionOffset;
default:
return position + PositionOffset;
}
}
}
}

View File

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

View File

@@ -0,0 +1,185 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will trigger a one time play on a target FloatController
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you trigger a one time play on a target FloatController.")]
[FeedbackPath("GameObject/FloatController")]
public class MMFeedbackFloatController : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// the different possible modes
public enum Modes { OneTime, ToDestination }
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.GameObjectColor; } }
#endif
[Header("Float Controller")]
/// the mode this controller is in
[Tooltip("the mode this controller is in")]
public Modes Mode = Modes.OneTime;
/// the float controller to trigger a one time play on
[Tooltip("the float controller to trigger a one time play on")]
public FloatController TargetFloatController;
/// whether this should revert to original at the end
[Tooltip("whether this should revert to original at the end")]
public bool RevertToInitialValueAfterEnd = false;
/// the duration of the One Time shake
[Tooltip("the duration of the One Time shake")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeDuration = 1f;
/// the amplitude of the One Time shake (this will be multiplied by the curve's height)
[Tooltip("the amplitude of the One Time shake (this will be multiplied by the curve's height)")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeAmplitude = 1f;
/// the low value to remap the normalized curve value to
[Tooltip("the low value to remap the normalized curve value to")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeRemapMin = 0f;
/// the high value to remap the normalized curve value to
[Tooltip("the high value to remap the normalized curve value to")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeRemapMax = 1f;
/// the curve to apply to the one time shake
[Tooltip("the curve to apply to the one time shake")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public AnimationCurve OneTimeCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to move this float controller to
[Tooltip("the value to move this float controller to")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float ToDestinationValue = 1f;
/// the duration over which to move the value
[Tooltip("the duration over which to move the value")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float ToDestinationDuration = 1f;
/// the curve over which to move the value in ToDestination mode
[Tooltip("the curve over which to move the value in ToDestination mode")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public AnimationCurve ToDestinationCurve = 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 one time hit
public override float FeedbackDuration
{
get { return (Mode == Modes.OneTime) ? ApplyTimeMultiplier(OneTimeDuration) : ApplyTimeMultiplier(ToDestinationDuration); }
set { OneTimeDuration = value; ToDestinationDuration = value; }
}
protected float _oneTimeDurationStorage;
protected float _oneTimeAmplitudeStorage;
protected float _oneTimeRemapMinStorage;
protected float _oneTimeRemapMaxStorage;
protected AnimationCurve _oneTimeCurveStorage;
protected float _toDestinationValueStorage;
protected float _toDestinationDurationStorage;
protected AnimationCurve _toDestinationCurveStorage;
protected bool _revertToInitialValueAfterEndStorage;
/// <summary>
/// On init we grab our initial values on the target float controller
/// </summary>
/// <param name="owner"></param>
protected override void CustomInitialization(GameObject owner)
{
if (Active && (TargetFloatController != null))
{
_oneTimeDurationStorage = TargetFloatController.OneTimeDuration;
_oneTimeAmplitudeStorage = TargetFloatController.OneTimeAmplitude;
_oneTimeCurveStorage = TargetFloatController.OneTimeCurve;
_oneTimeRemapMinStorage = TargetFloatController.OneTimeRemapMin;
_oneTimeRemapMaxStorage = TargetFloatController.OneTimeRemapMax;
_toDestinationCurveStorage = TargetFloatController.ToDestinationCurve;
_toDestinationDurationStorage = TargetFloatController.ToDestinationDuration;
_toDestinationValueStorage = TargetFloatController.ToDestinationValue;
_revertToInitialValueAfterEndStorage = TargetFloatController.RevertToInitialValueAfterEnd;
}
}
/// <summary>
/// On play we trigger a one time or ToDestination play on our target float controller
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || (TargetFloatController == null))
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
TargetFloatController.RevertToInitialValueAfterEnd = RevertToInitialValueAfterEnd;
if (Mode == Modes.OneTime)
{
TargetFloatController.OneTimeDuration = FeedbackDuration;
TargetFloatController.OneTimeAmplitude = OneTimeAmplitude;
TargetFloatController.OneTimeCurve = OneTimeCurve;
if (NormalPlayDirection)
{
TargetFloatController.OneTimeRemapMin = OneTimeRemapMin * intensityMultiplier;
TargetFloatController.OneTimeRemapMax = OneTimeRemapMax * intensityMultiplier;
}
else
{
TargetFloatController.OneTimeRemapMin = OneTimeRemapMax * intensityMultiplier;
TargetFloatController.OneTimeRemapMax = OneTimeRemapMin * intensityMultiplier;
}
TargetFloatController.OneTime();
}
if (Mode == Modes.ToDestination)
{
TargetFloatController.ToDestinationCurve = ToDestinationCurve;
TargetFloatController.ToDestinationDuration = FeedbackDuration;
TargetFloatController.ToDestinationValue = ToDestinationValue;
TargetFloatController.ToDestination();
}
}
/// <summary>
/// On reset we reset our values on the target controller with the ones stored initially
/// </summary>
protected override void CustomReset()
{
base.CustomReset();
if (Active && FeedbackTypeAuthorized && (TargetFloatController != null))
{
TargetFloatController.OneTimeDuration = _oneTimeDurationStorage;
TargetFloatController.OneTimeAmplitude = _oneTimeAmplitudeStorage;
TargetFloatController.OneTimeCurve = _oneTimeCurveStorage;
TargetFloatController.OneTimeRemapMin = _oneTimeRemapMinStorage;
TargetFloatController.OneTimeRemapMax = _oneTimeRemapMaxStorage;
TargetFloatController.ToDestinationCurve = _toDestinationCurveStorage;
TargetFloatController.ToDestinationDuration = _toDestinationDurationStorage;
TargetFloatController.ToDestinationValue = _toDestinationValueStorage;
TargetFloatController.RevertToInitialValueAfterEnd = _revertToInitialValueAfterEndStorage;
}
}
/// <summary>
/// On stop, we interrupt movement if it was active
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
if (TargetFloatController != null)
{
TargetFloatController.Stop();
}
}
}
}

View File

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

View File

@@ -0,0 +1,119 @@
using MoreMountains.Tools;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will request the spawn of a floating text, usually to signify damage, but not necessarily
/// This requires that a MMFloatingTextSpawner be correctly setup in the scene, otherwise nothing will happen.
/// To do so, create a new empty object, add a MMFloatingTextSpawner to it. Drag (at least) one MMFloatingText prefab into its PooledSimpleMMFloatingText slot.
/// You'll find such prefabs already made in the MMTools/Tools/MMFloatingText/Prefabs folder, but feel free to create your own.
/// Using that feedback will always spawn the same text. While this may be what you want, if you're using the Corgi Engine or TopDown Engine, you'll find dedicated versions
/// directly hooked to the Health component, letting you display damage taken.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will request the spawn of a floating text, usually to signify damage, but not necessarily. " +
"This requires that a MMFloatingTextSpawner be correctly setup in the scene, otherwise nothing will happen. " +
"To do so, create a new empty object, add a MMFloatingTextSpawner to it. Drag (at least) one MMFloatingText prefab into its PooledSimpleMMFloatingText slot. " +
"You'll find such prefabs already made in the MMTools/Tools/MMFloatingText/Prefabs folder, but feel free to create your own. " +
"Using that feedback will always spawn the same text. While this may be what you want, if you're using the Corgi Engine or TopDown Engine, you'll find dedicated versions " +
"directly hooked to the Health component, letting you display damage taken.")]
[FeedbackPath("UI/Floating Text")]
public class MMFeedbackFloatingText : 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.UIColor; } }
#endif
/// the possible places where the floating text should spawn at
public enum PositionModes { TargetTransform, FeedbackPosition, PlayPosition }
[Header("Floating Text")]
/// the channel to require a floating text spawn on. This has to match the Channel value in the Pooler settings of your chosen MMFloatingTextSpawner
[Tooltip("the channel to require a floating text spawn on. This has to match the Channel value in the general settings of your chosen MMFloatingTextSpawner")]
public int Channel = 0;
/// the Intensity to spawn this text with, will act as a lifetime/movement/scale multiplier based on the spawner's settings
[Tooltip("the Intensity to spawn this text with, will act as a lifetime/movement/scale multiplier based on the spawner's settings")]
public float Intensity = 1f;
/// the value to display when spawning this text
[Tooltip("the value to display when spawning this text")]
public string Value = "100";
/// if this is true, the intensity passed to this feedback will be the value displayed
[Tooltip("if this is true, the intensity passed to this feedback will be the value displayed")]
public bool UseIntensityAsValue = false;
[Header("Color")]
/// whether or not to force a color on the new text, if not, the default colors of the spawner will be used
[Tooltip("whether or not to force a color on the new text, if not, the default colors of the spawner will be used")]
public bool ForceColor = false;
/// the gradient to apply over the lifetime of the text
[Tooltip("the gradient to apply over the lifetime of the text")]
[GradientUsage(true)]
public Gradient AnimateColorGradient = new Gradient();
[Header("Lifetime")]
/// whether or not to force a lifetime on the new text, if not, the default colors of the spawner will be used
[Tooltip("whether or not to force a lifetime on the new text, if not, the default colors of the spawner will be used")]
public bool ForceLifetime = false;
/// the forced lifetime for the spawned text
[Tooltip("the forced lifetime for the spawned text")]
[MMFCondition("ForceLifetime", true)]
public float Lifetime = 0.5f;
[Header("Position")]
/// where to spawn the new text (at the position of the feedback, or on a specified Transform)
[Tooltip("where to spawn the new text (at the position of the feedback, or on a specified Transform)")]
public PositionModes PositionMode = PositionModes.FeedbackPosition;
/// in transform mode, the Transform on which to spawn the new floating text
[Tooltip("in transform mode, the Transform on which to spawn the new floating text")]
[MMFEnumCondition("PositionMode", (int)PositionModes.TargetTransform)]
public Transform TargetTransform;
/// the direction to apply to the new floating text (leave it to 0 to let the Spawner decide based on its settings)
[Tooltip("the direction to apply to the new floating text (leave it to 0 to let the Spawner decide based on its settings)")]
public Vector3 Direction = Vector3.zero;
protected Vector3 _playPosition;
protected string _value;
/// the duration of this feedback is a fixed value or the lifetime
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Lifetime); } set { Lifetime = value; } }
/// <summary>
/// On play we ask the spawner on the specified channel to spawn a new floating text
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
switch (PositionMode)
{
case PositionModes.FeedbackPosition:
_playPosition = this.transform.position;
break;
case PositionModes.PlayPosition:
_playPosition = position;
break;
case PositionModes.TargetTransform:
_playPosition = TargetTransform.position;
break;
}
_value = UseIntensityAsValue ? feedbacksIntensity.ToString() : Value;
MMFloatingTextSpawnEvent.Trigger(ChannelData(Channel), _playPosition, _value, Direction, Intensity * intensityMultiplier, ForceLifetime, Lifetime, ForceColor, AnimateColorGradient, Timing.TimescaleMode == TimescaleModes.Unscaled);
}
}
}

View File

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

View File

@@ -0,0 +1,220 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you animate the density, color, end and start distance of your scene's fog
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will let you animate the density, color, end and start distance of your scene's fog")]
[FeedbackPath("Renderer/Fog")]
public class MMFeedbackFog : 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.RendererColor; } }
#endif
/// the possible modes for this feedback
public enum Modes { OverTime, Instant }
[Header("Fog")]
/// whether the feedback should affect the sprite renderer instantly or over a period of time
[Tooltip("whether the feedback should affect the sprite renderer instantly or over a period of time")]
public Modes Mode = Modes.OverTime;
/// how long the sprite renderer should change over time
[Tooltip("how long the sprite renderer should change over time")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float Duration = 0.2f;
/// if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over
[Tooltip("if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over")]
public bool AllowAdditivePlays = false;
[Header("Fog Density")]
/// whether or not to modify the fog's density
[Tooltip("whether or not to modify the fog's density")]
public bool ModifyFogDensity = true;
/// a curve to use to animate the fog's density over time
[Tooltip("a curve to use to animate the fog's density over time")]
public MMTweenType DensityCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the fog's density curve zero value to
[Tooltip("the value to remap the fog's density curve zero value to")]
public float DensityRemapZero = 0.01f;
/// the value to remap the fog's density curve one value to
[Tooltip("the value to remap the fog's density curve one value to")]
public float DensityRemapOne = 0.05f;
/// the value to change the fog's density to when in instant mode
[Tooltip("the value to change the fog's density to when in instant mode")]
public float DensityInstantChange;
[Header("Fog Start Distance")]
/// whether or not to modify the fog's start distance
[Tooltip("whether or not to modify the fog's start distance")]
public bool ModifyStartDistance = true;
/// a curve to use to animate the fog's start distance over time
[Tooltip("a curve to use to animate the fog's start distance over time")]
public MMTweenType StartDistanceCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the fog's start distance curve zero value to
[Tooltip("the value to remap the fog's start distance curve zero value to")]
public float StartDistanceRemapZero = 0f;
/// the value to remap the fog's start distance curve one value to
[Tooltip("the value to remap the fog's start distance curve one value to")]
public float StartDistanceRemapOne = 0f;
/// the value to change the fog's start distance to when in instant mode
[Tooltip("the value to change the fog's start distance to when in instant mode")]
public float StartDistanceInstantChange;
[Header("Fog End Distance")]
/// whether or not to modify the fog's end distance
[Tooltip("whether or not to modify the fog's end distance")]
public bool ModifyEndDistance = true;
/// a curve to use to animate the fog's end distance over time
[Tooltip("a curve to use to animate the fog's end distance over time")]
public MMTweenType EndDistanceCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the fog's end distance curve zero value to
[Tooltip("the value to remap the fog's end distance curve zero value to")]
public float EndDistanceRemapZero = 0f;
/// the value to remap the fog's end distance curve one value to
[Tooltip("the value to remap the fog's end distance curve one value to")]
public float EndDistanceRemapOne = 300f;
/// the value to change the fog's end distance to when in instant mode
[Tooltip("the value to change the fog's end distance to when in instant mode")]
public float EndDistanceInstantChange;
[Header("Fog Color")]
/// whether or not to modify the fog's color
[Tooltip("whether or not to modify the fog's color")]
public bool ModifyColor = true;
/// the colors to apply to the sprite renderer over time
[Tooltip("the colors to apply to the sprite renderer over time")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public Gradient ColorOverTime;
/// the color to move to in instant mode
[Tooltip("the color to move to in instant mode")]
[MMFEnumCondition("Mode", (int)Modes.Instant)]
public Color InstantColor;
/// the duration of this feedback is the duration of the sprite renderer, or 0 if instant
public override float FeedbackDuration { get { return (Mode == Modes.Instant) ? 0f : ApplyTimeMultiplier(Duration); } set { if (Mode != Modes.Instant) { Duration = value; } } }
protected Coroutine _coroutine;
/// <summary>
/// On Play we change the values of our fog
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
switch (Mode)
{
case Modes.Instant:
if (ModifyColor)
{
RenderSettings.fogColor = InstantColor;
}
if (ModifyStartDistance)
{
RenderSettings.fogStartDistance = StartDistanceInstantChange;
}
if (ModifyEndDistance)
{
RenderSettings.fogEndDistance = EndDistanceInstantChange;
}
if (ModifyFogDensity)
{
RenderSettings.fogDensity = DensityInstantChange * intensityMultiplier;
}
break;
case Modes.OverTime:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
_coroutine = StartCoroutine(FogSequence(intensityMultiplier));
break;
}
}
/// <summary>
/// This coroutine will modify the values on the fog settings
/// </summary>
/// <returns></returns>
protected virtual IEnumerator FogSequence(float intensityMultiplier)
{
IsPlaying = true;
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
{
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
SetFogValues(remappedTime, intensityMultiplier);
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
yield return null;
}
SetFogValues(FinalNormalizedTime, intensityMultiplier);
_coroutine = null;
IsPlaying = false;
yield return null;
}
/// <summary>
/// Sets the various values on the fog on a specified time (between 0 and 1)
/// </summary>
/// <param name="time"></param>
protected virtual void SetFogValues(float time, float intensityMultiplier)
{
if (ModifyColor)
{
RenderSettings.fogColor = ColorOverTime.Evaluate(time);
}
if (ModifyFogDensity)
{
RenderSettings.fogDensity = MMTween.Tween(time, 0f, 1f, DensityRemapZero, DensityRemapOne, DensityCurve) * intensityMultiplier;
}
if (ModifyStartDistance)
{
RenderSettings.fogStartDistance = MMTween.Tween(time, 0f, 1f, StartDistanceRemapZero, StartDistanceRemapOne, StartDistanceCurve);
}
if (ModifyEndDistance)
{
RenderSettings.fogEndDistance = MMTween.Tween(time, 0f, 1f, EndDistanceRemapZero, EndDistanceRemapOne, EndDistanceCurve);
}
}
/// <summary>
/// Stops this feedback
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized || (_coroutine == null))
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
IsPlaying = false;
StopCoroutine(_coroutine);
_coroutine = null;
}
}
}

View File

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

View File

@@ -0,0 +1,195 @@
using System.Collections;
using System.Collections.Generic;
using MoreMountains.Tools;
using UnityEngine;
using UnityEngine.UI;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you change the alpha of a target sprite renderer over time.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will let you change the alpha of a target Image over time.")]
[FeedbackPath("UI/Image Alpha")]
public class MMFeedbackImageAlpha : 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.UIColor; } }
#endif
/// the possible modes for this feedback
public enum Modes { OverTime, Instant, ToDestination }
[Header("Sprite Renderer")]
/// the Image to affect when playing the feedback
[Tooltip("the Image to affect when playing the feedback")]
public Image BoundImage;
/// whether the feedback should affect the Image instantly or over a period of time
[Tooltip("whether the feedback should affect the Image instantly or over a period of time")]
public Modes Mode = Modes.OverTime;
/// how long the Image should change over time
[Tooltip("how long the Image should change over time")]
[MMFEnumCondition("Mode", (int)Modes.OverTime, (int)Modes.ToDestination)]
public float Duration = 0.2f;
/// if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over
[Tooltip("if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over")]
public bool AllowAdditivePlays = false;
[Header("Alpha")]
/// the alpha to move to in instant mode
[Tooltip("the alpha to move to in instant mode")]
[MMFEnumCondition("Mode", (int)Modes.Instant)]
public float InstantAlpha = 1f;
/// the curve to use when interpolating towards the destination alpha
[Tooltip("the curve to use when interpolating towards the destination alpha")]
[MMFEnumCondition("Mode", (int)Modes.OverTime, (int)Modes.ToDestination)]
public MMTweenType Curve = new MMTweenType(MMTween.MMTweenCurve.EaseInCubic);
/// the value to which the curve's 0 should be remapped
[Tooltip("the value to which the curve's 0 should be remapped")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float CurveRemapZero = 0f;
/// the value to which the curve's 1 should be remapped
[Tooltip("the value to which the curve's 1 should be remapped")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float CurveRemapOne = 1f;
/// the alpha to aim towards when in ToDestination mode
[Tooltip("the alpha to aim towards when in ToDestination mode")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float DestinationAlpha = 1f;
/// the duration of this feedback is the duration of the Image, or 0 if instant
public override float FeedbackDuration { get { return (Mode == Modes.Instant) ? 0f : ApplyTimeMultiplier(Duration); } set { Duration = value; } }
protected Coroutine _coroutine;
protected Color _imageColor;
protected float _initialAlpha;
/// <summary>
/// On init we turn the Image off if needed
/// </summary>
/// <param name="owner"></param>
protected override void CustomInitialization(GameObject owner)
{
base.CustomInitialization(owner);
}
/// <summary>
/// On Play we turn our Image on and start an over time coroutine if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
Turn(true);
switch (Mode)
{
case Modes.Instant:
_imageColor = BoundImage.color;
_imageColor.a = InstantAlpha;
BoundImage.color = _imageColor;
break;
case Modes.OverTime:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
_coroutine = StartCoroutine(ImageSequence());
break;
case Modes.ToDestination:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
_coroutine = StartCoroutine(ImageSequence());
break;
}
}
/// <summary>
/// This coroutine will modify the values on the Image
/// </summary>
/// <returns></returns>
protected virtual IEnumerator ImageSequence()
{
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
_imageColor = BoundImage.color;
_initialAlpha = BoundImage.color.a;
IsPlaying = true;
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
{
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
SetAlpha(remappedTime);
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
yield return null;
}
SetAlpha(FinalNormalizedTime);
_coroutine = null;
IsPlaying = false;
yield return null;
}
/// <summary>
/// Sets the various values on the sprite renderer on a specified time (between 0 and 1)
/// </summary>
/// <param name="time"></param>
protected virtual void SetAlpha(float time)
{
float newAlpha = 0f;
if (Mode == Modes.OverTime)
{
newAlpha = MMTween.Tween(time, 0f, 1f, CurveRemapZero, CurveRemapOne, Curve);
}
else if (Mode == Modes.ToDestination)
{
newAlpha = MMTween.Tween(time, 0f, 1f, _initialAlpha, DestinationAlpha, Curve);
}
_imageColor.a = newAlpha;
BoundImage.color = _imageColor;
}
/// <summary>
/// Turns the sprite renderer off on stop
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
IsPlaying = false;
base.CustomStopFeedback(position, feedbacksIntensity);
Turn(false);
_coroutine = null;
}
/// <summary>
/// Turns the sprite renderer on or off
/// </summary>
/// <param name="status"></param>
protected virtual void Turn(bool status)
{
BoundImage.gameObject.SetActive(status);
BoundImage.enabled = status;
}
}
}

View File

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

View File

@@ -0,0 +1,119 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
using UnityEngine.SceneManagement;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will request the load of a new scene, using the method of your choice
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will request the load of a new scene, using the method of your choice")]
[FeedbackPath("Scene/Load Scene")]
public class MMFeedbackLoadScene : 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.SceneColor; } }
#endif
/// the possible ways to load a new scene :
/// - direct : uses Unity's SceneManager API
/// - MMSceneLoadingManager : the simple, original MM way of loading scenes
/// - MMAdditiveSceneLoadingManager : a more advanced way of loading scenes, with (way) more options
public enum LoadingModes { Direct, MMSceneLoadingManager, MMAdditiveSceneLoadingManager }
[Header("Scene Names")]
/// the name of the loading screen scene to use
[Tooltip("the name of the loading screen scene to use - HAS TO BE ADDED TO YOUR BUILD SETTINGS")]
public string LoadingSceneName = "MMAdditiveLoadingScreen";
/// the name of the destination scene
[Tooltip("the name of the destination scene - HAS TO BE ADDED TO YOUR BUILD SETTINGS")]
public string DestinationSceneName = "";
[Header("Mode")]
/// the loading mode to use
[Tooltip("the loading mode to use to load the destination scene : " +
"- direct : uses Unity's SceneManager API" +
"- MMSceneLoadingManager : the simple, original MM way of loading scenes" +
"- MMAdditiveSceneLoadingManager : a more advanced way of loading scenes, with (way) more options")]
public LoadingModes LoadingMode = LoadingModes.MMAdditiveSceneLoadingManager;
[Header("Loading Scene Manager")]
/// the priority to use when loading the new scenes
[Tooltip("the priority to use when loading the new scenes")]
public ThreadPriority Priority = ThreadPriority.High;
/// whether or not to interpolate progress (slower, but usually looks better and smoother)
[Tooltip("whether or not to interpolate progress (slower, but usually looks better and smoother)")]
public bool InterpolateProgress = true;
/// whether or not to perform extra checks to make sure the loading screen and destination scene are in the build settings
[Tooltip("whether or not to perform extra checks to make sure the loading screen and destination scene are in the build settings")]
public bool SecureLoad = true;
[Header("Loading Scene Delays")]
/// a delay (in seconds) to apply before the first fade plays
[Tooltip("a delay (in seconds) to apply before the first fade plays")]
public float BeforeEntryFadeDelay = 0f;
/// the duration (in seconds) of the entry fade
[Tooltip("the duration (in seconds) of the entry fade")]
public float EntryFadeDuration = 0.2f;
/// a delay (in seconds) to apply after the first fade plays
[Tooltip("a delay (in seconds) to apply after the first fade plays")]
public float AfterEntryFadeDelay = 0f;
/// a delay (in seconds) to apply before the exit fade plays
[Tooltip("a delay (in seconds) to apply before the exit fade plays")]
public float BeforeExitFadeDelay = 0f;
/// the duration (in seconds) of the exit fade
[Tooltip("the duration (in seconds) of the exit fade")]
public float ExitFadeDuration = 0.2f;
[Header("Transitions")]
/// the speed at which the progress bar should move if interpolated
[Tooltip("the speed at which the progress bar should move if interpolated")]
public float ProgressInterpolationSpeed = 5f;
/// the order in which to play fades (really depends on the type of fader you have in your loading screen
[Tooltip("the order in which to play fades (really depends on the type of fader you have in your loading screen")]
public MMAdditiveSceneLoadingManager.FadeModes FadeMode = MMAdditiveSceneLoadingManager.FadeModes.FadeInThenOut;
/// the tween to use on the entry fade
[Tooltip("the tween to use on the entry fade")]
public MMTweenType EntryFadeTween = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
/// the tween to use on the exit fade
[Tooltip("the tween to use on the exit fade")]
public MMTweenType ExitFadeTween = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
/// <summary>
/// On play, we request a load of the destination scene using hte specified method
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (LoadingMode)
{
case LoadingModes.Direct:
SceneManager.LoadScene(DestinationSceneName);
break;
case LoadingModes.MMSceneLoadingManager:
MMSceneLoadingManager.LoadScene(DestinationSceneName, LoadingSceneName);
break;
case LoadingModes.MMAdditiveSceneLoadingManager:
MMAdditiveSceneLoadingManager.LoadScene(DestinationSceneName, LoadingSceneName,
Priority, SecureLoad, InterpolateProgress,
BeforeEntryFadeDelay, EntryFadeDuration,
AfterEntryFadeDelay,
BeforeExitFadeDelay, ExitFadeDuration,
EntryFadeTween, ExitFadeTween,
ProgressInterpolationSpeed, FadeMode);
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will trigger a MMGameEvent of the specified name when played
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will trigger a MMGameEvent of the specified name when played")]
[FeedbackPath("Events/MMGameEvent")]
public class MMFeedbackMMGameEvent : 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.EventsColor; } }
#endif
public string MMGameEventName;
/// <summary>
/// On Play we change the values of our fog
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMGameEvent.Trigger(MMGameEventName);
}
}
}

View File

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

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// A feedback used to control all sounds playing on the MMSoundManager at once. It'll let you pause, play, stop and free (stop and returns the audiosource to the pool) sounds. You will need a MMSoundManager in your scene for this to work.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager All Sounds Control")]
[FeedbackHelp("A feedback used to control all sounds playing on the MMSoundManager at once. It'll let you pause, play, stop and free (stop and returns the audiosource to the pool) sounds. You will need a MMSoundManager in your scene for this to work.")]
public class MMFeedbackMMSoundManagerAllSoundsControl : 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.SoundsColor; } }
#endif
[Header("MMSoundManager All Sounds Control")]
/// The selected control mode.
[Tooltip("The selected control mode")]
public MMSoundManagerAllSoundsControlEventTypes ControlMode = MMSoundManagerAllSoundsControlEventTypes.Pause;
/// <summary>
/// On Play, we call the specified event, to be caught by the MMSoundManager
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (ControlMode)
{
case MMSoundManagerAllSoundsControlEventTypes.Pause:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.Pause);
break;
case MMSoundManagerAllSoundsControlEventTypes.Play:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.Play);
break;
case MMSoundManagerAllSoundsControlEventTypes.Stop:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.Stop);
break;
case MMSoundManagerAllSoundsControlEventTypes.Free:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.Free);
break;
case MMSoundManagerAllSoundsControlEventTypes.FreeAllButPersistent:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.FreeAllButPersistent);
break;
case MMSoundManagerAllSoundsControlEventTypes.FreeAllLooping:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.FreeAllLooping);
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,60 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you trigger save, load, and reset on MMSoundManager settings. You will need a MMSoundManager in your scene for this to work.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager Save and Load")]
[FeedbackHelp("This feedback will let you trigger save, load, and reset on MMSoundManager settings. You will need a MMSoundManager in your scene for this to work.")]
public class MMFeedbackMMSoundManagerSaveLoad : 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.SoundsColor; } }
#endif
/// the possible modes you can use to interact with save settings
public enum Modes { Save, Load, Reset }
[Header("MMSoundManager Save and Load")]
/// the selected mode to interact with save settings on the MMSoundManager
[Tooltip("the selected mode to interact with save settings on the MMSoundManager")]
public Modes Mode = Modes.Save;
/// <summary>
/// On Play, saves, loads or resets settings
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (Mode)
{
case Modes.Save:
MMSoundManagerEvent.Trigger(MMSoundManagerEventTypes.SaveSettings);
break;
case Modes.Load:
MMSoundManagerEvent.Trigger(MMSoundManagerEventTypes.LoadSettings);
break;
case Modes.Reset:
MMSoundManagerEvent.Trigger(MMSoundManagerEventTypes.ResetSettings);
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,390 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
using UnityEngine.SceneManagement;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you play a sound via the MMSoundManager. You will need a game object in your scene with a MMSoundManager object on it for this to work.
/// </summary>
[ExecuteAlways]
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager Sound")]
[FeedbackHelp("This feedback will let you play a sound via the MMSoundManager. You will need a game object in your scene with a MMSoundManager object on it for this to work.")]
public class MMFeedbackMMSoundManagerSound : 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.SoundsColor; } }
#endif
/// the duration of this feedback is the duration of the clip being played
public override float FeedbackDuration { get { return GetDuration(); } }
[Header("Sound")]
/// the sound clip to play
[Tooltip("the sound clip to play")]
public AudioClip Sfx;
[Header("Random Sound")]
/// an array to pick a random sfx from
[Tooltip("an array to pick a random sfx from")]
public AudioClip[] RandomSfx;
[Header("Test")]
[MMFInspectorButton("TestPlaySound")]
public bool TestButton;
[MMFInspectorButton("TestStopSound")]
public bool TestStopButton;
[Header("Volume")]
/// the minimum volume to play the sound at
[Tooltip("the minimum volume to play the sound at")]
[Range(0f,2f)]
public float MinVolume = 1f;
/// the maximum volume to play the sound at
[Tooltip("the maximum volume to play the sound at")]
[Range(0f,2f)]
public float MaxVolume = 1f;
[Header("Pitch")]
/// the minimum pitch to play the sound at
[Tooltip("the minimum pitch to play the sound at")]
[Range(-3f,3f)]
public float MinPitch = 1f;
/// the maximum pitch to play the sound at
[Tooltip("the maximum pitch to play the sound at")]
[Range(-3f,3f)]
public float MaxPitch = 1f;
[Header("SoundManager Options")]
/// the track on which to play the sound. Pick the one that matches the nature of your sound
[Tooltip("the track on which to play the sound. Pick the one that matches the nature of your sound")]
public MMSoundManager.MMSoundManagerTracks MmSoundManagerTrack = MMSoundManager.MMSoundManagerTracks.Sfx;
/// the ID of the sound. This is useful if you plan on using sound control feedbacks on it afterwards.
[Tooltip("the ID of the sound. This is useful if you plan on using sound control feedbacks on it afterwards.")]
public int ID = 0;
/// the AudioGroup on which to play the sound. If you're already targeting a preset track, you can leave it blank, otherwise the group you specify here will override it.
[Tooltip("the AudioGroup on which to play the sound. If you're already targeting a preset track, you can leave it blank, otherwise the group you specify here will override it.")]
public AudioMixerGroup AudioGroup = null;
/// if (for some reason) you've already got an audiosource and wouldn't like to use the built-in pool system, you can specify it here
[Tooltip("if (for some reason) you've already got an audiosource and wouldn't like to use the built-in pool system, you can specify it here")]
public AudioSource RecycleAudioSource = null;
/// whether or not this sound should loop
[Tooltip("whether or not this sound should loop")]
public bool Loop = false;
/// whether or not this sound should continue playing when transitioning to another scene
[Tooltip("whether or not this sound should continue playing when transitioning to another scene")]
public bool Persistent = false;
/// whether or not this sound should play if the same sound clip is already playing
[Tooltip("whether or not this sound should play if the same sound clip is already playing")]
public bool DoNotPlayIfClipAlreadyPlaying = false;
/// if this is true, this sound will stop playing when stopping the feedback
[Tooltip("if this is true, this sound will stop playing when stopping the feedback")]
public bool StopSoundOnFeedbackStop = false;
/// if this is true, this sound won't be recycled if it's not done playing
[Tooltip("if this is true, this sound won't be recycled if it's not done playing")]
public bool DoNotAutoRecycleIfNotDonePlaying = false;
[Header("Fade")]
/// whether or not to fade this sound in when playing it
[Tooltip("whether or not to fade this sound in when playing it")]
public bool Fade = false;
/// if fading, the volume at which to start the fade
[Tooltip("if fading, the volume at which to start the fade")]
[MMCondition("Fade", true)]
public float FadeInitialVolume = 0f;
/// if fading, the duration of the fade, in seconds
[Tooltip("if fading, the duration of the fade, in seconds")]
[MMCondition("Fade", true)]
public float FadeDuration = 1f;
/// if fading, the tween over which to fade the sound
[Tooltip("if fading, the tween over which to fade the sound ")]
[MMCondition("Fade", true)]
public MMTweenType FadeTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic);
[Header("Solo")]
/// whether or not this sound should play in solo mode over its destination track. If yes, all other sounds on that track will be muted when this sound starts playing
[Tooltip("whether or not this sound should play in solo mode over its destination track. If yes, all other sounds on that track will be muted when this sound starts playing")]
public bool SoloSingleTrack = false;
/// whether or not this sound should play in solo mode over all other tracks. If yes, all other tracks will be muted when this sound starts playing
[Tooltip("whether or not this sound should play in solo mode over all other tracks. If yes, all other tracks will be muted when this sound starts playing")]
public bool SoloAllTracks = false;
/// if in any of the above solo modes, AutoUnSoloOnEnd will unmute the track(s) automatically once that sound stops playing
[Tooltip("if in any of the above solo modes, AutoUnSoloOnEnd will unmute the track(s) automatically once that sound stops playing")]
public bool AutoUnSoloOnEnd = false;
[Header("Spatial Settings")]
/// Pans a playing sound in a stereo way (left or right). This only applies to sounds that are Mono or Stereo.
[Tooltip("Pans a playing sound in a stereo way (left or right). This only applies to sounds that are Mono or Stereo.")]
[Range(-1f,1f)]
public float PanStereo;
/// Sets how much this AudioSource is affected by 3D spatialisation calculations (attenuation, doppler etc). 0.0 makes the sound full 2D, 1.0 makes it full 3D.
[Tooltip("Sets how much this AudioSource is affected by 3D spatialisation calculations (attenuation, doppler etc). 0.0 makes the sound full 2D, 1.0 makes it full 3D.")]
[Range(0f,1f)]
public float SpatialBlend;
[Header("Effects")]
/// Bypass effects (Applied from filter components or global listener filters).
[Tooltip("Bypass effects (Applied from filter components or global listener filters).")]
public bool BypassEffects = false;
/// When set global effects on the AudioListener will not be applied to the audio signal generated by the AudioSource. Does not apply if the AudioSource is playing into a mixer group.
[Tooltip("When set global effects on the AudioListener will not be applied to the audio signal generated by the AudioSource. Does not apply if the AudioSource is playing into a mixer group.")]
public bool BypassListenerEffects = false;
/// When set doesn't route the signal from an AudioSource into the global reverb associated with reverb zones.
[Tooltip("When set doesn't route the signal from an AudioSource into the global reverb associated with reverb zones.")]
public bool BypassReverbZones = false;
/// Sets the priority of the AudioSource.
[Tooltip("Sets the priority of the AudioSource.")]
[Range(0, 256)]
public int Priority = 128;
/// The amount by which the signal from the AudioSource will be mixed into the global reverb associated with the Reverb Zones.
[Tooltip("The amount by which the signal from the AudioSource will be mixed into the global reverb associated with the Reverb Zones.")]
[Range(0f,1.1f)]
public float ReverbZoneMix = 1f;
[Header("3D Sound Settings")]
/// Sets the Doppler scale for this AudioSource.
[Tooltip("Sets the Doppler scale for this AudioSource.")]
[Range(0f,5f)]
public float DopplerLevel = 1f;
/// Sets the spread angle (in degrees) of a 3d stereo or multichannel sound in speaker space.
[Tooltip("Sets the spread angle (in degrees) of a 3d stereo or multichannel sound in speaker space.")]
[Range(0,360)]
public int Spread = 0;
/// Sets/Gets how the AudioSource attenuates over distance.
[Tooltip("Sets/Gets how the AudioSource attenuates over distance.")]
public AudioRolloffMode RolloffMode = AudioRolloffMode.Logarithmic;
/// Within the Min distance the AudioSource will cease to grow louder in volume.
[Tooltip("Within the Min distance the AudioSource will cease to grow louder in volume.")]
public float MinDistance = 1f;
/// (Logarithmic rolloff) MaxDistance is the distance a sound stops attenuating at.
[Tooltip("(Logarithmic rolloff) MaxDistance is the distance a sound stops attenuating at.")]
public float MaxDistance = 500f;
protected AudioClip _randomClip;
protected AudioSource _editorAudioSource;
protected MMSoundManagerPlayOptions _options;
protected AudioSource _playedAudioSource;
/// <summary>
/// Plays either a random sound or the specified sfx
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
if (Sfx != null)
{
PlaySound(Sfx, position, intensityMultiplier);
return;
}
if (RandomSfx.Length > 0)
{
_randomClip = RandomSfx[Random.Range(0, RandomSfx.Length)];
if (_randomClip != null)
{
PlaySound(_randomClip, position, intensityMultiplier);
}
}
}
/// <summary>
/// On Stop, we stop our sound if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
if (StopSoundOnFeedbackStop && (_playedAudioSource != null))
{
_playedAudioSource.Stop();
}
}
/// <summary>
/// Triggers a play sound event
/// </summary>
/// <param name="sfx"></param>
/// <param name="position"></param>
/// <param name="intensity"></param>
protected virtual void PlaySound(AudioClip sfx, Vector3 position, float intensity)
{
if (DoNotPlayIfClipAlreadyPlaying)
{
if (MMSoundManager.Instance.FindByClip(sfx) != null)
{
return;
}
}
float volume = Random.Range(MinVolume, MaxVolume);
if (!Timing.ConstantIntensity)
{
volume = volume * intensity;
}
float pitch = Random.Range(MinPitch, MaxPitch);
int timeSamples = NormalPlayDirection ? 0 : sfx.samples - 1;
/*if (!NormalPlayDirection)
{
pitch = -pitch;
}*/
_options.MmSoundManagerTrack = MmSoundManagerTrack;
_options.Location = position;
_options.Loop = Loop;
_options.Volume = volume;
_options.ID = ID;
_options.Fade = Fade;
_options.FadeInitialVolume = FadeInitialVolume;
_options.FadeDuration = FadeDuration;
_options.FadeTween = FadeTween;
_options.Persistent = Persistent;
_options.RecycleAudioSource = RecycleAudioSource;
_options.AudioGroup = AudioGroup;
_options.Pitch = pitch;
_options.PanStereo = PanStereo;
_options.SpatialBlend = SpatialBlend;
_options.SoloSingleTrack = SoloSingleTrack;
_options.SoloAllTracks = SoloAllTracks;
_options.AutoUnSoloOnEnd = AutoUnSoloOnEnd;
_options.BypassEffects = BypassEffects;
_options.BypassListenerEffects = BypassListenerEffects;
_options.BypassReverbZones = BypassReverbZones;
_options.Priority = Priority;
_options.ReverbZoneMix = ReverbZoneMix;
_options.DopplerLevel = DopplerLevel;
_options.Spread = Spread;
_options.RolloffMode = RolloffMode;
_options.MinDistance = MinDistance;
_options.MaxDistance = MaxDistance;
_options.DoNotAutoRecycleIfNotDonePlaying = DoNotAutoRecycleIfNotDonePlaying;
_playedAudioSource = MMSoundManagerSoundPlayEvent.Trigger(sfx, _options);
}
/// <summary>
/// Returns the duration of the sound, or of the longest of the random sounds
/// </summary>
/// <returns></returns>
protected virtual float GetDuration()
{
if (Sfx != null)
{
return Sfx.length;
}
float longest = 0f;
if ((RandomSfx != null) && (RandomSfx.Length > 0))
{
foreach (AudioClip clip in RandomSfx)
{
if ((clip != null) && (clip.length > longest))
{
longest = clip.length;
}
}
return longest;
}
return 0f;
}
#region TestMethods
/// <summary>
/// A test method that creates an audiosource, plays it, and destroys itself after play
/// </summary>
protected virtual async void TestPlaySound()
{
AudioClip tmpAudioClip = null;
if (Sfx != null)
{
tmpAudioClip = Sfx;
}
if (RandomSfx.Length > 0)
{
tmpAudioClip = RandomSfx[Random.Range(0, RandomSfx.Length)];
}
if (tmpAudioClip == null)
{
Debug.LogError(Label + " on " + this.gameObject.name + " can't play in editor mode, you haven't set its Sfx.");
return;
}
float volume = Random.Range(MinVolume, MaxVolume);
float pitch = Random.Range(MinPitch, MaxPitch);
GameObject temporaryAudioHost = new GameObject("EditorTestAS_WillAutoDestroy");
SceneManager.MoveGameObjectToScene(temporaryAudioHost.gameObject, this.gameObject.scene);
temporaryAudioHost.transform.position = this.transform.position;
_editorAudioSource = temporaryAudioHost.AddComponent<AudioSource>() as AudioSource;
PlayAudioSource(_editorAudioSource, tmpAudioClip, volume, pitch, 0);
float length = 1000 * tmpAudioClip.length;
length = length / Mathf.Abs(pitch);
await Task.Delay((int)length);
DestroyImmediate(temporaryAudioHost);
}
/// <summary>
/// A test method that stops the test sound
/// </summary>
protected virtual void TestStopSound()
{
if (_editorAudioSource != null)
{
_editorAudioSource.Stop();
}
}
/// <summary>
/// Plays the audio source with the specified volume and pitch
/// </summary>
/// <param name="audioSource"></param>
/// <param name="sfx"></param>
/// <param name="volume"></param>
/// <param name="pitch"></param>
protected virtual void PlayAudioSource(AudioSource audioSource, AudioClip sfx, float volume, float pitch, int timeSamples)
{
// we set that audio source clip to the one in paramaters
audioSource.clip = sfx;
audioSource.timeSamples = timeSamples;
// we set the audio source volume to the one in parameters
audioSource.volume = volume;
audioSource.pitch = pitch;
// we set our loop setting
audioSource.loop = false;
// we start playing the sound
audioSource.Play();
}
#endregion
}
}

View File

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

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you control a specific sound (or sounds), targeted by SoundID, which has to match the SoundID of the sound you intially played. You will need a MMSoundManager in your scene for this to work.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager Sound Control")]
[FeedbackHelp("This feedback will let you control a specific sound (or sounds), targeted by SoundID, which has to match the SoundID of the sound you intially played. You will need a MMSoundManager in your scene for this to work.")]
public class MMFeedbackMMSoundManagerSoundControl : 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.SoundsColor; } }
#endif
[Header("MMSoundManager Sound Control")]
/// the action to trigger on the specified sound
[Tooltip("the action to trigger on the specified sound")]
public MMSoundManagerSoundControlEventTypes ControlMode = MMSoundManagerSoundControlEventTypes.Pause;
/// the ID of the sound, has to match the one you specified when playing it
[Tooltip("the ID of the sound, has to match the one you specified when playing it")]
public int SoundID = 0;
protected AudioSource _targetAudioSource;
/// <summary>
/// On play, triggers an event meant to be caught by the MMSoundManager and acted upon
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMSoundManagerSoundControlEvent.Trigger(ControlMode, SoundID);
}
}
}

View File

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

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you trigger fades on a specific sound via the MMSoundManager. You will need a MMSoundManager in your scene for this to work.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager Sound Fade")]
[FeedbackHelp("This feedback lets you trigger fades on a specific sound via the MMSoundManager. You will need a MMSoundManager in your scene for this to work.")]
public class MMFeedbackMMSoundManagerSoundFade : 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.SoundsColor; } }
#endif
[Header("MMSoundManager Sound Fade")]
/// the ID of the sound you want to fade. Has to match the ID you specified when playing the sound initially
[Tooltip("the ID of the sound you want to fade. Has to match the ID you specified when playing the sound initially")]
public int SoundID = 0;
/// the duration of the fade, in seconds
[Tooltip("the duration of the fade, in seconds")]
public float FadeDuration = 1f;
/// the volume towards which to fade
[Tooltip("the volume towards which to fade")]
[Range(MMSoundManagerSettings._minimalVolume,MMSoundManagerSettings._maxVolume)]
public float FinalVolume = MMSoundManagerSettings._minimalVolume;
/// the tween to apply over the fade
[Tooltip("the tween to apply over the fade")]
public MMTweenType FadeTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic);
protected AudioSource _targetAudioSource;
/// <summary>
/// On play, we start our fade via a fade event
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMSoundManagerSoundFadeEvent.Trigger(SoundID, FadeDuration, FinalVolume, FadeTween);
}
}
}

View File

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

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you control all sounds playing on a specific track (master, UI, music, sfx), and play, pause, mute, unmute, resume, stop, free them all at once. You will need a MMSoundManager in your scene for this to work.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager Track Control")]
[FeedbackHelp("This feedback will let you control all sounds playing on a specific track (master, UI, music, sfx), and play, pause, mute, unmute, resume, stop, free them all at once. You will need a MMSoundManager in your scene for this to work.")]
public class MMFeedbackMMSoundManagerTrackControl : 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.SoundsColor; } }
#endif
/// the possible modes you can use to interact with the track. Free will stop all sounds and return them to the pool
public enum ControlModes { Mute, UnMute, SetVolume, Pause, Play, Stop, Free }
[Header("MMSoundManager Track Control")]
/// the track to mute/unmute/pause/play/stop/free/etc
[Tooltip("the track to mute/unmute/pause/play/stop/free/etc")]
public MMSoundManager.MMSoundManagerTracks Track;
/// the selected control mode to interact with the track. Free will stop all sounds and return them to the pool
[Tooltip("the selected control mode to interact with the track. Free will stop all sounds and return them to the pool")]
public ControlModes ControlMode = ControlModes.Pause;
/// if setting the volume, the volume to assign to the track
[Tooltip("if setting the volume, the volume to assign to the track")]
[MMEnumCondition("ControlMode", (int) ControlModes.SetVolume)]
public float Volume = 0.5f;
/// <summary>
/// On play, orders the entire track to follow the specific command, via a MMSoundManager event
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (ControlMode)
{
case ControlModes.Mute:
MMSoundManagerTrackEvent.Trigger(MMSoundManagerTrackEventTypes.MuteTrack, Track);
break;
case ControlModes.UnMute:
MMSoundManagerTrackEvent.Trigger(MMSoundManagerTrackEventTypes.UnmuteTrack, Track);
break;
case ControlModes.SetVolume:
MMSoundManagerTrackEvent.Trigger(MMSoundManagerTrackEventTypes.SetVolumeTrack, Track, Volume);
break;
case ControlModes.Pause:
MMSoundManagerTrackEvent.Trigger(MMSoundManagerTrackEventTypes.PauseTrack, Track);
break;
case ControlModes.Play:
MMSoundManagerTrackEvent.Trigger(MMSoundManagerTrackEventTypes.PlayTrack, Track);
break;
case ControlModes.Stop:
MMSoundManagerTrackEvent.Trigger(MMSoundManagerTrackEventTypes.StopTrack, Track);
break;
case ControlModes.Free:
MMSoundManagerTrackEvent.Trigger(MMSoundManagerTrackEventTypes.FreeTrack, Track);
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you fade all the sounds on a specific track at once. You will need a MMSoundManager in your scene for this to work.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager Track Fade")]
[FeedbackHelp("This feedback will let you fade all the sounds on a specific track at once. You will need a MMSoundManager in your scene for this to work.")]
public class MMFeedbackMMSoundManagerTrackFade : 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.SoundsColor; } }
#endif
/// the duration of this feedback is the duration of the fade
public override float FeedbackDuration { get { return FadeDuration; } }
[Header("MMSoundManager Track Fade")]
/// the track to fade the volume on
[Tooltip("the track to fade the volume on")]
public MMSoundManager.MMSoundManagerTracks Track;
/// the duration of the fade, in seconds
[Tooltip("the duration of the fade, in seconds")]
public float FadeDuration = 1f;
/// the volume to reach at the end of the fade
[Tooltip("the volume to reach at the end of the fade")]
[Range(MMSoundManagerSettings._minimalVolume,MMSoundManagerSettings._maxVolume)]
public float FinalVolume = MMSoundManagerSettings._minimalVolume;
/// the tween to operate the fade on
[Tooltip("the tween to operate the fade on")]
public MMTweenType FadeTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic);
/// <summary>
/// On Play, triggers a fade event, meant to be caught by the MMSoundManager
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMSoundManagerTrackFadeEvent.Trigger(Track, FadeDuration, FinalVolume, FadeTween);
}
}
}

View File

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

View File

@@ -0,0 +1,80 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will trigger a post processing moving filter event, meant to be caught by a MMPostProcessingMovableFilter object
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will trigger a post processing moving filter event, meant to be caught by a MMPostProcessingMovableFilter object")]
[FeedbackPath("PostProcess/PPMovingFilter")]
public class MMFeedbackPPMovingFilter : 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
/// the possible modes for this feedback
public enum Modes { Toggle, On, Off }
[Header("PostProcessing Profile Moving Filter")]
/// the selected mode for this feedback
[Tooltip("the selected mode for this feedback")]
public Modes Mode = Modes.Toggle;
/// the channel to target
[Tooltip("the channel to target")]
public int Channel = 0;
/// the duration of the transition
[Tooltip("the duration of the transition")]
public float TransitionDuration = 1f;
/// the curve to move along to
[Tooltip("the curve to move along to")]
public MMTweenType Curve = new MMTweenType(MMTween.MMTweenCurve.EaseInCubic);
/// the duration of this feedback is the duration of the transition
public override float FeedbackDuration { get { return ApplyTimeMultiplier(TransitionDuration); } set { TransitionDuration = value; } }
protected bool _active = false;
protected bool _toggle = false;
/// <summary>
/// On custom play, we trigger a MMPostProcessingMovingFilterEvent with the selected parameters
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
_active = (Mode == Modes.On);
_toggle = (Mode == Modes.Toggle);
MMPostProcessingMovingFilterEvent.Trigger(Curve, _active, _toggle, FeedbackDuration, Channel);
}
/// <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);
MMPostProcessingMovingFilterEvent.Trigger(Curve, _active, _toggle, FeedbackDuration, stop:true);
}
}
}

View File

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

View File

@@ -0,0 +1,78 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you pilot a MMPlaylist
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will let you pilot a MMPlaylist")]
[FeedbackPath("Audio/MMPlaylist")]
public class MMFeedbackPlaylist : 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.SoundsColor; } }
#endif
public enum Modes { Play, PlayNext, PlayPrevious, Stop, Pause, PlaySongAt }
[Header("MMPlaylist")]
/// the channel of the target MMPlaylist
[Tooltip("the channel of the target MMPlaylist")]
public int Channel = 0;
/// the action to call on the playlist
[Tooltip("the action to call on the playlist")]
public Modes Mode = Modes.PlayNext;
/// the index of the song to play
[Tooltip("the index of the song to play")]
[MMEnumCondition("Mode", (int)Modes.PlaySongAt)]
public int SongIndex = 0;
protected Coroutine _coroutine;
/// <summary>
/// On Play we change the values of our fog
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (Mode)
{
case Modes.Play:
MMPlaylistPlayEvent.Trigger(Channel);
break;
case Modes.PlayNext:
MMPlaylistPlayNextEvent.Trigger(Channel);
break;
case Modes.PlayPrevious:
MMPlaylistPlayPreviousEvent.Trigger(Channel);
break;
case Modes.Stop:
MMPlaylistStopEvent.Trigger(Channel);
break;
case Modes.Pause:
MMPlaylistPauseEvent.Trigger(Channel);
break;
case Modes.PlaySongAt:
MMPlaylistPlayIndexEvent.Trigger(Channel, SongIndex);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}

View File

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

View File

@@ -0,0 +1,204 @@
using MoreMountains.Tools;
using System.Collections;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you target (almost) any property, on any object in your scene.
/// It also works on scriptable objects. Drag an object, select a property, and setup your feedback " +
/// to update that property over time
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will let you target (almost) any property, on any object in your scene. " +
"It also works on scriptable objects. Drag an object, select a property, and setup your feedback " +
"to update that property over time.")]
[FeedbackPath("GameObject/Property")]
public class MMFeedbackProperty : MMFeedback
{
/// the duration of this feedback is the duration of the target property, or 0 if instant
public override float FeedbackDuration { get { return (Mode == Modes.Instant) ? 0f : ApplyTimeMultiplier(Duration); } set { if (Mode != Modes.Instant) { Duration = value; } } }
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.GameObjectColor; } }
#endif
/// the possible modes for this feedback
public enum Modes { OverTime, Instant }
[Header("Target Property")]
/// the receiver to write the level to
[Tooltip("the receiver to write the level to")]
public MMPropertyReceiver Target;
[Header("Mode")]
/// whether the feedback should affect the target property instantly or over a period of time
[Tooltip("whether the feedback should affect the target property instantly or over a period of time")]
public Modes Mode = Modes.OverTime;
/// how long the target property should change over time
[Tooltip("how long the target property should change over time")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float Duration = 0.2f;
/// whether or not that target property should be turned off on start
[Tooltip("whether or not that target property should be turned off on start")]
public bool StartsOff = false;
/// whether or not the values should be relative or not
[Tooltip("whether or not the values should be relative or not")]
public bool RelativeValues = true;
/// if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over
[Tooltip("if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over")]
public bool AllowAdditivePlays = false;
[Header("Level")]
/// the curve to tween the intensity on
[Tooltip("the curve to tween the intensity on")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public MMTweenType LevelCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the intensity curve's 0 to
[Tooltip("the value to remap the intensity curve's 0 to")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float RemapLevelZero = 0f;
/// the value to remap the intensity curve's 1 to
[Tooltip("the value to remap the intensity curve's 1 to")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float RemapLevelOne = 1f;
/// the value to move the intensity to in instant mode
[Tooltip("the value to move the intensity to in instant mode")]
[MMFEnumCondition("Mode", (int)Modes.Instant)]
public float InstantLevel;
protected float _initialIntensity;
protected Coroutine _coroutine;
/// <summary>
/// On init we turn the target property off if needed
/// </summary>
/// <param name="owner"></param>
protected override void CustomInitialization(GameObject owner)
{
base.CustomInitialization(owner);
Target.Initialization(this.gameObject);
_initialIntensity = Target.Level;
if (Active)
{
if (StartsOff)
{
Turn(false);
}
}
}
/// <summary>
/// On Play we turn our target property on and start an over time coroutine if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (Active)
{
Turn(true);
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
switch (Mode)
{
case Modes.Instant:
Target.SetLevel(InstantLevel);
break;
case Modes.OverTime:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
_coroutine = StartCoroutine(UpdateValueSequence(intensityMultiplier));
break;
}
}
}
/// <summary>
/// This coroutine will modify the values on the target property
/// </summary>
/// <returns></returns>
protected virtual IEnumerator UpdateValueSequence(float intensityMultiplier)
{
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
{
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
SetValues(remappedTime, intensityMultiplier);
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
yield return null;
}
SetValues(FinalNormalizedTime, intensityMultiplier);
if (StartsOff)
{
Turn(false);
}
_coroutine = null;
yield return null;
}
/// <summary>
/// Sets the various values on the target property on a specified time (between 0 and 1)
/// </summary>
/// <param name="time"></param>
protected virtual void SetValues(float time, float intensityMultiplier)
{
float intensity = MMTween.Tween(time, 0f, 1f, RemapLevelZero, RemapLevelOne, LevelCurve);
intensity *= intensityMultiplier;
if (RelativeValues)
{
intensity += _initialIntensity;
}
Target.SetLevel(intensity);
}
/// <summary>
/// Turns the target property object off on stop if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
base.CustomStopFeedback(position, feedbacksIntensity);
if (Active)
{
if (_coroutine != null)
{
StopCoroutine(_coroutine);
_coroutine = null;
SetValues(_initialIntensity, 1f);
}
if (StartsOff)
{
Turn(false);
}
}
}
/// <summary>
/// Turns the target object on or off
/// </summary>
/// <param name="status"></param>
protected virtual void Turn(bool status)
{
if (Target.TargetComponent.gameObject != null)
{
Target.TargetComponent.gameObject.SetActive(status);
}
}
}
}

View File

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

View File

@@ -0,0 +1,75 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you trigger a play on a target MMRadioSignal (usually used by a MMRadioBroadcaster to emit a value that can then be listened to by MMRadioReceivers. From this feedback you can also specify a duration, timescale and multiplier.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will let you trigger a play on a target MMRadioSignal (usually used by a MMRadioBroadcaster to emit a value that can then be listened to by MMRadioReceivers. From this feedback you can also specify a duration, timescale and multiplier.")]
[FeedbackPath("GameObject/MMRadioSignal")]
public class MMFeedbackRadioSignal : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// the duration of this feedback is the duration of the light, or 0 if instant
public override float FeedbackDuration { get { return 0f; } }
/// The target MMRadioSignal to trigger
[Tooltip("The target MMRadioSignal to trigger")]
public MMRadioSignal TargetSignal;
/// the timescale to operate on
[Tooltip("the timescale to operate on")]
public MMRadioSignal.TimeScales TimeScale = MMRadioSignal.TimeScales.Unscaled;
/// the duration of the shake, in seconds
[Tooltip("the duration of the shake, in seconds")]
public float Duration = 1f;
/// a global multiplier to apply to the end result of the combination
[Tooltip("a global multiplier to apply to the end result of the combination")]
public float GlobalMultiplier = 1f;
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.GameObjectColor; } }
#endif
/// <summary>
/// On Play we set the values on our target signal and make it start shaking its level
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (Active && FeedbackTypeAuthorized)
{
if (TargetSignal != null)
{
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
TargetSignal.Duration = Duration;
TargetSignal.GlobalMultiplier = GlobalMultiplier * intensityMultiplier;
TargetSignal.TimeScale = TimeScale;
TargetSignal.StartShaking();
}
}
}
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
base.CustomStopFeedback(position, feedbacksIntensity);
if (Active)
{
if (TargetSignal != null)
{
TargetSignal.Stop();
}
}
}
}
}

View File

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

View File

@@ -0,0 +1,101 @@
using MoreMountains.Tools;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you control the min and max anchors of a RectTransform over time. That's the normalized position in the parent RectTransform that the lower left and upper right corners are anchored to.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you control the min and max anchors of a RectTransform over time. That's the normalized position in the parent RectTransform that the lower left and upper right corners are anchored to.")]
[FeedbackPath("UI/RectTransform Anchor")]
public class MMFeedbackRectTransformAnchor : MMFeedbackBase
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.UIColor; } }
#endif
[Header("Target")]
/// the target RectTransform to control
[Tooltip("the target RectTransform to control")]
public RectTransform TargetRectTransform;
[Header("Anchor Min")]
/// whether or not to modify the min anchor
[Tooltip("whether or not to modify the min anchor")]
public bool ModifyAnchorMin = true;
/// the curve to animate the min anchor on
[Tooltip("the curve to animate the min anchor on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType AnchorMinCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
/// the value to remap the min anchor curve's 0 on
[Tooltip("the value to remap the min anchor curve's 0 on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public Vector2 AnchorMinRemapZero = Vector2.zero;
/// the value to remap the min anchor curve's 1 on
[Tooltip("the value to remap the min anchor curve's 1 on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)MMFeedbackBase.Modes.Instant)]
public Vector2 AnchorMinRemapOne = Vector2.one;
[Header("Anchor Max")]
/// whether or not to modify the max anchor
[Tooltip("whether or not to modify the max anchor")]
public bool ModifyAnchorMax = true;
/// the curve to animate the max anchor on
[Tooltip("the curve to animate the max anchor on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType AnchorMaxCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
/// the value to remap the max anchor curve's 0 on
[Tooltip("the value to remap the max anchor curve's 0 on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public Vector2 AnchorMaxRemapZero = Vector2.zero;
/// the value to remap the max anchor curve's 1 on
[Tooltip("the value to remap the max anchor curve's 1 on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)MMFeedbackBase.Modes.Instant)]
public Vector2 AnchorMaxRemapOne = Vector2.one;
protected override void FillTargets()
{
if (TargetRectTransform == null)
{
return;
}
MMFeedbackBaseTarget targetMin = new MMFeedbackBaseTarget();
MMPropertyReceiver receiverMin = new MMPropertyReceiver();
receiverMin.TargetObject = TargetRectTransform.gameObject;
receiverMin.TargetComponent = TargetRectTransform;
receiverMin.TargetPropertyName = "anchorMin";
receiverMin.RelativeValue = RelativeValues;
receiverMin.Vector2RemapZero = AnchorMinRemapZero;
receiverMin.Vector2RemapOne = AnchorMinRemapOne;
receiverMin.ShouldModifyValue = ModifyAnchorMin;
targetMin.Target = receiverMin;
targetMin.LevelCurve = AnchorMinCurve;
targetMin.RemapLevelZero = 0f;
targetMin.RemapLevelOne = 1f;
targetMin.InstantLevel = 1f;
_targets.Add(targetMin);
MMFeedbackBaseTarget targetMax = new MMFeedbackBaseTarget();
MMPropertyReceiver receiverMax = new MMPropertyReceiver();
receiverMax.TargetObject = TargetRectTransform.gameObject;
receiverMax.TargetComponent = TargetRectTransform;
receiverMax.TargetPropertyName = "anchorMax";
receiverMax.RelativeValue = RelativeValues;
receiverMax.Vector2RemapZero = AnchorMaxRemapZero;
receiverMax.Vector2RemapOne = AnchorMaxRemapOne;
receiverMax.ShouldModifyValue = ModifyAnchorMax;
targetMax.Target = receiverMax;
targetMax.LevelCurve = AnchorMaxCurve;
targetMax.RemapLevelZero = 0f;
targetMax.RemapLevelOne = 1f;
targetMax.InstantLevel = 1f;
_targets.Add(targetMax);
}
}
}

View File

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

View File

@@ -0,0 +1,100 @@
using MoreMountains.Tools;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you control the offset of the lower left corner of the rectangle relative to the lower left anchor, and the offset of the upper right corner of the rectangle relative to the upper right anchor.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you control the offset of the lower left corner of the rectangle relative to the lower left anchor, and the offset of the upper right corner of the rectangle relative to the upper right anchor.")]
[FeedbackPath("UI/RectTransform Offset")]
public class MMFeedbackRectTransformOffset : MMFeedbackBase
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.UIColor; } }
#endif
[Header("Target")]
/// The RectTransform we want to modify
public RectTransform TargetRectTransform;
[Header("Offset Min")]
/// whether we should modify the offset min or not
[Tooltip("whether we should modify the offset min or not")]
public bool ModifyOffsetMin = true;
/// the curve to animate the min offset on
[Tooltip("the curve to animate the min offset on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType OffsetMinCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
/// the value to remap the min curve's 0 on
[Tooltip("the value to remap the min curve's 0 on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public Vector2 OffsetMinRemapZero = Vector2.zero;
/// the value to remap the min curve's 1 on
[Tooltip("the value to remap the min curve's 1 on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)MMFeedbackBase.Modes.Instant)]
public Vector2 OffsetMinRemapOne = Vector2.one;
[Header("Offset Max")]
/// whether we should modify the offset max or not
[Tooltip("whether we should modify the offset max or not")]
public bool ModifyOffsetMax = true;
/// the curve to animate the max offset on
[Tooltip("the curve to animate the max offset on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType OffsetMaxCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
/// the value to remap the max curve's 0 on
[Tooltip("the value to remap the max curve's 0 on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public Vector2 OffsetMaxRemapZero = Vector2.zero;
/// the value to remap the max curve's 1 on
[Tooltip("the value to remap the max curve's 1 on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)MMFeedbackBase.Modes.Instant)]
public Vector2 OffsetMaxRemapOne = Vector2.one;
protected override void FillTargets()
{
if (TargetRectTransform == null)
{
return;
}
MMFeedbackBaseTarget targetMin = new MMFeedbackBaseTarget();
MMPropertyReceiver receiverMin = new MMPropertyReceiver();
receiverMin.TargetObject = TargetRectTransform.gameObject;
receiverMin.TargetComponent = TargetRectTransform;
receiverMin.TargetPropertyName = "offsetMin";
receiverMin.RelativeValue = RelativeValues;
receiverMin.Vector2RemapZero = OffsetMinRemapZero;
receiverMin.Vector2RemapOne = OffsetMinRemapOne;
receiverMin.ShouldModifyValue = ModifyOffsetMin;
targetMin.Target = receiverMin;
targetMin.LevelCurve = OffsetMinCurve;
targetMin.RemapLevelZero = 0f;
targetMin.RemapLevelOne = 1f;
targetMin.InstantLevel = 1f;
_targets.Add(targetMin);
MMFeedbackBaseTarget targetMax = new MMFeedbackBaseTarget();
MMPropertyReceiver receiverMax = new MMPropertyReceiver();
receiverMax.TargetObject = TargetRectTransform.gameObject;
receiverMax.TargetComponent = TargetRectTransform;
receiverMax.TargetPropertyName = "offsetMax";
receiverMax.RelativeValue = RelativeValues;
receiverMax.Vector2RemapZero = OffsetMaxRemapZero;
receiverMax.Vector2RemapOne = OffsetMaxRemapOne;
receiverMax.ShouldModifyValue = ModifyOffsetMax;
targetMax.Target = receiverMax;
targetMax.LevelCurve = OffsetMaxCurve;
targetMax.RemapLevelZero = 0f;
targetMax.RemapLevelOne = 1f;
targetMax.InstantLevel = 1f;
_targets.Add(targetMax);
}
}
}

View File

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

View File

@@ -0,0 +1,62 @@
using MoreMountains.Tools;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you control the position of a RectTransform's pivot over time
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you control the position of a RectTransform's pivot over time")]
[FeedbackPath("UI/RectTransform Pivot")]
public class MMFeedbackRectTransformPivot : MMFeedbackBase
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.UIColor; } }
#endif
[Header("Target")]
/// the RectTransform whose position you want to control over time
[Tooltip("the RectTransform whose position you want to control over time")]
public RectTransform TargetRectTransform;
[Header("Pivot")]
/// The curve along which to evaluate the position of the RectTransform's pivot
[Tooltip("The curve along which to evaluate the position of the RectTransform's pivot")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType SpeedCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
/// the position to remap the curve's 0 to
[Tooltip("the position to remap the curve's 0 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public Vector2 RemapZero = Vector2.zero;
/// the position to remap the curve's 1 to
[Tooltip("the position to remap the curve's 1 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)MMFeedbackBase.Modes.Instant)]
public Vector2 RemapOne = Vector2.one;
protected override void FillTargets()
{
if (TargetRectTransform == null)
{
return;
}
MMFeedbackBaseTarget target = new MMFeedbackBaseTarget();
MMPropertyReceiver receiver = new MMPropertyReceiver();
receiver.TargetObject = TargetRectTransform.gameObject;
receiver.TargetComponent = TargetRectTransform;
receiver.TargetPropertyName = "pivot";
receiver.RelativeValue = RelativeValues;
receiver.Vector2RemapZero = RemapZero;
receiver.Vector2RemapOne = RemapOne;
target.Target = receiver;
target.LevelCurve = SpeedCurve;
target.RemapLevelZero = 0f;
target.RemapLevelOne = 1f;
target.InstantLevel = 1f;
_targets.Add(target);
}
}
}

View File

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

View File

@@ -0,0 +1,63 @@
using MoreMountains.Tools;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you control the size delta property (the size of this RectTransform relative to the distances between the anchors) of a RectTransform, over time
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you control the size delta property (the size of this RectTransform relative to the distances between the anchors) of a RectTransform, over time")]
[FeedbackPath("UI/RectTransformSizeDelta")]
public class MMFeedbackRectTransformSizeDelta : MMFeedbackBase
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.UIColor; } }
#endif
[Header("Target")]
/// the rect transform we want to impact
[Tooltip("the rect transform we want to impact")]
public RectTransform TargetRectTransform;
[Header("Size Delta")]
/// the speed at which we should animate the size delta
[Tooltip("the speed at which we should animate the size delta")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType SpeedCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public Vector2 RemapZero = Vector2.zero;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)MMFeedbackBase.Modes.Instant)]
public Vector2 RemapOne = Vector2.one;
protected override void FillTargets()
{
if (TargetRectTransform == null)
{
return;
}
MMFeedbackBaseTarget target = new MMFeedbackBaseTarget();
MMPropertyReceiver receiver = new MMPropertyReceiver();
receiver.TargetObject = TargetRectTransform.gameObject;
receiver.TargetComponent = TargetRectTransform;
receiver.TargetPropertyName = "sizeDelta";
receiver.RelativeValue = RelativeValues;
receiver.Vector2RemapZero = RemapZero;
receiver.Vector2RemapOne = RemapOne;
target.Target = receiver;
target.LevelCurve = SpeedCurve;
target.RemapLevelZero = 0f;
target.RemapLevelOne = 1f;
target.InstantLevel = 1f;
_targets.Add(target);
}
}
}

View File

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

View File

@@ -0,0 +1,220 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you control values on a target ShaderController, letting you modify the behaviour and aspect of a shader driven material at runtime
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you trigger a one time play on a target ShaderController.")]
[FeedbackPath("Renderer/ShaderController")]
public class MMFeedbackShaderController : MMFeedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// the different possible modes
public enum Modes { OneTime, ToDestination }
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.RendererColor; } }
#endif
[Header("Float Controller")]
/// the mode this controller is in
[Tooltip("the mode this controller is in")]
public Modes Mode = Modes.OneTime;
/// the float controller to trigger a one time play on
[Tooltip("the float controller to trigger a one time play on")]
public ShaderController TargetShaderController;
/// an optional list of float controllers to trigger a one time play on
[Tooltip("an optional list of float controllers to trigger a one time play on")]
public List<ShaderController> TargetShaderControllerList;
/// whether this should revert to original at the end
[Tooltip("whether this should revert to original at the end")]
public bool RevertToInitialValueAfterEnd = false;
/// the duration of the One Time shake
[Tooltip("the duration of the One Time shake")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeDuration = 1f;
/// the amplitude of the One Time shake (this will be multiplied by the curve's height)
[Tooltip("the amplitude of the One Time shake (this will be multiplied by the curve's height)")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeAmplitude = 1f;
/// the low value to remap the normalized curve value to
[Tooltip("the low value to remap the normalized curve value to")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeRemapMin = 0f;
/// the high value to remap the normalized curve value to
[Tooltip("the high value to remap the normalized curve value to")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeRemapMax = 1f;
/// the curve to apply to the one time shake
[Tooltip("the curve to apply to the one time shake")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public AnimationCurve OneTimeCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the new value towards which to move the current value
[Tooltip("the new value towards which to move the current value")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float ToDestinationValue = 1f;
/// the duration over which to interpolate the target value
[Tooltip("the duration over which to interpolate the target value")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float ToDestinationDuration = 1f;
/// the color to aim for (when targetting a Color property
[Tooltip("the color to aim for (when targetting a Color property")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public Color ToDestinationColor = Color.red;
/// the curve over which to interpolate the value
[Tooltip("the curve over which to interpolate the value")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public AnimationCurve ToDestinationCurve = 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 one time hit
public override float FeedbackDuration
{
get { return (Mode == Modes.OneTime) ? ApplyTimeMultiplier(OneTimeDuration) : ApplyTimeMultiplier(ToDestinationDuration); }
set { OneTimeDuration = value; ToDestinationDuration = value; }
}
protected float _oneTimeDurationStorage;
protected float _oneTimeAmplitudeStorage;
protected float _oneTimeRemapMinStorage;
protected float _oneTimeRemapMaxStorage;
protected AnimationCurve _oneTimeCurveStorage;
protected float _toDestinationValueStorage;
protected float _toDestinationDurationStorage;
protected AnimationCurve _toDestinationCurveStorage;
protected bool _revertToInitialValueAfterEndStorage;
/// <summary>
/// On init we grab our initial controller values
/// </summary>
/// <param name="owner"></param>
protected override void CustomInitialization(GameObject owner)
{
if (Active && (TargetShaderController != null))
{
_oneTimeDurationStorage = TargetShaderController.OneTimeDuration;
_oneTimeAmplitudeStorage = TargetShaderController.OneTimeAmplitude;
_oneTimeCurveStorage = TargetShaderController.OneTimeCurve;
_oneTimeRemapMinStorage = TargetShaderController.OneTimeRemapMin;
_oneTimeRemapMaxStorage = TargetShaderController.OneTimeRemapMax;
_toDestinationCurveStorage = TargetShaderController.ToDestinationCurve;
_toDestinationDurationStorage = TargetShaderController.ToDestinationDuration;
_toDestinationValueStorage = TargetShaderController.ToDestinationValue;
_revertToInitialValueAfterEndStorage = TargetShaderController.RevertToInitialValueAfterEnd;
}
}
/// <summary>
/// On play we trigger a OneTime or ToDestination play on our shader controller
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || (TargetShaderController == null))
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
PerformPlay(TargetShaderController, intensityMultiplier);
foreach (ShaderController shaderController in TargetShaderControllerList)
{
PerformPlay(shaderController, intensityMultiplier);
}
}
protected virtual void PerformPlay(ShaderController shaderController, float intensityMultiplier)
{
shaderController.RevertToInitialValueAfterEnd = RevertToInitialValueAfterEnd;
if (Mode == Modes.OneTime)
{
shaderController.OneTimeDuration = FeedbackDuration;
shaderController.OneTimeAmplitude = OneTimeAmplitude;
shaderController.OneTimeCurve = OneTimeCurve;
if (NormalPlayDirection)
{
shaderController.OneTimeRemapMin = OneTimeRemapMin * intensityMultiplier;
shaderController.OneTimeRemapMax = OneTimeRemapMax * intensityMultiplier;
}
else
{
shaderController.OneTimeRemapMin = OneTimeRemapMax * intensityMultiplier;
shaderController.OneTimeRemapMax = OneTimeRemapMin * intensityMultiplier;
}
shaderController.OneTime();
}
if (Mode == Modes.ToDestination)
{
shaderController.ToColor = ToDestinationColor;
shaderController.ToDestinationCurve = ToDestinationCurve;
shaderController.ToDestinationDuration = FeedbackDuration;
shaderController.ToDestinationValue = ToDestinationValue;
shaderController.ToDestination();
}
}
/// <summary>
/// Stops this feedback
/// </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);
if (TargetShaderController != null)
{
TargetShaderController.Stop();
}
foreach (ShaderController shaderController in TargetShaderControllerList)
{
shaderController.Stop();
}
}
/// <summary>
/// On reset we restore our initial values
/// </summary>
protected override void CustomReset()
{
base.CustomReset();
if (Active && FeedbackTypeAuthorized && (TargetShaderController != null))
{
PerformReset(TargetShaderController);
}
foreach (ShaderController shaderController in TargetShaderControllerList)
{
PerformReset(shaderController);
}
}
protected virtual void PerformReset(ShaderController shaderController)
{
shaderController.OneTimeDuration = _oneTimeDurationStorage;
shaderController.OneTimeAmplitude = _oneTimeAmplitudeStorage;
shaderController.OneTimeCurve = _oneTimeCurveStorage;
shaderController.OneTimeRemapMin = _oneTimeRemapMinStorage;
shaderController.OneTimeRemapMax = _oneTimeRemapMaxStorage;
shaderController.ToDestinationCurve = _toDestinationCurveStorage;
shaderController.ToDestinationDuration = _toDestinationDurationStorage;
shaderController.ToDestinationValue = _toDestinationValueStorage;
shaderController.RevertToInitialValueAfterEnd = _revertToInitialValueAfterEndStorage;
}
}
}

View File

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

View File

@@ -0,0 +1,334 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Audio;
using MoreMountains.Tools;
using UnityEngine.SceneManagement;
namespace MoreMountains.Feedbacks
{
[ExecuteAlways]
[AddComponentMenu("")]
[FeedbackPath("Audio/Sound")]
[FeedbackHelp("This feedback lets you play the specified AudioClip, either via event (you'll need something in your scene to catch a MMSfxEvent, for example a MMSoundManager), or cached (AudioSource gets created on init, and is then ready to be played), or on demand (instantiated on Play). For all these methods you can define a random volume between min/max boundaries (just set the same value in both fields if you don't want randomness), random pitch, and an optional AudioMixerGroup.")]
public class MMFeedbackSound : 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.SoundsColor; } }
#endif
/// <summary>
/// The possible methods to play the sound with.
/// Event : sends a MMSfxEvent, you'll need a class to catch this event and play the sound
/// Cached : creates and stores an audiosource to play the sound with, parented to the owner
/// OnDemand : creates an audiosource and destroys it everytime you want to play the sound
/// </summary>
public enum PlayMethods { Event, Cached, OnDemand, Pool }
[Header("Sound")]
/// the sound clip to play
[Tooltip("the sound clip to play")]
public AudioClip Sfx;
[Header("Random Sound")]
/// an array to pick a random sfx from
[Tooltip("an array to pick a random sfx from")]
public AudioClip[] RandomSfx;
[Header("Test")]
[MMFInspectorButton("TestPlaySound")]
public bool TestButton;
[MMFInspectorButton("TestStopSound")]
public bool TestStopButton;
[Header("Method")]
/// the play method to use when playing the sound (event, cached or on demand)
[Tooltip("the play method to use when playing the sound (event, cached or on demand)")]
public PlayMethods PlayMethod = PlayMethods.Event;
/// the size of the pool when in Pool mode
[Tooltip("the size of the pool when in Pool mode")]
[MMFEnumCondition("PlayMethod", (int)PlayMethods.Pool)]
public int PoolSize = 10;
[Header("Volume")]
/// the minimum volume to play the sound at
[Tooltip("the minimum volume to play the sound at")]
public float MinVolume = 1f;
/// the maximum volume to play the sound at
[Tooltip("the maximum volume to play the sound at")]
public float MaxVolume = 1f;
[Header("Pitch")]
/// the minimum pitch to play the sound at
[Tooltip("the minimum pitch to play the sound at")]
public float MinPitch = 1f;
/// the maximum pitch to play the sound at
[Tooltip("the maximum pitch to play the sound at")]
public float MaxPitch = 1f;
[Header("Mixer")]
/// the audiomixer to play the sound with (optional)
[Tooltip("the audiomixer to play the sound with (optional)")]
public AudioMixerGroup SfxAudioMixerGroup;
[Tooltip("the audiosource priority, to be specified if needed between 0 (highest) and 256")]
public int Priority = 128;
/// the duration of this feedback is the duration of the clip being played
public override float FeedbackDuration { get { return GetDuration(); } }
protected AudioClip _randomClip;
protected AudioSource _cachedAudioSource;
protected AudioSource[] _pool;
protected AudioSource _tempAudioSource;
protected float _duration;
protected AudioSource _editorAudioSource;
/// <summary>
/// Custom init to cache the audiosource if required
/// </summary>
/// <param name="owner"></param>
protected override void CustomInitialization(GameObject owner)
{
base.CustomInitialization(owner);
if (PlayMethod == PlayMethods.Cached)
{
_cachedAudioSource = CreateAudioSource(owner, "CachedFeedbackAudioSource");
}
if (PlayMethod == PlayMethods.Pool)
{
// create a pool
_pool = new AudioSource[PoolSize];
for (int i = 0; i < PoolSize; i++)
{
_pool[i] = CreateAudioSource(owner, "PooledAudioSource"+i);
}
}
}
protected virtual AudioSource CreateAudioSource(GameObject owner, string audioSourceName)
{
// we create a temporary game object to host our audio source
GameObject temporaryAudioHost = new GameObject(audioSourceName);
SceneManager.MoveGameObjectToScene(temporaryAudioHost.gameObject, this.gameObject.scene);
// we set the temp audio's position
temporaryAudioHost.transform.position = owner.transform.position;
temporaryAudioHost.transform.SetParent(owner.transform);
// we add an audio source to that host
_tempAudioSource = temporaryAudioHost.AddComponent<AudioSource>() as AudioSource;
_tempAudioSource.playOnAwake = false;
return _tempAudioSource;
}
/// <summary>
/// Plays either a random sound or the specified sfx
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
if (Sfx != null)
{
_duration = Sfx.length;
PlaySound(Sfx, position, intensityMultiplier);
return;
}
if (RandomSfx.Length > 0)
{
_randomClip = RandomSfx[Random.Range(0, RandomSfx.Length)];
if (_randomClip != null)
{
_duration = _randomClip.length;
PlaySound(_randomClip, position, intensityMultiplier);
}
}
}
protected virtual float GetDuration()
{
if (Sfx != null)
{
return Sfx.length;
}
float longest = 0f;
if ((RandomSfx != null) && (RandomSfx.Length > 0))
{
foreach (AudioClip clip in RandomSfx)
{
if ((clip != null) && (clip.length > longest))
{
longest = clip.length;
}
}
return longest;
}
return 0f;
}
/// <summary>
/// Plays a sound differently based on the selected play method
/// </summary>
/// <param name="sfx"></param>
/// <param name="position"></param>
protected virtual void PlaySound(AudioClip sfx, Vector3 position, float intensity)
{
float volume = Random.Range(MinVolume, MaxVolume);
if (!Timing.ConstantIntensity)
{
volume = volume * intensity;
}
float pitch = Random.Range(MinPitch, MaxPitch);
int timeSamples = NormalPlayDirection ? 0 : sfx.samples - 1;
if (!NormalPlayDirection)
{
pitch = -pitch;
}
if (PlayMethod == PlayMethods.Event)
{
MMSfxEvent.Trigger(sfx, SfxAudioMixerGroup, volume, pitch, Priority);
return;
}
if (PlayMethod == PlayMethods.OnDemand)
{
// we create a temporary game object to host our audio source
GameObject temporaryAudioHost = new GameObject("TempAudio");
SceneManager.MoveGameObjectToScene(temporaryAudioHost.gameObject, this.gameObject.scene);
// we set the temp audio's position
temporaryAudioHost.transform.position = position;
// we add an audio source to that host
AudioSource audioSource = temporaryAudioHost.AddComponent<AudioSource>() as AudioSource;
PlayAudioSource(audioSource, sfx, volume, pitch, timeSamples, SfxAudioMixerGroup, Priority);
// we destroy the host after the clip has played
Destroy(temporaryAudioHost, sfx.length);
}
if (PlayMethod == PlayMethods.Cached)
{
// we set that audio source clip to the one in paramaters
PlayAudioSource(_cachedAudioSource, sfx, volume, pitch, timeSamples, SfxAudioMixerGroup, Priority);
}
if (PlayMethod == PlayMethods.Pool)
{
_tempAudioSource = GetAudioSourceFromPool();
if (_tempAudioSource != null)
{
PlayAudioSource(_tempAudioSource, sfx, volume, pitch, timeSamples, SfxAudioMixerGroup, Priority);
}
}
}
/// <summary>
/// Plays the audio source with the specified volume and pitch
/// </summary>
/// <param name="audioSource"></param>
/// <param name="sfx"></param>
/// <param name="volume"></param>
/// <param name="pitch"></param>
protected virtual void PlayAudioSource(AudioSource audioSource, AudioClip sfx, float volume, float pitch,
int timeSamples, AudioMixerGroup audioMixerGroup = null, int priority = 128)
{
// we set that audio source clip to the one in paramaters
audioSource.clip = sfx;
audioSource.timeSamples = timeSamples;
// we set the audio source volume to the one in parameters
audioSource.volume = volume;
audioSource.pitch = pitch;
// we set our loop setting
audioSource.loop = false;
audioSource.priority = priority;
if (audioMixerGroup != null)
{
audioSource.outputAudioMixerGroup = audioMixerGroup;
}
// we start playing the sound
audioSource.Play();
}
/// <summary>
/// Gets an audio source from the pool if possible
/// </summary>
/// <returns></returns>
protected virtual AudioSource GetAudioSourceFromPool()
{
for (int i = 0; i < PoolSize; i++)
{
if (!_pool[i].isPlaying)
{
return _pool[i];
}
}
return null;
}
/// <summary>
/// A test method that creates an audiosource, plays it, and destroys itself after play
/// </summary>
protected virtual async void TestPlaySound()
{
AudioClip tmpAudioClip = null;
if (Sfx != null)
{
tmpAudioClip = Sfx;
}
if (RandomSfx.Length > 0)
{
tmpAudioClip = RandomSfx[Random.Range(0, RandomSfx.Length)];
}
if (tmpAudioClip == null)
{
Debug.LogError(Label + " on " + this.gameObject.name + " can't play in editor mode, you haven't set its Sfx.");
return;
}
float volume = Random.Range(MinVolume, MaxVolume);
float pitch = Random.Range(MinPitch, MaxPitch);
GameObject temporaryAudioHost = new GameObject("EditorTestAS_WillAutoDestroy");
SceneManager.MoveGameObjectToScene(temporaryAudioHost.gameObject, this.gameObject.scene);
temporaryAudioHost.transform.position = this.transform.position;
_editorAudioSource = temporaryAudioHost.AddComponent<AudioSource>() as AudioSource;
PlayAudioSource(_editorAudioSource, tmpAudioClip, volume, pitch, 0);
float length = 1000 * tmpAudioClip.length;
await Task.Delay((int)length);
DestroyImmediate(temporaryAudioHost);
}
/// <summary>
/// A test method that stops the test sound
/// </summary>
protected virtual void TestStopSound()
{
if (_editorAudioSource != null)
{
_editorAudioSource.Stop();
}
}
}
}

View File

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

View File

@@ -0,0 +1,66 @@
using MoreMountains.Tools;
using UnityEngine;
using UnityEngine.UI;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you control the font size of a target Text over time
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you control the font size of a target Text over time.")]
[FeedbackPath("UI/Text Font Size")]
public class MMFeedbackTextFontSize : MMFeedbackBase
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.TMPColor; } }
#endif
[Header("Target")]
/// the TMP_Text component to control
[Tooltip("the TMP_Text component to control")]
public Text TargetText;
[Header("Font Size")]
/// the curve to tween on
[Tooltip("the curve to tween on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType FontSizeCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the curve's 0 to
[Tooltip("the value to remap the curve's 0 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public float RemapZero = 0f;
/// the value to remap the curve's 1 to
[Tooltip("the value to remap the curve's 1 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public float RemapOne = 1f;
/// the value to move to in instant mode
[Tooltip("the value to move to in instant mode")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.Instant)]
public float InstantFontSize;
protected override void FillTargets()
{
if (TargetText == null)
{
return;
}
MMFeedbackBaseTarget target = new MMFeedbackBaseTarget();
MMPropertyReceiver receiver = new MMPropertyReceiver();
receiver.TargetObject = TargetText.gameObject;
receiver.TargetComponent = TargetText;
receiver.TargetPropertyName = "fontSize";
receiver.RelativeValue = RelativeValues;
target.Target = receiver;
target.LevelCurve = FontSizeCurve;
target.RemapLevelZero = RemapZero;
target.RemapLevelOne = RemapOne;
target.InstantLevel = InstantFontSize;
_targets.Add(target);
}
}
}

View File

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

View File

@@ -0,0 +1,102 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will trigger a MMBlink object, letting you blink something
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you trigger a blink on an MMBlink object.")]
[FeedbackPath("Renderer/MMBlink")]
public class MMF_Blink : MMF_Feedback
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get => MMFeedbacksInspectorColors.RendererColor; }
public override bool HasCustomInspectors { get { return true; } }
public override bool EvaluateRequiresSetup() => (TargetBlink == null);
public override string RequiredTargetText => TargetBlink != null ? TargetBlink.name : "";
public override string RequiresSetupText => "This feedback requires that a TargetBlink be set to be able to work properly. You can set one below.";
#endif
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// the possible modes for this feedback, that correspond to MMBlink's public methods
public enum BlinkModes { Toggle, Start, Stop }
[MMFInspectorGroup("Blink", true, 61, true)]
/// the target object to blink
[Tooltip("the target object to blink")]
public MMBlink TargetBlink;
/// the selected mode for this feedback
[Tooltip("the selected mode for this feedback")]
public BlinkModes BlinkMode = BlinkModes.Toggle;
/// the duration of the blink. You can set it manually, or you can press the GrabDurationFromBlink button to automatically compute it. For performance reasons, this isn't updated unless you press the button, make sure you do so if you change the blink's duration.
[Tooltip("the duration of the blink. You can set it manually, or you can press the GrabDurationFromBlink button to automatically compute it. For performance reasons, this isn't updated unless you press the button, make sure you do so if you change the blink's duration.")]
public float Duration;
public MMF_Button GrabDurationFromBlinkButton;
/// <summary>
/// Initializes our duration button
/// </summary>
public override void InitializeCustomAttributes()
{
GrabDurationFromBlinkButton = new MMF_Button("Grab Duration From Blink Component", GrabDurationFromBlink);
}
/// <summary>
/// On Custom play, we trigger our MMBlink object
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || (TargetBlink == null))
{
return;
}
TargetBlink.TimescaleMode = ComputedTimescaleMode;
switch (BlinkMode)
{
case BlinkModes.Toggle:
TargetBlink.ToggleBlinking();
break;
case BlinkModes.Start:
TargetBlink.StartBlinking();
break;
case BlinkModes.Stop:
TargetBlink.StopBlinking();
break;
}
}
/// <summary>
/// On restore, we restore our initial state
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
TargetBlink.StopBlinking();
}
/// <summary>
/// Grabs and stores the duration from our target blink component if one is set
/// </summary>
public virtual void GrabDurationFromBlink()
{
if (TargetBlink != null)
{
Duration = TargetBlink.Duration;
}
}
}
}

View File

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

View File

@@ -0,0 +1,73 @@
using MoreMountains.Tools;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you broadcast a float value to the MMRadio system
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you broadcast a float value to the MMRadio system.")]
[FeedbackPath("GameObject/Broadcast")]
public class MMF_Broadcast : MMF_FeedbackBase
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.UIColor; } }
#endif
public override bool HasChannel => true;
[Header("Level")]
/// the curve to tween the intensity on
[Tooltip("the curve to tween the intensity on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType Curve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the intensity curve's 0 to
[Tooltip("the value to remap the intensity curve's 0 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public float RemapZero = 0f;
/// the value to remap the intensity curve's 1 to
[Tooltip("the value to remap the intensity curve's 1 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public float RemapOne = 1f;
/// the value to move the intensity to in instant mode
[Tooltip("the value to move the intensity to in instant mode")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.Instant)]
public float InstantChange;
protected MMF_BroadcastProxy _proxy;
/// <summary>
/// On init we store our initial alpha
/// </summary>
/// <param name="owner"></param>
protected override void CustomInitialization(MMF_Player owner)
{
base.CustomInitialization(owner);
_proxy = Owner.gameObject.AddComponent<MMF_BroadcastProxy>();
_proxy.Channel = Channel;
PrepareTargets();
}
/// <summary>
/// We setup our target with this object
/// </summary>
protected override void FillTargets()
{
MMF_FeedbackBaseTarget target = new MMF_FeedbackBaseTarget();
MMPropertyReceiver receiver = new MMPropertyReceiver();
receiver.TargetObject = Owner.gameObject;
receiver.TargetComponent = _proxy;
receiver.TargetPropertyName = "ThisLevel";
receiver.RelativeValue = RelativeValues;
target.Target = receiver;
target.LevelCurve = Curve;
target.RemapLevelZero = RemapZero;
target.RemapLevelOne = RemapOne;
target.InstantLevel = InstantChange;
_targets.Add(target);
}
}
}

View File

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

View File

@@ -0,0 +1,50 @@
using MoreMountains.Tools;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This component will be automatically added by the MMF_Broadcast feedback
/// </summary>
public class MMF_BroadcastProxy : MonoBehaviour
{
/// the channel on which to broadcast
[Tooltip("the channel on which to broadcast")]
[MMReadOnly]
public int Channel;
/// a debug view of the current level being broadcasted
[Tooltip("a debug view of the current level being broadcasted")]
[MMReadOnly]
public float DebugLevel;
/// whether or not a broadcast is in progress (will be false while the value is not changing, and thus not broadcasting)
[Tooltip("whether or not a broadcast is in progress (will be false while the value is not changing, and thus not broadcasting)")]
[MMReadOnly]
public bool BroadcastInProgress = false;
public float ThisLevel { get; set; }
protected float _levelLastFrame;
/// <summary>
/// On Update we process our broadcast
/// </summary>
protected virtual void Update()
{
ProcessBroadcast();
}
/// <summary>
/// Broadcasts the value if needed
/// </summary>
protected virtual void ProcessBroadcast()
{
BroadcastInProgress = false;
if (ThisLevel != _levelLastFrame)
{
MMRadioLevelEvent.Trigger(Channel, ThisLevel);
BroadcastInProgress = true;
}
DebugLevel = ThisLevel;
_levelLastFrame = ThisLevel;
}
}
}

View File

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

View File

@@ -0,0 +1,67 @@
using MoreMountains.Tools;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you control the opacity of a canvas group over time
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you control the opacity of a canvas group over time.")]
[FeedbackPath("UI/CanvasGroup")]
public class MMF_CanvasGroup : MMF_FeedbackBase
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.UIColor; } }
public override bool EvaluateRequiresSetup() { return (TargetCanvasGroup == null); }
public override string RequiredTargetText { get { return TargetCanvasGroup != null ? TargetCanvasGroup.name : ""; } }
public override string RequiresSetupText { get { return "This feedback requires that a TargetCanvasGroup be set to be able to work properly. You can set one below."; } }
#endif
[MMFInspectorGroup("Canvas Group", true, 12, true)]
/// the receiver to write the level to
[Tooltip("the receiver to write the level to")]
public CanvasGroup TargetCanvasGroup;
/// the curve to tween the opacity on
[Tooltip("the curve to tween the opacity on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public MMTweenType AlphaCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the opacity curve's 0 to
[Tooltip("the value to remap the opacity curve's 0 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public float RemapZero = 0f;
/// the value to remap the opacity curve's 1 to
[Tooltip("the value to remap the opacity curve's 1 to")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
public float RemapOne = 1f;
/// the value to move the opacity to in instant mode
[Tooltip("the value to move the opacity to in instant mode")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.Instant)]
public float InstantAlpha;
protected override void FillTargets()
{
if (TargetCanvasGroup == null)
{
return;
}
MMF_FeedbackBaseTarget target = new MMF_FeedbackBaseTarget();
MMPropertyReceiver receiver = new MMPropertyReceiver();
receiver.TargetObject = TargetCanvasGroup.gameObject;
receiver.TargetComponent = TargetCanvasGroup;
receiver.TargetPropertyName = "alpha";
receiver.RelativeValue = RelativeValues;
target.Target = receiver;
target.LevelCurve = AlphaCurve;
target.RemapLevelZero = RemapZero;
target.RemapLevelOne = RemapOne;
target.InstantLevel = InstantAlpha;
_targets.Add(target);
}
}
}

View File

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

View File

@@ -0,0 +1,52 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback doesn't do anything by default, it's just meant as a comment, you can store text in it for future reference, maybe to remember how you setup a particular MMFeedbacks. Optionally it can also output that comment to the console on Play.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback doesn't do anything by default, it's just meant as a comment, you can store text in it for future reference, maybe to remember how you setup a particular MMFeedbacks. Optionally it can also output that comment to the console on Play.")]
[FeedbackPath("Debug/Comment")]
public class MMF_DebugComment : 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.DebugColor; } }
#endif
[MMFInspectorGroup("Comment", true, 61)]
/// the comment / note associated to this feedback
[Tooltip("the comment / note associated to this feedback")]
[TextArea(10,30)]
public string Comment;
/// if this is true, the comment will be output to the console on Play
[Tooltip("if this is true, the comment will be output to the console on Play")]
public bool LogComment = false;
/// the color of the message when in DebugLogTime mode
[Tooltip("the color of the message when in DebugLogTime mode")]
[MMCondition("LogComment", true)]
public Color DebugColor = Color.gray;
/// <summary>
/// On Play we output our message to the console if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || !LogComment)
{
return;
}
Debug.Log(Comment);
}
}
}

View File

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

View File

@@ -0,0 +1,80 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you output a message to the console, using a custom MM debug method, or Log, Assertion, Error or Warning logs.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will let you output a message to the console, using a custom MM debug method, or Log, Assertion, Error or Warning logs.")]
[FeedbackPath("Debug/Log")]
public class MMF_DebugLog : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// the duration of this feedback is the duration of the light, or 0 if instant
public override float FeedbackDuration { get { return 0f; } }
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.DebugColor; } }
#endif
/// the possible debug modes
public enum DebugLogModes { DebugLogTime, Log, Assertion, Error, Warning }
[MMFInspectorGroup("Debug", true, 17)]
/// the selected debug mode
[Tooltip("the selected debug mode")]
public DebugLogModes DebugLogMode = DebugLogModes.DebugLogTime;
/// the message to display
[Tooltip("the message to display")]
[TextArea]
public string DebugMessage;
/// the color of the message when in DebugLogTime mode
[Tooltip("the color of the message when in DebugLogTime mode")]
[MMFEnumCondition("DebugLogMode", (int) DebugLogModes.DebugLogTime)]
public Color DebugColor = Color.cyan;
/// whether or not to display the frame count when in DebugLogTime mode
[Tooltip("whether or not to display the frame count when in DebugLogTime mode")]
[MMFEnumCondition("DebugLogMode", (int) DebugLogModes.DebugLogTime)]
public bool DisplayFrameCount = true;
/// <summary>
/// On Play we output our message to the console using the selected mode
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (DebugLogMode)
{
case DebugLogModes.Assertion:
Debug.LogAssertion(DebugMessage);
break;
case DebugLogModes.Log:
Debug.Log(DebugMessage);
break;
case DebugLogModes.Error:
Debug.LogError(DebugMessage);
break;
case DebugLogModes.Warning:
Debug.LogWarning(DebugMessage);
break;
case DebugLogModes.DebugLogTime:
string color = "#" + ColorUtility.ToHtmlStringRGB(DebugColor);
MMDebug.DebugLogTime(DebugMessage, color, 3, DisplayFrameCount);
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,164 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will trigger a one time play on a target FloatController
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you trigger a fade event.")]
[FeedbackPath("Camera/Fade")]
public class MMF_Fade : 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; } }
public override string RequiredTargetText { get { return "ID "+ID; } }
#endif
/// the different possible types of fades
public enum FadeTypes { FadeIn, FadeOut, Custom }
/// the different ways to send the position to the fader :
/// - FeedbackPosition : fade at the position of the feedback, plus an optional offset
/// - Transform : fade at the specified Transform's position, plus an optional offset
/// - WorldPosition : fade at the specified world position vector, plus an optional offset
/// - Script : the position passed in parameters when calling the feedback
public enum PositionModes { FeedbackPosition, Transform, WorldPosition, Script }
[MMFInspectorGroup("Fade", true, 43)]
/// the type of fade we want to use when this feedback gets played
[Tooltip("the type of fade we want to use when this feedback gets played")]
public FadeTypes FadeType;
/// the ID of the fader(s) to pilot
[Tooltip("the ID of the fader(s) to pilot")]
public int ID = 0;
/// the duration (in seconds) of the fade
[Tooltip("the duration (in seconds) of the fade")]
public float Duration = 1f;
/// the curve to use for this fade
[Tooltip("the curve to use for this fade")]
public MMTweenType Curve = new MMTweenType(MMTween.MMTweenCurve.EaseInCubic);
/// whether or not this fade should ignore timescale
[Tooltip("whether or not this fade should ignore timescale")]
public bool IgnoreTimeScale = true;
[Header("Custom")]
/// the target alpha we're aiming for with this fade
[Tooltip("the target alpha we're aiming for with this fade")]
public float TargetAlpha;
[Header("Position")]
/// the chosen way to position the fade
[Tooltip("the chosen way to position the fade")]
public PositionModes PositionMode = PositionModes.FeedbackPosition;
/// the transform on which to center the fade
[Tooltip("the transform on which to center the fade")]
[MMFEnumCondition("PositionMode", (int)PositionModes.Transform)]
public Transform TargetTransform;
/// the coordinates on which to center the fadet
[Tooltip("the coordinates on which to center the fade")]
[MMFEnumCondition("PositionMode", (int)PositionModes.WorldPosition)]
public Vector3 TargetPosition;
/// the position offset to apply when centering the fade
[Tooltip("the position offset to apply when centering the fade")]
public Vector3 PositionOffset;
/// the duration of this feedback is the duration of the fade
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
protected Vector3 _position;
protected FadeTypes _fadeType;
/// <summary>
/// On play we trigger the selected fade event
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
_position = GetPosition(position);
_fadeType = FadeType;
if (!NormalPlayDirection)
{
if (FadeType == FadeTypes.FadeIn)
{
_fadeType = FadeTypes.FadeOut;
}
else if (FadeType == FadeTypes.FadeOut)
{
_fadeType = FadeTypes.FadeIn;
}
}
switch (_fadeType)
{
case FadeTypes.Custom:
MMFadeEvent.Trigger(FeedbackDuration, TargetAlpha, Curve, ID, IgnoreTimeScale, _position);
break;
case FadeTypes.FadeIn:
MMFadeInEvent.Trigger(FeedbackDuration, Curve, ID, IgnoreTimeScale, _position);
break;
case FadeTypes.FadeOut:
MMFadeOutEvent.Trigger(FeedbackDuration, Curve, ID, IgnoreTimeScale, _position);
break;
}
}
/// <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)
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
MMFadeStopEvent.Trigger(ID);
}
/// <summary>
/// Computes the proper position for this fade
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
protected virtual Vector3 GetPosition(Vector3 position)
{
switch (PositionMode)
{
case PositionModes.FeedbackPosition:
return Owner.transform.position + PositionOffset;
case PositionModes.Transform:
return TargetTransform.position + PositionOffset;
case PositionModes.WorldPosition:
return TargetPosition + PositionOffset;
case PositionModes.Script:
return position + PositionOffset;
default:
return position + PositionOffset;
}
}
/// <summary>
/// On restore, we restore our initial state
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMFadeStopEvent.Trigger(ID, true);
}
}
}

View File

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

View File

@@ -0,0 +1,201 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will trigger a one time play on a target FloatController
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you trigger a one time play on a target FloatController.")]
[FeedbackPath("GameObject/FloatController")]
public class MMF_FloatController : MMF_Feedback
{
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
/// the different possible modes
public enum Modes { OneTime, ToDestination }
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.GameObjectColor; } }
public override bool EvaluateRequiresSetup() { return (TargetFloatController == null); }
public override string RequiredTargetText { get { return TargetFloatController != null ? TargetFloatController.name : ""; } }
public override string RequiresSetupText { get { return "This feedback requires that a TargetFloatController be set to be able to work properly. You can set one below."; } }
#endif
public override bool HasRandomness => true;
[MMFInspectorGroup("Float Controller", true, 36, true)]
/// the mode this controller is in
[Tooltip("the mode this controller is in")]
public Modes Mode = Modes.OneTime;
/// the float controller to trigger a one time play on
[Tooltip("the float controller to trigger a one time play on")]
public FloatController TargetFloatController;
/// whether this should revert to original at the end
[Tooltip("whether this should revert to original at the end")]
public bool RevertToInitialValueAfterEnd = false;
/// the duration of the One Time shake
[Tooltip("the duration of the One Time shake")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeDuration = 1f;
/// the amplitude of the One Time shake (this will be multiplied by the curve's height)
[Tooltip("the amplitude of the One Time shake (this will be multiplied by the curve's height)")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeAmplitude = 1f;
/// the low value to remap the normalized curve value to
[Tooltip("the low value to remap the normalized curve value to")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeRemapMin = 0f;
/// the high value to remap the normalized curve value to
[Tooltip("the high value to remap the normalized curve value to")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public float OneTimeRemapMax = 1f;
/// the curve to apply to the one time shake
[Tooltip("the curve to apply to the one time shake")]
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
public AnimationCurve OneTimeCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// the value to move this float controller to
[Tooltip("the value to move this float controller to")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float ToDestinationValue = 1f;
/// the duration over which to move the value
[Tooltip("the duration over which to move the value")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float ToDestinationDuration = 1f;
/// the curve over which to move the value in ToDestination mode
[Tooltip("the curve over which to move the value in ToDestination mode")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public AnimationCurve ToDestinationCurve = 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 one time hit
public override float FeedbackDuration
{
get { return (Mode == Modes.OneTime) ? ApplyTimeMultiplier(OneTimeDuration) : ApplyTimeMultiplier(ToDestinationDuration); }
set { OneTimeDuration = value; ToDestinationDuration = value; }
}
protected float _oneTimeDurationStorage;
protected float _oneTimeAmplitudeStorage;
protected float _oneTimeRemapMinStorage;
protected float _oneTimeRemapMaxStorage;
protected AnimationCurve _oneTimeCurveStorage;
protected float _toDestinationValueStorage;
protected float _toDestinationDurationStorage;
protected AnimationCurve _toDestinationCurveStorage;
protected bool _revertToInitialValueAfterEndStorage;
/// <summary>
/// On init we grab our initial values on the target float controller
/// </summary>
/// <param name="owner"></param>
protected override void CustomInitialization(MMF_Player owner)
{
if (Active && (TargetFloatController != null))
{
_oneTimeDurationStorage = TargetFloatController.OneTimeDuration;
_oneTimeAmplitudeStorage = TargetFloatController.OneTimeAmplitude;
_oneTimeCurveStorage = TargetFloatController.OneTimeCurve;
_oneTimeRemapMinStorage = TargetFloatController.OneTimeRemapMin;
_oneTimeRemapMaxStorage = TargetFloatController.OneTimeRemapMax;
_toDestinationCurveStorage = TargetFloatController.ToDestinationCurve;
_toDestinationDurationStorage = TargetFloatController.ToDestinationDuration;
_toDestinationValueStorage = TargetFloatController.ToDestinationValue;
_revertToInitialValueAfterEndStorage = TargetFloatController.RevertToInitialValueAfterEnd;
}
}
/// <summary>
/// On play we trigger a one time or ToDestination play on our target float controller
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized || (TargetFloatController == null))
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
TargetFloatController.RevertToInitialValueAfterEnd = RevertToInitialValueAfterEnd;
if (Mode == Modes.OneTime)
{
TargetFloatController.OneTimeDuration = FeedbackDuration;
TargetFloatController.OneTimeAmplitude = OneTimeAmplitude;
TargetFloatController.OneTimeCurve = OneTimeCurve;
if (NormalPlayDirection)
{
TargetFloatController.OneTimeRemapMin = OneTimeRemapMin * intensityMultiplier;
TargetFloatController.OneTimeRemapMax = OneTimeRemapMax * intensityMultiplier;
}
else
{
TargetFloatController.OneTimeRemapMin = OneTimeRemapMax * intensityMultiplier;
TargetFloatController.OneTimeRemapMax = OneTimeRemapMin * intensityMultiplier;
}
TargetFloatController.OneTime();
}
if (Mode == Modes.ToDestination)
{
TargetFloatController.ToDestinationCurve = ToDestinationCurve;
TargetFloatController.ToDestinationDuration = FeedbackDuration;
TargetFloatController.ToDestinationValue = ToDestinationValue;
TargetFloatController.ToDestination();
}
}
/// <summary>
/// On reset we reset our values on the target controller with the ones stored initially
/// </summary>
protected override void CustomReset()
{
base.CustomReset();
if (Active && FeedbackTypeAuthorized && (TargetFloatController != null))
{
TargetFloatController.OneTimeDuration = _oneTimeDurationStorage;
TargetFloatController.OneTimeAmplitude = _oneTimeAmplitudeStorage;
TargetFloatController.OneTimeCurve = _oneTimeCurveStorage;
TargetFloatController.OneTimeRemapMin = _oneTimeRemapMinStorage;
TargetFloatController.OneTimeRemapMax = _oneTimeRemapMaxStorage;
TargetFloatController.ToDestinationCurve = _toDestinationCurveStorage;
TargetFloatController.ToDestinationDuration = _toDestinationDurationStorage;
TargetFloatController.ToDestinationValue = _toDestinationValueStorage;
TargetFloatController.RevertToInitialValueAfterEnd = _revertToInitialValueAfterEndStorage;
}
}
/// <summary>
/// On stop, we interrupt movement if it was active
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
if (TargetFloatController != null)
{
TargetFloatController.Stop();
}
}
/// <summary>
/// On restore, we restore our initial state
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
TargetFloatController.RestoreInitialValues();
}
}
}

View File

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

View File

@@ -0,0 +1,157 @@
using MoreMountains.Tools;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will request the spawn of a floating text, usually to signify damage, but not necessarily
/// This requires that a MMFloatingTextSpawner be correctly setup in the scene, otherwise nothing will happen.
/// To do so, create a new empty object, add a MMFloatingTextSpawner to it. Drag (at least) one MMFloatingText prefab into its PooledSimpleMMFloatingText slot.
/// You'll find such prefabs already made in the MMTools/Tools/MMFloatingText/Prefabs folder, but feel free to create your own.
/// Using that feedback will always spawn the same text. While this may be what you want, if you're using the Corgi Engine or TopDown Engine, you'll find dedicated versions
/// directly hooked to the Health component, letting you display damage taken.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will request the spawn of a floating text, usually to signify damage, but not necessarily. " +
"This requires that a MMFloatingTextSpawner be correctly setup in the scene, otherwise nothing will happen. " +
"To do so, create a new empty object, add a MMFloatingTextSpawner to it. Drag (at least) one MMFloatingText prefab into its PooledSimpleMMFloatingText slot. " +
"You'll find such prefabs already made in the MMTools/Tools/MMFloatingText/Prefabs folder, but feel free to create your own. " +
"Using that feedback will always spawn the same text. While this may be what you want, if you're using the Corgi Engine or TopDown Engine, you'll find dedicated versions " +
"directly hooked to the Health component, letting you display damage taken.")]
[FeedbackPath("UI/Floating Text")]
public class MMF_FloatingText : 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.UIColor; } }
#endif
/// the duration of this feedback is a fixed value or the lifetime
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Lifetime); } set { Lifetime = value; } }
public override bool HasChannel => true;
public override bool HasRandomness => true;
/// the possible places where the floating text should spawn at
public enum PositionModes { TargetTransform, FeedbackPosition, PlayPosition }
[MMFInspectorGroup("Floating Text", true, 64)]
/// the Intensity to spawn this text with, will act as a lifetime/movement/scale multiplier based on the spawner's settings
[Tooltip("the Intensity to spawn this text with, will act as a lifetime/movement/scale multiplier based on the spawner's settings")]
public float Intensity = 1f;
/// the value to display when spawning this text
[Tooltip("the value to display when spawning this text")]
public string Value = "100";
/// if this is true, the intensity passed to this feedback will be the value displayed
[Tooltip("if this is true, the intensity passed to this feedback will be the value displayed")]
public bool UseIntensityAsValue = false;
/// the possible methods that can be applied to the output value (when using intensity as the output value, string values won't get rounded)
public enum RoundingMethods { NoRounding, Round, Ceil, Floor }
/// the rounding methods to apply to the output value (when using intensity as the output value, string values won't get rounded)
[Tooltip("the rounding methods to apply to the output value (when using intensity as the output value, string values won't get rounded)")]
[MMFInspectorGroup("Rounding", true, 68)]
public RoundingMethods RoundingMethod = RoundingMethods.NoRounding;
[MMFInspectorGroup("Color", true, 65)]
/// whether or not to force a color on the new text, if not, the default colors of the spawner will be used
[Tooltip("whether or not to force a color on the new text, if not, the default colors of the spawner will be used")]
public bool ForceColor = false;
/// the gradient to apply over the lifetime of the text
[Tooltip("the gradient to apply over the lifetime of the text")]
[GradientUsage(true)]
public Gradient AnimateColorGradient = new Gradient();
[MMFInspectorGroup("Lifetime", true, 66)]
/// whether or not to force a lifetime on the new text, if not, the default colors of the spawner will be used
[Tooltip("whether or not to force a lifetime on the new text, if not, the default colors of the spawner will be used")]
public bool ForceLifetime = false;
/// the forced lifetime for the spawned text
[Tooltip("the forced lifetime for the spawned text")]
[MMFCondition("ForceLifetime", true)]
public float Lifetime = 0.5f;
[MMFInspectorGroup("Position", true, 67)]
/// where to spawn the new text (at the position of the feedback, or on a specified Transform)
[Tooltip("where to spawn the new text (at the position of the feedback, or on a specified Transform)")]
public PositionModes PositionMode = PositionModes.FeedbackPosition;
/// in transform mode, the Transform on which to spawn the new floating text
[Tooltip("in transform mode, the Transform on which to spawn the new floating text")]
[MMFEnumCondition("PositionMode", (int)PositionModes.TargetTransform)]
public Transform TargetTransform;
/// the direction to apply to the new floating text (leave it to 0 to let the Spawner decide based on its settings)
[Tooltip("the direction to apply to the new floating text (leave it to 0 to let the Spawner decide based on its settings)")]
public Vector3 Direction = Vector3.zero;
protected Vector3 _playPosition;
protected string _value;
/// <summary>
/// On play we ask the spawner on the specified channel to spawn a new floating text
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
switch (PositionMode)
{
case PositionModes.FeedbackPosition:
_playPosition = Owner.transform.position;
break;
case PositionModes.PlayPosition:
_playPosition = position;
break;
case PositionModes.TargetTransform:
_playPosition = TargetTransform.position;
break;
}
if (RoundingMethod != RoundingMethods.NoRounding)
{
switch (RoundingMethod)
{
case RoundingMethods.Ceil:
break;
}
}
feedbacksIntensity = ApplyRounding(feedbacksIntensity);
_value = UseIntensityAsValue ? feedbacksIntensity.ToString() : Value;
MMFloatingTextSpawnEvent.Trigger(ChannelData, _playPosition, _value, Direction, Intensity * intensityMultiplier, ForceLifetime, Lifetime, ForceColor, AnimateColorGradient, ComputedTimescaleMode == TimescaleModes.Unscaled);
}
protected virtual float ApplyRounding(float value)
{
if (RoundingMethod == RoundingMethods.NoRounding)
{
return value;
}
switch (RoundingMethod)
{
case RoundingMethods.Round:
return Mathf.Round(value);
case RoundingMethods.Ceil:
return Mathf.Ceil(value);
case RoundingMethods.Floor:
return Mathf.Floor(value);
}
return value;
}
}
}

View File

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

View File

@@ -0,0 +1,247 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you animate the density, color, end and start distance of your scene's fog
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will let you animate the density, color, end and start distance of your scene's fog")]
[FeedbackPath("Renderer/Fog")]
public class MMF_Fog : 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.RendererColor; } }
public override string RequiredTargetText { get { return Mode.ToString(); } }
#endif
public override bool HasRandomness => true;
/// the possible modes for this feedback
public enum Modes { OverTime, Instant }
[MMFInspectorGroup("Fog", true, 24)]
/// whether the feedback should affect the sprite renderer instantly or over a period of time
[Tooltip("whether the feedback should affect the sprite renderer instantly or over a period of time")]
public Modes Mode = Modes.OverTime;
/// how long the sprite renderer should change over time
[Tooltip("how long the sprite renderer should change over time")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float Duration = 2f;
/// if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over
[Tooltip("if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over")]
public bool AllowAdditivePlays = false;
[MMFInspectorGroup("Fog Density", true, 25)]
/// whether or not to modify the fog's density
[Tooltip("whether or not to modify the fog's density")]
public bool ModifyFogDensity = true;
/// a curve to use to animate the fog's density over time
[Tooltip("a curve to use to animate the fog's density over time")]
public MMTweenType DensityCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the fog's density curve zero value to
[Tooltip("the value to remap the fog's density curve zero value to")]
public float DensityRemapZero = 0.01f;
/// the value to remap the fog's density curve one value to
[Tooltip("the value to remap the fog's density curve one value to")]
public float DensityRemapOne = 0.05f;
/// the value to change the fog's density to when in instant mode
[Tooltip("the value to change the fog's density to when in instant mode")]
public float DensityInstantChange;
[MMFInspectorGroup("Fog Start Distance", true, 26)]
/// whether or not to modify the fog's start distance
[Tooltip("whether or not to modify the fog's start distance")]
public bool ModifyStartDistance = true;
/// a curve to use to animate the fog's start distance over time
[Tooltip("a curve to use to animate the fog's start distance over time")]
public MMTweenType StartDistanceCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the fog's start distance curve zero value to
[Tooltip("the value to remap the fog's start distance curve zero value to")]
public float StartDistanceRemapZero = 0f;
/// the value to remap the fog's start distance curve one value to
[Tooltip("the value to remap the fog's start distance curve one value to")]
public float StartDistanceRemapOne = 0f;
/// the value to change the fog's start distance to when in instant mode
[Tooltip("the value to change the fog's start distance to when in instant mode")]
public float StartDistanceInstantChange;
[MMFInspectorGroup("Fog End Distance", true, 27)]
/// whether or not to modify the fog's end distance
[Tooltip("whether or not to modify the fog's end distance")]
public bool ModifyEndDistance = true;
/// a curve to use to animate the fog's end distance over time
[Tooltip("a curve to use to animate the fog's end distance over time")]
public MMTweenType EndDistanceCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
/// the value to remap the fog's end distance curve zero value to
[Tooltip("the value to remap the fog's end distance curve zero value to")]
public float EndDistanceRemapZero = 0f;
/// the value to remap the fog's end distance curve one value to
[Tooltip("the value to remap the fog's end distance curve one value to")]
public float EndDistanceRemapOne = 300f;
/// the value to change the fog's end distance to when in instant mode
[Tooltip("the value to change the fog's end distance to when in instant mode")]
public float EndDistanceInstantChange;
[MMFInspectorGroup("Fog Color", true, 28)]
/// whether or not to modify the fog's color
[Tooltip("whether or not to modify the fog's color")]
public bool ModifyColor = true;
/// the colors to apply to the sprite renderer over time
[Tooltip("the colors to apply to the sprite renderer over time")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public Gradient ColorOverTime;
/// the color to move to in instant mode
[Tooltip("the color to move to in instant mode")]
[MMFEnumCondition("Mode", (int)Modes.Instant)]
public Color InstantColor;
/// the duration of this feedback is the duration of the sprite renderer, or 0 if instant
public override float FeedbackDuration { get { return (Mode == Modes.Instant) ? 0f : ApplyTimeMultiplier(Duration); } set { if (Mode != Modes.Instant) { Duration = value; } } }
protected Coroutine _coroutine;
protected Color _initialColor;
protected float _initialStartDistance;
protected float _initialEndDistance;
protected float _initialDensity;
/// <summary>
/// On Play we change the values of our fog
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
_initialColor = RenderSettings.fogColor;
_initialStartDistance = RenderSettings.fogStartDistance;
_initialEndDistance = RenderSettings.fogEndDistance;
_initialDensity = RenderSettings.fogDensity;
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
switch (Mode)
{
case Modes.Instant:
if (ModifyColor)
{
RenderSettings.fogColor = InstantColor;
}
if (ModifyStartDistance)
{
RenderSettings.fogStartDistance = StartDistanceInstantChange;
}
if (ModifyEndDistance)
{
RenderSettings.fogEndDistance = EndDistanceInstantChange;
}
if (ModifyFogDensity)
{
RenderSettings.fogDensity = DensityInstantChange * intensityMultiplier;
}
break;
case Modes.OverTime:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
_coroutine = Owner.StartCoroutine(FogSequence(intensityMultiplier));
break;
}
}
/// <summary>
/// This coroutine will modify the values on the fog settings
/// </summary>
/// <returns></returns>
protected virtual IEnumerator FogSequence(float intensityMultiplier)
{
IsPlaying = true;
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
{
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
SetFogValues(remappedTime, intensityMultiplier);
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
yield return null;
}
SetFogValues(FinalNormalizedTime, intensityMultiplier);
_coroutine = null;
IsPlaying = false;
yield return null;
}
/// <summary>
/// Sets the various values on the fog on a specified time (between 0 and 1)
/// </summary>
/// <param name="time"></param>
protected virtual void SetFogValues(float time, float intensityMultiplier)
{
if (ModifyColor)
{
RenderSettings.fogColor = ColorOverTime.Evaluate(time);
}
if (ModifyFogDensity)
{
RenderSettings.fogDensity = MMTween.Tween(time, 0f, 1f, DensityRemapZero, DensityRemapOne, DensityCurve) * intensityMultiplier;
}
if (ModifyStartDistance)
{
RenderSettings.fogStartDistance = MMTween.Tween(time, 0f, 1f, StartDistanceRemapZero, StartDistanceRemapOne, StartDistanceCurve);
}
if (ModifyEndDistance)
{
RenderSettings.fogEndDistance = MMTween.Tween(time, 0f, 1f, EndDistanceRemapZero, EndDistanceRemapOne, EndDistanceCurve);
}
}
/// <summary>
/// Stops this feedback
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized || (_coroutine == null))
{
return;
}
base.CustomStopFeedback(position, feedbacksIntensity);
IsPlaying = false;
Owner.StopCoroutine(_coroutine);
_coroutine = null;
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
RenderSettings.fogColor = _initialColor;
RenderSettings.fogStartDistance = _initialStartDistance;
RenderSettings.fogEndDistance = _initialEndDistance;
RenderSettings.fogDensity = _initialDensity;
}
}
}

View File

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

View File

@@ -0,0 +1,207 @@
using System.Collections;
using System.Collections.Generic;
using MoreMountains.Tools;
using UnityEngine;
using UnityEngine.UI;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you change the alpha of a target sprite renderer over time.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will let you change the alpha of a target Image over time.")]
[FeedbackPath("UI/Image Alpha")]
public class MMF_ImageAlpha : 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.UIColor; } }
public override bool EvaluateRequiresSetup() { return (BoundImage == null); }
public override string RequiredTargetText { get { return BoundImage != null ? BoundImage.name : ""; } }
public override string RequiresSetupText { get { return "This feedback requires that a BoundImage be set to be able to work properly. You can set one below."; } }
#endif
public override bool HasCustomInspectors => true;
/// the possible modes for this feedback
public enum Modes { OverTime, Instant, ToDestination }
[MMFInspectorGroup("Target Image", true, 12, true)]
/// the Image to affect when playing the feedback
[Tooltip("the Image to affect when playing the feedback")]
public Image BoundImage;
[MMFInspectorGroup("Image Alpha Animation", true, 24)]
/// whether the feedback should affect the Image instantly or over a period of time
[Tooltip("whether the feedback should affect the Image instantly or over a period of time")]
public Modes Mode = Modes.OverTime;
/// how long the Image should change over time
[Tooltip("how long the Image should change over time")]
[MMFEnumCondition("Mode", (int)Modes.OverTime, (int)Modes.ToDestination)]
public float Duration = 0.2f;
/// if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over
[Tooltip("if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over")]
public bool AllowAdditivePlays = false;
/// the alpha to move to in instant mode
[Tooltip("the alpha to move to in instant mode")]
[MMFEnumCondition("Mode", (int)Modes.Instant)]
public float InstantAlpha = 1f;
/// the curve to use when interpolating towards the destination alpha
[Tooltip("the curve to use when interpolating towards the destination alpha")]
[MMFEnumCondition("Mode", (int)Modes.OverTime, (int)Modes.ToDestination)]
public MMTweenType Curve = new MMTweenType(MMTween.MMTweenCurve.EaseInCubic);
/// the value to which the curve's 0 should be remapped
[Tooltip("the value to which the curve's 0 should be remapped")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float CurveRemapZero = 0f;
/// the value to which the curve's 1 should be remapped
[Tooltip("the value to which the curve's 1 should be remapped")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float CurveRemapOne = 1f;
/// the alpha to aim towards when in ToDestination mode
[Tooltip("the alpha to aim towards when in ToDestination mode")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float DestinationAlpha = 1f;
/// if this is true, the target will be disabled when this feedbacks is stopped
[Tooltip("if this is true, the target will be disabled when this feedbacks is stopped")]
public bool DisableOnStop = true;
/// the duration of this feedback is the duration of the Image, or 0 if instant
public override float FeedbackDuration { get { return (Mode == Modes.Instant) ? 0f : ApplyTimeMultiplier(Duration); } set { Duration = value; } }
protected Coroutine _coroutine;
protected Color _imageColor;
protected Color _initialColor;
protected float _initialAlpha;
/// <summary>
/// On Play we turn our Image on and start an over time coroutine if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
_initialColor = BoundImage.color;
Turn(true);
switch (Mode)
{
case Modes.Instant:
_imageColor = BoundImage.color;
_imageColor.a = InstantAlpha;
BoundImage.color = _imageColor;
break;
case Modes.OverTime:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
_coroutine = Owner.StartCoroutine(ImageSequence());
break;
case Modes.ToDestination:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
_coroutine = Owner.StartCoroutine(ImageSequence());
break;
}
}
/// <summary>
/// This coroutine will modify the values on the Image
/// </summary>
/// <returns></returns>
protected virtual IEnumerator ImageSequence()
{
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
_imageColor = BoundImage.color;
_initialAlpha = BoundImage.color.a;
IsPlaying = true;
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
{
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
SetAlpha(remappedTime);
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
yield return null;
}
SetAlpha(FinalNormalizedTime);
_coroutine = null;
IsPlaying = false;
yield return null;
}
/// <summary>
/// Sets the various values on the sprite renderer on a specified time (between 0 and 1)
/// </summary>
/// <param name="time"></param>
protected virtual void SetAlpha(float time)
{
float newAlpha = 0f;
if (Mode == Modes.OverTime)
{
newAlpha = MMTween.Tween(time, 0f, 1f, CurveRemapZero, CurveRemapOne, Curve);
}
else if (Mode == Modes.ToDestination)
{
newAlpha = MMTween.Tween(time, 0f, 1f, _initialAlpha, DestinationAlpha, Curve);
}
_imageColor.a = newAlpha;
BoundImage.color = _imageColor;
}
/// <summary>
/// Turns the sprite renderer off on stop
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
IsPlaying = false;
base.CustomStopFeedback(position, feedbacksIntensity);
if (Active && DisableOnStop)
{
Turn(false);
}
_coroutine = null;
}
/// <summary>
/// Turns the sprite renderer on or off
/// </summary>
/// <param name="status"></param>
protected virtual void Turn(bool status)
{
BoundImage.gameObject.SetActive(status);
BoundImage.enabled = status;
}
/// <summary>
/// On restore, we restore our initial state
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
BoundImage.color = _initialColor;
}
}
}

View File

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

View File

@@ -0,0 +1,205 @@
using System.Collections;
using System.Collections.Generic;
using MoreMountains.Tools;
using UnityEngine;
using UnityEngine.UI;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you change the fill value of a target Image over time.
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will let you modify the fill value of a target Image over time.")]
[FeedbackPath("UI/Image Fill")]
public class MMF_ImageFill : 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.UIColor; } }
public override bool EvaluateRequiresSetup() { return (BoundImage == null); }
public override string RequiredTargetText { get { return BoundImage != null ? BoundImage.name : ""; } }
public override string RequiresSetupText { get { return "This feedback requires that a BoundImage be set to be able to work properly. You can set one below."; } }
#endif
public override bool HasCustomInspectors => true;
/// the possible modes for this feedback
public enum Modes { OverTime, Instant, ToDestination }
[MMFInspectorGroup("Target Image", true, 12, true)]
/// the Image to affect when playing the feedback
[Tooltip("the Image to affect when playing the feedback")]
public Image BoundImage;
[MMFInspectorGroup("Image Fill Animation", true, 24)]
/// whether the feedback should affect the Image instantly or over a period of time
[Tooltip("whether the feedback should affect the Image instantly or over a period of time")]
public Modes Mode = Modes.OverTime;
/// how long the Image should change over time
[Tooltip("how long the Image should change over time")]
[MMFEnumCondition("Mode", (int)Modes.OverTime, (int)Modes.ToDestination)]
public float Duration = 0.2f;
/// if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over
[Tooltip("if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over")]
public bool AllowAdditivePlays = false;
/// the fill to move to in instant mode
[Tooltip("the fill to move to in instant mode")]
[MMFEnumCondition("Mode", (int)Modes.Instant)]
public float InstantFill = 1f;
/// the curve to use when interpolating towards the destination fill
[Tooltip("the curve to use when interpolating towards the destination fill")]
[MMFEnumCondition("Mode", (int)Modes.OverTime, (int)Modes.ToDestination)]
public MMTweenType Curve = new MMTweenType(MMTween.MMTweenCurve.EaseInCubic);
/// the value to which the curve's 0 should be remapped
[Tooltip("the value to which the curve's 0 should be remapped")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float CurveRemapZero = 0f;
/// the value to which the curve's 1 should be remapped
[Tooltip("the value to which the curve's 1 should be remapped")]
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
public float CurveRemapOne = 1f;
/// the fill to aim towards when in ToDestination mode
[Tooltip("the fill to aim towards when in ToDestination mode")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float DestinationFill = 1f;
/// if this is true, the target will be disabled when this feedbacks is stopped
[Tooltip("if this is true, the target will be disabled when this feedbacks is stopped")]
public bool DisableOnStop = true;
/// the duration of this feedback is the duration of the Image, or 0 if instant
public override float FeedbackDuration { get { return (Mode == Modes.Instant) ? 0f : ApplyTimeMultiplier(Duration); } set { Duration = value; } }
protected Coroutine _coroutine;
protected float _initialFill;
protected bool _initialState;
/// <summary>
/// On Play we turn our Image on and start an over time coroutine if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
_initialState = BoundImage.gameObject.activeInHierarchy;
Turn(true);
_initialFill = BoundImage.fillAmount;
switch (Mode)
{
case Modes.Instant:
BoundImage.fillAmount = InstantFill;
break;
case Modes.OverTime:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
_coroutine = Owner.StartCoroutine(ImageSequence());
break;
case Modes.ToDestination:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
_coroutine = Owner.StartCoroutine(ImageSequence());
break;
}
}
/// <summary>
/// This coroutine will modify the values on the Image
/// </summary>
/// <returns></returns>
protected virtual IEnumerator ImageSequence()
{
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
_initialFill = BoundImage.fillAmount;
IsPlaying = true;
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
{
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
SetFill(remappedTime);
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
yield return null;
}
SetFill(FinalNormalizedTime);
_coroutine = null;
IsPlaying = false;
yield return null;
}
/// <summary>
/// Sets the various values on the sprite renderer on a specified time (between 0 and 1)
/// </summary>
/// <param name="time"></param>
protected virtual void SetFill(float time)
{
float newFill = 0f;
if (Mode == Modes.OverTime)
{
newFill = MMTween.Tween(time, 0f, 1f, CurveRemapZero, CurveRemapOne, Curve);
}
else if (Mode == Modes.ToDestination)
{
newFill = MMTween.Tween(time, 0f, 1f, _initialFill, DestinationFill, Curve);
}
BoundImage.fillAmount = newFill;
}
/// <summary>
/// Turns the sprite renderer off on stop
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
IsPlaying = false;
base.CustomStopFeedback(position, feedbacksIntensity);
if (Active && DisableOnStop)
{
Turn(false);
}
_coroutine = null;
}
/// <summary>
/// Turns the sprite renderer on or off
/// </summary>
/// <param name="status"></param>
protected virtual void Turn(bool status)
{
BoundImage.gameObject.SetActive(status);
BoundImage.enabled = status;
}
/// <summary>
/// On restore, we put our object back at its initial position
/// </summary>
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
Turn(_initialState);
BoundImage.fillAmount = _initialFill;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95530134bb5ab7b4a959774f63c2e92f
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.Tools;
using UnityEngine.SceneManagement;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will request the load of a new scene, using the method of your choice
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will request the load of a new scene, using the method of your choice")]
[FeedbackPath("Scene/Load Scene")]
public class MMF_LoadScene : 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.SceneColor; } }
public override bool EvaluateRequiresSetup() { return (DestinationSceneName == ""); }
public override string RequiredTargetText { get { return DestinationSceneName; } }
public override string RequiresSetupText { get { return "This feedback requires that you specify a DestinationSceneName below. Make sure you also add that destination scene to your Build Settings."; } }
#endif
/// the possible ways to load a new scene :
/// - direct : uses Unity's SceneManager API
/// - direct additive : uses Unity's SceneManager API, but with additive mode (so loading the scene on top of the current one)
/// - MMSceneLoadingManager : the simple, original MM way of loading scenes
/// - MMAdditiveSceneLoadingManager : a more advanced way of loading scenes, with (way) more options
public enum LoadingModes { Direct, MMSceneLoadingManager, MMAdditiveSceneLoadingManager, DirectAdditive }
[MMFInspectorGroup("Scene Loading", true, 57, true)]
/// the name of the loading screen scene to use
[Tooltip("the name of the loading screen scene to use - HAS TO BE ADDED TO YOUR BUILD SETTINGS")]
public string LoadingSceneName = "MMAdditiveLoadingScreen";
/// the name of the destination scene
[Tooltip("the name of the destination scene - HAS TO BE ADDED TO YOUR BUILD SETTINGS")]
public string DestinationSceneName = "";
[Header("Mode")]
/// the loading mode to use
[Tooltip("the loading mode to use to load the destination scene : " +
"- direct : uses Unity's SceneManager API" +
"- MMSceneLoadingManager : the simple, original MM way of loading scenes" +
"- MMAdditiveSceneLoadingManager : a more advanced way of loading scenes, with (way) more options")]
public LoadingModes LoadingMode = LoadingModes.MMAdditiveSceneLoadingManager;
[Header("Loading Scene Manager")]
/// the priority to use when loading the new scenes
[Tooltip("the priority to use when loading the new scenes")]
public ThreadPriority Priority = ThreadPriority.High;
/// whether or not to interpolate progress (slower, but usually looks better and smoother)
[Tooltip("whether or not to interpolate progress (slower, but usually looks better and smoother)")]
public bool InterpolateProgress = true;
/// whether or not to perform extra checks to make sure the loading screen and destination scene are in the build settings
[Tooltip("whether or not to perform extra checks to make sure the loading screen and destination scene are in the build settings")]
public bool SecureLoad = true;
[MMFInspectorGroup("Loading Scene Delays", true, 58)]
/// a delay (in seconds) to apply before the first fade plays
[Tooltip("a delay (in seconds) to apply before the first fade plays")]
public float BeforeEntryFadeDelay = 0f;
/// the duration (in seconds) of the entry fade
[Tooltip("the duration (in seconds) of the entry fade")]
public float EntryFadeDuration = 0.2f;
/// a delay (in seconds) to apply after the first fade plays
[Tooltip("a delay (in seconds) to apply after the first fade plays")]
public float AfterEntryFadeDelay = 0f;
/// a delay (in seconds) to apply before the exit fade plays
[Tooltip("a delay (in seconds) to apply before the exit fade plays")]
public float BeforeExitFadeDelay = 0f;
/// the duration (in seconds) of the exit fade
[Tooltip("the duration (in seconds) of the exit fade")]
public float ExitFadeDuration = 0.2f;
[MMFInspectorGroup("Transitions", true, 59)]
/// the speed at which the progress bar should move if interpolated
[Tooltip("the speed at which the progress bar should move if interpolated")]
public float ProgressInterpolationSpeed = 5f;
/// the order in which to play fades (really depends on the type of fader you have in your loading screen
[Tooltip("the order in which to play fades (really depends on the type of fader you have in your loading screen")]
public MMAdditiveSceneLoadingManager.FadeModes FadeMode = MMAdditiveSceneLoadingManager.FadeModes.FadeInThenOut;
/// the tween to use on the entry fade
[Tooltip("the tween to use on the entry fade")]
public MMTweenType EntryFadeTween = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
/// the tween to use on the exit fade
[Tooltip("the tween to use on the exit fade")]
public MMTweenType ExitFadeTween = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
/// <summary>
/// On play, we request a load of the destination scene using hte specified method
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (LoadingMode)
{
case LoadingModes.Direct:
SceneManager.LoadScene(DestinationSceneName);
break;
case LoadingModes.DirectAdditive:
SceneManager.LoadScene(DestinationSceneName, LoadSceneMode.Additive);
break;
case LoadingModes.MMSceneLoadingManager:
MMSceneLoadingManager.LoadScene(DestinationSceneName, LoadingSceneName);
break;
case LoadingModes.MMAdditiveSceneLoadingManager:
MMAdditiveSceneLoadingManager.LoadScene(DestinationSceneName, LoadingSceneName,
Priority, SecureLoad, InterpolateProgress,
BeforeEntryFadeDelay, EntryFadeDuration,
AfterEntryFadeDelay,
BeforeExitFadeDelay, ExitFadeDuration,
EntryFadeTween, ExitFadeTween,
ProgressInterpolationSpeed, FadeMode);
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,43 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will trigger a MMGameEvent of the specified name when played
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback will trigger a MMGameEvent of the specified name when played")]
[FeedbackPath("Events/MMGameEvent")]
public class MMF_MMGameEvent : 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.EventsColor; } }
public override bool EvaluateRequiresSetup() { return (MMGameEventName == ""); }
public override string RequiredTargetText { get { return MMGameEventName; } }
public override string RequiresSetupText { get { return "This feedback requires that you specify a MMGameEventName below."; } }
#endif
[MMFInspectorGroup("MMGameEvent", true, 57, true)]
public string MMGameEventName;
/// <summary>
/// On Play we change the values of our fog
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMGameEvent.Trigger(MMGameEventName);
}
}
}

View File

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

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// A feedback used to control all sounds playing on the MMSoundManager at once. It'll let you pause, play, stop and free (stop and returns the audiosource to the pool) sounds. You will need a MMSoundManager in your scene for this to work.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager All Sounds Control")]
[FeedbackHelp("A feedback used to control all sounds playing on the MMSoundManager at once. It'll let you pause, play, stop and free (stop and returns the audiosource to the pool) sounds. You will need a MMSoundManager in your scene for this to work.")]
public class MMF_MMSoundManagerAllSoundsControl : 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.SoundsColor; } }
public override string RequiredTargetText { get { return ControlMode.ToString(); } }
#endif
[MMFInspectorGroup("MMSoundManager All Sounds Control", true, 30)]
/// The selected control mode.
[Tooltip("The selected control mode")]
public MMSoundManagerAllSoundsControlEventTypes ControlMode = MMSoundManagerAllSoundsControlEventTypes.Pause;
/// <summary>
/// On Play, we call the specified event, to be caught by the MMSoundManager
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (ControlMode)
{
case MMSoundManagerAllSoundsControlEventTypes.Pause:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.Pause);
break;
case MMSoundManagerAllSoundsControlEventTypes.Play:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.Play);
break;
case MMSoundManagerAllSoundsControlEventTypes.Stop:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.Stop);
break;
case MMSoundManagerAllSoundsControlEventTypes.Free:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.Free);
break;
case MMSoundManagerAllSoundsControlEventTypes.FreeAllButPersistent:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.FreeAllButPersistent);
break;
case MMSoundManagerAllSoundsControlEventTypes.FreeAllLooping:
MMSoundManagerAllSoundsControlEvent.Trigger(MMSoundManagerAllSoundsControlEventTypes.FreeAllLooping);
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you trigger save, load, and reset on MMSoundManager settings. You will need a MMSoundManager in your scene for this to work.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager Save and Load")]
[FeedbackHelp("This feedback will let you trigger save, load, and reset on MMSoundManager settings. You will need a MMSoundManager in your scene for this to work.")]
public class MMF_MMSoundManagerSaveLoad : 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.SoundsColor; } }
public override string RequiredTargetText { get { return Mode.ToString(); } }
#endif
/// the possible modes you can use to interact with save settings
public enum Modes { Save, Load, Reset }
[MMFInspectorGroup("MMSoundManager Save and Load", true, 30)]
/// the selected mode to interact with save settings on the MMSoundManager
[Tooltip("the selected mode to interact with save settings on the MMSoundManager")]
public Modes Mode = Modes.Save;
/// <summary>
/// On Play, saves, loads or resets settings
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
switch (Mode)
{
case Modes.Save:
MMSoundManagerEvent.Trigger(MMSoundManagerEventTypes.SaveSettings);
break;
case Modes.Load:
MMSoundManagerEvent.Trigger(MMSoundManagerEventTypes.LoadSettings);
break;
case Modes.Reset:
MMSoundManagerEvent.Trigger(MMSoundManagerEventTypes.ResetSettings);
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,537 @@
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;
using Random = UnityEngine.Random;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you play a sound via the MMSoundManager. You will need a game object in your scene with a MMSoundManager object on it for this to work.
/// </summary>
[ExecuteAlways]
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager Sound")]
[FeedbackHelp("This feedback will let you play a sound via the MMSoundManager. You will need a game object in your scene with a MMSoundManager object on it for this to work.")]
public class MMF_MMSoundManagerSound : 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.SoundsColor; } }
public override bool EvaluateRequiresSetup()
{
bool requiresSetup = false;
if (Sfx == null)
{
requiresSetup = true;
}
if ((RandomSfx != null) && (RandomSfx.Length > 0))
{
requiresSetup = false;
foreach (AudioClip clip in RandomSfx)
{
if (clip == null)
{
requiresSetup = true;
}
}
}
return requiresSetup;
}
public override string RequiredTargetText { get { return Sfx != null ? Sfx.name : ""; } }
public override string RequiresSetupText { get { return "This feedback requires that you set an Audio clip in its Sfx slot below, or one or more clips in the Random Sfx array."; } }
public override bool HasCustomInspectors { get { return true; } }
#endif
/// the duration of this feedback is the duration of the clip being played
public override float FeedbackDuration { get { return GetDuration(); } }
public override bool HasRandomness => true;
[MMFInspectorGroup("Sound", true, 14, true)]
/// the sound clip to play
[Tooltip("the sound clip to play")]
public AudioClip Sfx;
[MMFInspectorGroup("Random Sound", true, 34, true)]
/// an array to pick a random sfx from
[Tooltip("an array to pick a random sfx from")]
public AudioClip[] RandomSfx;
/// if this is true, random sfx audio clips will be played in sequential order instead of at random
[Tooltip("if this is true, random sfx audio clips will be played in sequential order instead of at random")]
public bool SequentialOrder = false;
/// if we're in sequential order, determines whether or not to hold at the last index, until either a cooldown is met, or the ResetSequentialIndex method is called
[Tooltip("if we're in sequential order, determines whether or not to hold at the last index, until either a cooldown is met, or the ResetSequentialIndex method is called")]
[MMFCondition("SequentialOrder", true)]
public bool SequentialOrderHoldLast = false;
/// if we're in sequential order hold last mode, index will reset to 0 automatically after this duration, unless it's 0, in which case it'll be ignored
[Tooltip("if we're in sequential order hold last mode, index will reset to 0 automatically after this duration, unless it's 0, in which case it'll be ignored")]
[MMFCondition("SequentialOrderHoldLast", true)]
public float SequentialOrderHoldCooldownDuration = 2f;
[MMFInspectorGroup("Sound Properties", true, 24)]
[Header("Volume")]
/// the minimum volume to play the sound at
[Tooltip("the minimum volume to play the sound at")]
[Range(0f,2f)]
public float MinVolume = 1f;
/// the maximum volume to play the sound at
[Tooltip("the maximum volume to play the sound at")]
[Range(0f,2f)]
public float MaxVolume = 1f;
[Header("Pitch")]
/// the minimum pitch to play the sound at
[Tooltip("the minimum pitch to play the sound at")]
[Range(-3f,3f)]
public float MinPitch = 1f;
/// the maximum pitch to play the sound at
[Tooltip("the maximum pitch to play the sound at")]
[Range(-3f,3f)]
public float MaxPitch = 1f;
[Header("Time")]
/// the minimum and maximum time stamps at which to play the sound
[Tooltip("the minimum and maximum time stamps at which to play the sound")]
[MMVector("Min", "Max")]
public Vector2 PlaybackTime = new Vector2(0f, 0f);
[MMFInspectorGroup("SoundManager Options", true, 28)]
/// the track on which to play the sound. Pick the one that matches the nature of your sound
[Tooltip("the track on which to play the sound. Pick the one that matches the nature of your sound")]
public MMSoundManager.MMSoundManagerTracks MmSoundManagerTrack = MMSoundManager.MMSoundManagerTracks.Sfx;
/// the ID of the sound. This is useful if you plan on using sound control feedbacks on it afterwards.
[Tooltip("the ID of the sound. This is useful if you plan on using sound control feedbacks on it afterwards.")]
public int ID = 0;
/// the AudioGroup on which to play the sound. If you're already targeting a preset track, you can leave it blank, otherwise the group you specify here will override it.
[Tooltip("the AudioGroup on which to play the sound. If you're already targeting a preset track, you can leave it blank, otherwise the group you specify here will override it.")]
public AudioMixerGroup AudioGroup = null;
/// if (for some reason) you've already got an audiosource and wouldn't like to use the built-in pool system, you can specify it here
[Tooltip("if (for some reason) you've already got an audiosource and wouldn't like to use the built-in pool system, you can specify it here")]
public AudioSource RecycleAudioSource = null;
/// whether or not this sound should loop
[Tooltip("whether or not this sound should loop")]
public bool Loop = false;
/// whether or not this sound should continue playing when transitioning to another scene
[Tooltip("whether or not this sound should continue playing when transitioning to another scene")]
public bool Persistent = false;
/// whether or not this sound should play if the same sound clip is already playing
[Tooltip("whether or not this sound should play if the same sound clip is already playing")]
public bool DoNotPlayIfClipAlreadyPlaying = false;
/// if this is true, this sound will stop playing when stopping the feedback
[Tooltip("if this is true, this sound will stop playing when stopping the feedback")]
public bool StopSoundOnFeedbackStop = false;
[MMFInspectorGroup("Fade", true, 30)]
/// whether or not to fade this sound in when playing it
[Tooltip("whether or not to fade this sound in when playing it")]
public bool Fade = false;
/// if fading, the volume at which to start the fade
[Tooltip("if fading, the volume at which to start the fade")]
[MMCondition("Fade", true)]
public float FadeInitialVolume = 0f;
/// if fading, the duration of the fade, in seconds
[Tooltip("if fading, the duration of the fade, in seconds")]
[MMCondition("Fade", true)]
public float FadeDuration = 1f;
/// if fading, the tween over which to fade the sound
[Tooltip("if fading, the tween over which to fade the sound ")]
[MMCondition("Fade", true)]
public MMTweenType FadeTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic);
[MMFInspectorGroup("Solo", true, 32)]
/// whether or not this sound should play in solo mode over its destination track. If yes, all other sounds on that track will be muted when this sound starts playing
[Tooltip("whether or not this sound should play in solo mode over its destination track. If yes, all other sounds on that track will be muted when this sound starts playing")]
public bool SoloSingleTrack = false;
/// whether or not this sound should play in solo mode over all other tracks. If yes, all other tracks will be muted when this sound starts playing
[Tooltip("whether or not this sound should play in solo mode over all other tracks. If yes, all other tracks will be muted when this sound starts playing")]
public bool SoloAllTracks = false;
/// if in any of the above solo modes, AutoUnSoloOnEnd will unmute the track(s) automatically once that sound stops playing
[Tooltip("if in any of the above solo modes, AutoUnSoloOnEnd will unmute the track(s) automatically once that sound stops playing")]
public bool AutoUnSoloOnEnd = false;
[MMFInspectorGroup("Spatial Settings", true, 33)]
/// Pans a playing sound in a stereo way (left or right). This only applies to sounds that are Mono or Stereo.
[Tooltip("Pans a playing sound in a stereo way (left or right). This only applies to sounds that are Mono or Stereo.")]
[Range(-1f,1f)]
public float PanStereo;
/// Sets how much this AudioSource is affected by 3D spatialisation calculations (attenuation, doppler etc). 0.0 makes the sound full 2D, 1.0 makes it full 3D.
[Tooltip("Sets how much this AudioSource is affected by 3D spatialisation calculations (attenuation, doppler etc). 0.0 makes the sound full 2D, 1.0 makes it full 3D.")]
[Range(0f,1f)]
public float SpatialBlend;
[MMFInspectorGroup("Effects", true, 36)]
/// Bypass effects (Applied from filter components or global listener filters).
[Tooltip("Bypass effects (Applied from filter components or global listener filters).")]
public bool BypassEffects = false;
/// When set global effects on the AudioListener will not be applied to the audio signal generated by the AudioSource. Does not apply if the AudioSource is playing into a mixer group.
[Tooltip("When set global effects on the AudioListener will not be applied to the audio signal generated by the AudioSource. Does not apply if the AudioSource is playing into a mixer group.")]
public bool BypassListenerEffects = false;
/// When set doesn't route the signal from an AudioSource into the global reverb associated with reverb zones.
[Tooltip("When set doesn't route the signal from an AudioSource into the global reverb associated with reverb zones.")]
public bool BypassReverbZones = false;
/// Sets the priority of the AudioSource.
[Tooltip("Sets the priority of the AudioSource.")]
[Range(0, 256)]
public int Priority = 128;
/// The amount by which the signal from the AudioSource will be mixed into the global reverb associated with the Reverb Zones.
[Tooltip("The amount by which the signal from the AudioSource will be mixed into the global reverb associated with the Reverb Zones.")]
[Range(0f,1.1f)]
public float ReverbZoneMix = 1f;
[MMFInspectorGroup("3D Sound Settings", true, 37)]
/// Sets the Doppler scale for this AudioSource.
[Tooltip("Sets the Doppler scale for this AudioSource.")]
[Range(0f,5f)]
public float DopplerLevel = 1f;
/// Sets the spread angle (in degrees) of a 3d stereo or multichannel sound in speaker space.
[Tooltip("Sets the spread angle (in degrees) of a 3d stereo or multichannel sound in speaker space.")]
[Range(0,360)]
public int Spread = 0;
/// Sets/Gets how the AudioSource attenuates over distance.
[Tooltip("Sets/Gets how the AudioSource attenuates over distance.")]
public AudioRolloffMode RolloffMode = AudioRolloffMode.Logarithmic;
/// Within the Min distance the AudioSource will cease to grow louder in volume.
[Tooltip("Within the Min distance the AudioSource will cease to grow louder in volume.")]
public float MinDistance = 1f;
/// (Logarithmic rolloff) MaxDistance is the distance a sound stops attenuating at.
[Tooltip("(Logarithmic rolloff) MaxDistance is the distance a sound stops attenuating at.")]
public float MaxDistance = 500f;
[MMFInspectorGroup("Debug", true, 31)]
/// whether or not to draw sound falloff gizmos when this MMF Player is selected
[Tooltip("whether or not to draw sound falloff gizmos when this MMF Player is selected")]
public bool DrawGizmos = false;
/// an object to use as the center of the gizmos. If left empty, this MMF Player's position will be used.
[Tooltip("an object to use as the center of the gizmos. If left empty, this MMF Player's position will be used.")]
[MMFCondition("DrawGizmos", true)]
public Transform GizmosCenter;
/// the color to use to draw the min distance sphere of the sound falloff gizmos
[Tooltip("the color to use to draw the min distance sphere of the sound falloff gizmos")]
[MMFCondition("DrawGizmos", true)]
public Color MinDistanceColor = MMColors.CadetBlue;
/// the color to use to draw the max distance sphere of the sound falloff gizmos
[Tooltip("the color to use to draw the max distance sphere of the sound falloff gizmos")]
[MMFCondition("DrawGizmos", true)]
public Color MaxDistanceColor = MMColors.Orangered;
/// a test button used to play the sound in inspector
public MMF_Button TestPlayButton;
/// a test button used to stop the sound in inspector
public MMF_Button TestStopButton;
/// a test button used to stop the sound in inspector
public MMF_Button ResetSequentialIndexButton;
protected AudioClip _randomClip;
protected AudioSource _editorAudioSource;
protected MMSoundManagerPlayOptions _options;
protected AudioSource _playedAudioSource;
protected float _randomPlaybackTime;
protected int _currentIndex = 0;
protected Vector3 _gizmoCenter;
/// <summary>
/// Initializes the debug buttons
/// </summary>
public override void InitializeCustomAttributes()
{
TestPlayButton = new MMF_Button("Debug Play Sound", TestPlaySound);
TestStopButton = new MMF_Button("Debug Stop Sound", TestStopSound);
ResetSequentialIndexButton = new MMF_Button("Reset Sequential Index", ResetSequentialIndex);
}
/// <summary>
/// Plays either a random sound or the specified sfx
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
if (Sfx != null)
{
PlaySound(Sfx, position, intensityMultiplier);
return;
}
if (RandomSfx.Length > 0)
{
_randomClip = PickRandomClip();
if (_randomClip != null)
{
PlaySound(_randomClip, position, intensityMultiplier);
}
}
}
/// <summary>
/// On Stop, we stop our sound if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
if (StopSoundOnFeedbackStop && (_playedAudioSource != null))
{
_playedAudioSource.Stop();
MMSoundManager.Instance.FreeSound(_playedAudioSource);
}
}
/// <summary>
/// Triggers a play sound event
/// </summary>
/// <param name="sfx"></param>
/// <param name="position"></param>
/// <param name="intensity"></param>
protected virtual void PlaySound(AudioClip sfx, Vector3 position, float intensity)
{
if (DoNotPlayIfClipAlreadyPlaying)
{
if (_playedAudioSource != null && _playedAudioSource.isPlaying)
{
return;
}
if (MMSoundManager.Instance.FindByClip(sfx) != null)
{
return;
}
}
float volume = Random.Range(MinVolume, MaxVolume);
if (!Timing.ConstantIntensity)
{
volume = volume * intensity;
}
float pitch = Random.Range(MinPitch, MaxPitch);
_randomPlaybackTime = Random.Range(PlaybackTime.x, PlaybackTime.y);
int timeSamples = NormalPlayDirection ? 0 : sfx.samples - 1;
_options.MmSoundManagerTrack = MmSoundManagerTrack;
_options.Location = position;
_options.Loop = Loop;
_options.Volume = volume;
_options.ID = ID;
_options.Fade = Fade;
_options.FadeInitialVolume = FadeInitialVolume;
_options.FadeDuration = FadeDuration;
_options.FadeTween = FadeTween;
_options.Persistent = Persistent;
_options.RecycleAudioSource = RecycleAudioSource;
_options.AudioGroup = AudioGroup;
_options.Pitch = pitch;
_options.PlaybackTime = _randomPlaybackTime;
_options.PanStereo = PanStereo;
_options.SpatialBlend = SpatialBlend;
_options.SoloSingleTrack = SoloSingleTrack;
_options.SoloAllTracks = SoloAllTracks;
_options.AutoUnSoloOnEnd = AutoUnSoloOnEnd;
_options.BypassEffects = BypassEffects;
_options.BypassListenerEffects = BypassListenerEffects;
_options.BypassReverbZones = BypassReverbZones;
_options.Priority = Priority;
_options.ReverbZoneMix = ReverbZoneMix;
_options.DopplerLevel = DopplerLevel;
_options.Spread = Spread;
_options.RolloffMode = RolloffMode;
_options.MinDistance = MinDistance;
_options.MaxDistance = MaxDistance;
_playedAudioSource = MMSoundManagerSoundPlayEvent.Trigger(sfx, _options);
_lastPlayTimestamp = FeedbackTime;
}
/// <summary>
/// Returns the duration of the sound, or of the longest of the random sounds
/// </summary>
/// <returns></returns>
protected virtual float GetDuration()
{
if (Sfx != null)
{
return Sfx.length - _randomPlaybackTime;
}
float longest = 0f;
if ((RandomSfx != null) && (RandomSfx.Length > 0))
{
foreach (AudioClip clip in RandomSfx)
{
if ((clip != null) && (clip.length > longest))
{
longest = clip.length;
}
}
return longest - _randomPlaybackTime;
}
return 0f;
}
public override void OnDrawGizmosSelected()
{
if (!DrawGizmos)
{
return;
}
_gizmoCenter = GizmosCenter != null ? GizmosCenter.position : Owner.transform.position;
Gizmos.color = MinDistanceColor;
Gizmos.DrawWireSphere(_gizmoCenter, MinDistance);
Gizmos.color = MaxDistanceColor;
Gizmos.DrawWireSphere(_gizmoCenter, MaxDistance);
}
#region TestMethods
/// <summary>
/// A test method that creates an audiosource, plays it, and destroys itself after play
/// </summary>
protected virtual async void TestPlaySound()
{
AudioClip tmpAudioClip = null;
if (Sfx != null)
{
tmpAudioClip = Sfx;
}
if ((RandomSfx != null) && (RandomSfx.Length > 0))
{
tmpAudioClip = PickRandomClip();
}
if (tmpAudioClip == null)
{
Debug.LogError(Label + " on " + Owner.gameObject.name + " can't play in editor mode, you haven't set its Sfx.");
return;
}
float volume = Random.Range(MinVolume, MaxVolume);
float pitch = Random.Range(MinPitch, MaxPitch);
_randomPlaybackTime = Random.Range(PlaybackTime.x, PlaybackTime.y);
GameObject temporaryAudioHost = new GameObject("EditorTestAS_WillAutoDestroy");
SceneManager.MoveGameObjectToScene(temporaryAudioHost.gameObject, Owner.gameObject.scene);
temporaryAudioHost.transform.position = Owner.transform.position;
_editorAudioSource = temporaryAudioHost.AddComponent<AudioSource>() as AudioSource;
PlayAudioSource(_editorAudioSource, tmpAudioClip, volume, pitch, _randomPlaybackTime);
_lastPlayTimestamp = FeedbackTime;
float length = 1000 * tmpAudioClip.length;
length = length / Mathf.Abs(pitch);
await Task.Delay((int)length);
Object.DestroyImmediate(temporaryAudioHost);
}
/// <summary>
/// A test method that stops the test sound
/// </summary>
protected virtual void TestStopSound()
{
if (_editorAudioSource != null)
{
_editorAudioSource.Stop();
}
}
/// <summary>
/// Plays the audio source with the specified volume and pitch
/// </summary>
/// <param name="audioSource"></param>
/// <param name="sfx"></param>
/// <param name="volume"></param>
/// <param name="pitch"></param>
protected virtual void PlayAudioSource(AudioSource audioSource, AudioClip sfx, float volume, float pitch, float time)
{
// we set that audio source clip to the one in paramaters
audioSource.clip = sfx;
audioSource.time = time;
// we set the audio source volume to the one in parameters
audioSource.volume = volume;
audioSource.pitch = pitch;
// we set our loop setting
audioSource.loop = false;
// we start playing the sound
audioSource.Play();
}
/// <summary>
/// Determines the next index to play when dealing with random clips
/// </summary>
/// <returns></returns>
protected virtual AudioClip PickRandomClip()
{
int newIndex = 0;
if (!SequentialOrder)
{
newIndex = Random.Range(0, RandomSfx.Length);
}
else
{
newIndex = _currentIndex;
if (newIndex >= RandomSfx.Length)
{
if (SequentialOrderHoldLast)
{
newIndex--;
if ((SequentialOrderHoldCooldownDuration > 0)
&& (FeedbackTime - _lastPlayTimestamp > SequentialOrderHoldCooldownDuration))
{
newIndex = 0;
}
}
else
{
newIndex = 0;
}
}
_currentIndex = newIndex + 1;
}
return RandomSfx[newIndex];
}
/// <summary>
/// Forces a reset of the sequential index to 0
/// </summary>
public virtual void ResetSequentialIndex()
{
_currentIndex = 0;
}
/// <summary>
/// Forces a reset of the sequential index to the value specified in parameters
/// </summary>
/// <param name="newIndex"></param>
public virtual void SetSequentialIndex(int newIndex)
{
_currentIndex = newIndex;
}
#endregion
}
}

View File

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

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback will let you control a specific sound (or sounds), targeted by SoundID, which has to match the SoundID of the sound you intially played. You will need a MMSoundManager in your scene for this to work.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager Sound Control")]
[FeedbackHelp("This feedback will let you control a specific sound (or sounds), targeted by SoundID, which has to match the SoundID of the sound you intially played. You will need a MMSoundManager in your scene for this to work.")]
public class MMF_MMSoundManagerSoundControl : 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.SoundsColor; } }
public override string RequiredTargetText { get { return ControlMode.ToString(); } }
#endif
[MMFInspectorGroup("MMSoundManager Sound Control", true, 30)]
/// the action to trigger on the specified sound
[Tooltip("the action to trigger on the specified sound")]
public MMSoundManagerSoundControlEventTypes ControlMode = MMSoundManagerSoundControlEventTypes.Pause;
/// the ID of the sound, has to match the one you specified when playing it
[Tooltip("the ID of the sound, has to match the one you specified when playing it")]
public int SoundID = 0;
protected AudioSource _targetAudioSource;
/// <summary>
/// On play, triggers an event meant to be caught by the MMSoundManager and acted upon
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMSoundManagerSoundControlEvent.Trigger(ControlMode, SoundID);
}
}
}

View File

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

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
using MoreMountains.Tools;
using UnityEngine.Audio;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you trigger fades on a specific sound via the MMSoundManager. You will need a MMSoundManager in your scene for this to work.
/// </summary>
[AddComponentMenu("")]
[FeedbackPath("Audio/MMSoundManager Sound Fade")]
[FeedbackHelp("This feedback lets you trigger fades on a specific sound via the MMSoundManager. You will need a MMSoundManager in your scene for this to work.")]
public class MMF_MMSoundManagerSoundFade : 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.SoundsColor; } }
public override string RequiredTargetText { get { return "ID "+SoundID; } }
#endif
[MMFInspectorGroup("MMSoundManager Sound Fade", true, 30)]
/// the ID of the sound you want to fade. Has to match the ID you specified when playing the sound initially
[Tooltip("the ID of the sound you want to fade. Has to match the ID you specified when playing the sound initially")]
public int SoundID = 0;
/// the duration of the fade, in seconds
[Tooltip("the duration of the fade, in seconds")]
public float FadeDuration = 1f;
/// the volume towards which to fade
[Tooltip("the volume towards which to fade")]
[Range(MMSoundManagerSettings._minimalVolume,MMSoundManagerSettings._maxVolume)]
public float FinalVolume = MMSoundManagerSettings._minimalVolume;
/// the tween to apply over the fade
[Tooltip("the tween to apply over the fade")]
public MMTweenType FadeTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic);
protected AudioSource _targetAudioSource;
/// <summary>
/// On play, we start our fade via a fade event
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
MMSoundManagerSoundFadeEvent.Trigger(SoundID, FadeDuration, FinalVolume, FadeTween);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 14c18eda2751dd04ba846546118f8d97
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