Added Feel plugin
This commit is contained in:
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks.meta
vendored
Normal file
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f81ac7d016b3bba44b13af28b6f81506
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
127
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Blink.cs
vendored
Normal file
127
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Blink.cs
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("Renderer/MMBlink")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
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; } }
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetBlink = FindAutomatedTarget<MMBlink>();
|
||||
|
||||
/// 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;
|
||||
/// an optional list of extra target objects to blink
|
||||
[Tooltip("an optional list of extra target objects to blink")]
|
||||
public List<MMBlink> ExtraTargetBlinks;
|
||||
/// 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;
|
||||
}
|
||||
HandleBlink(TargetBlink);
|
||||
foreach (MMBlink blink in ExtraTargetBlinks)
|
||||
{
|
||||
HandleBlink(blink);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles, starts or stops blink on the target
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
protected virtual void HandleBlink(MMBlink target)
|
||||
{
|
||||
target.TimescaleMode = ComputedTimescaleMode;
|
||||
switch (BlinkMode)
|
||||
{
|
||||
case BlinkModes.Toggle:
|
||||
target.ToggleBlinking();
|
||||
break;
|
||||
case BlinkModes.Start:
|
||||
target.StartBlinking();
|
||||
break;
|
||||
case BlinkModes.Stop:
|
||||
target.StopBlinking();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On restore, we restore our initial state
|
||||
/// </summary>
|
||||
protected override void CustomRestoreInitialValues()
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TargetBlink.StopBlinking();
|
||||
foreach (MMBlink blink in ExtraTargetBlinks)
|
||||
{
|
||||
blink.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Blink.cs.meta
vendored
Normal file
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Blink.cs.meta
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b3c116d0e316af4f98aea90424ad690
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Blink.cs
|
||||
uploadId: 830868
|
||||
82
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Broadcast.cs
vendored
Normal file
82
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Broadcast.cs
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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, (int)Modes.ToDestination)]
|
||||
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;
|
||||
/// the value to move the intensity to in destination mode
|
||||
[Tooltip("the value to move the intensity to in destination mode")]
|
||||
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
|
||||
public float DestinationValue;
|
||||
|
||||
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;
|
||||
target.ToDestinationLevel = DestinationValue;
|
||||
|
||||
_targets.Add(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f92a3f5abd60c5e41b92ebf0add536a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Broadcast.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,51 @@
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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 virtual 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8117ecb7d1e9e3a49bf38e7ab2c09ff7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_BroadcastProxy.cs
|
||||
uploadId: 830868
|
||||
84
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_CanvasGroup.cs
vendored
Normal file
84
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_CanvasGroup.cs
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
public override bool CanForceInitialValue => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetCanvasGroup = FindAutomatedTarget<CanvasGroup>();
|
||||
|
||||
[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, (int)Modes.ToDestination)]
|
||||
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;
|
||||
/// the value to move the opacity to in destination mode
|
||||
[Tooltip("the value to move the opacity to in destination mode")]
|
||||
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
|
||||
public float DestinationAlpha;
|
||||
|
||||
public override void OnAddFeedback()
|
||||
{
|
||||
base.OnAddFeedback();
|
||||
RelativeValues = false;
|
||||
}
|
||||
|
||||
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;
|
||||
target.ToDestinationLevel = DestinationAlpha;
|
||||
|
||||
_targets.Add(target);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0bcfac83087655f42bcb7a42d7d02f05
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_CanvasGroup.cs
|
||||
uploadId: 830868
|
||||
44
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugBreak.cs
vendored
Normal file
44
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugBreak.cs
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// This feedback will force a break, pausing the editor
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
[FeedbackHelp("This feedback will will force a break, pausing the editor")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("Debug/Break")]
|
||||
public class MMF_DebugBreak : 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 0
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// On Play we break
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Break();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af342e664060d4e42bd5f6a5753d95e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugBreak.cs
|
||||
uploadId: 830868
|
||||
55
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugComment.cs
vendored
Normal file
55
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugComment.cs
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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;
|
||||
}
|
||||
|
||||
MMDebug.DebugLogInfo(Comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e5ef4e0e1b94c54b97bc6387c8009bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugComment.cs
|
||||
uploadId: 830868
|
||||
83
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugLog.cs
vendored
Normal file
83
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugLog.cs
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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 0
|
||||
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 = "YOUR DEBUG MESSAGE GOES HERE";
|
||||
/// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugLog.cs.meta
vendored
Normal file
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugLog.cs.meta
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18d70b42b0fd93e49b47f2970addf779
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_DebugLog.cs
|
||||
uploadId: 830868
|
||||
223
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Fade.cs
vendored
Normal file
223
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Fade.cs
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
#if MM_UI
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
using UnityEngine.UI;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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; } }
|
||||
public override bool HasCustomInspectors => true;
|
||||
public override bool HasAutomaticShakerSetup => true;
|
||||
#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;
|
||||
|
||||
[Header("Optional Target")]
|
||||
/// this field lets you bind a specific MMFader to this feedback. If left empty, the feedback will trigger a MMFadeEvent instead, targeting all matching faders. If you fill it, only that specific fader will be targeted.
|
||||
[Tooltip("this field lets you bind a specific MMFader to this feedback. If left empty, the feedback will trigger a MMFadeEvent instead, targeting all matching faders. If you fill it, only that specific fader will be targeted.")]
|
||||
public MMFader TargetFader;
|
||||
|
||||
/// 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;
|
||||
}
|
||||
}
|
||||
|
||||
if (TargetFader != null)
|
||||
{
|
||||
switch (_fadeType)
|
||||
{
|
||||
case FadeTypes.Custom:
|
||||
TargetFader.Fade(TargetAlpha, FeedbackDuration, Curve, IgnoreTimeScale);
|
||||
break;
|
||||
case FadeTypes.FadeIn:
|
||||
TargetFader.FadeIn(FeedbackDuration, Curve, IgnoreTimeScale);
|
||||
break;
|
||||
case FadeTypes.FadeOut:
|
||||
TargetFader.FadeOut(FeedbackDuration, Curve, IgnoreTimeScale);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Automatically tries to add a MMFader setup to the scene
|
||||
/// </summary>
|
||||
public override void AutomaticShakerSetup()
|
||||
{
|
||||
if (Object.FindAnyObjectByType<MMFader>() != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
(Canvas canvas, bool createdNewCanvas) = Owner.gameObject.MMFindOrCreateObjectOfType<Canvas>("FadeCanvas", null);
|
||||
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
(Image image, bool createdNewImage) = canvas.gameObject.MMFindOrCreateObjectOfType<Image>("FadeImage", canvas.transform, true);
|
||||
image.raycastTarget = false;
|
||||
image.color = Color.black;
|
||||
|
||||
RectTransform rectTransform = image.GetComponent<RectTransform>();
|
||||
rectTransform.anchorMin = new Vector2(0f, 0f);
|
||||
rectTransform.anchorMax = new Vector2(1f, 1f);
|
||||
rectTransform.offsetMin = Vector2.zero;
|
||||
rectTransform.offsetMax = Vector2.zero;
|
||||
|
||||
image.gameObject.AddComponent<MMFader>();
|
||||
image.gameObject.GetComponent<CanvasGroup>().alpha = 0;
|
||||
image.gameObject.GetComponent<CanvasGroup>().interactable = false;
|
||||
|
||||
MMDebug.DebugLogInfo("Added a MMFader to the scene. You're all set.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Fade.cs.meta
vendored
Normal file
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Fade.cs.meta
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dc617b01bf230943a22cac5dec24291
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Fade.cs
|
||||
uploadId: 830868
|
||||
242
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_FloatController.cs
vendored
Normal file
242
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_FloatController.cs
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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;
|
||||
public override bool CanForceInitialValue => true;
|
||||
public override bool ForceInitialValueDelayed => true;
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetFloatController = FindAutomatedTarget<FloatController>();
|
||||
|
||||
[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;
|
||||
/// a list of extra and optional float controllers to trigger a one time play on
|
||||
[Tooltip("a list of extra and optional float controllers to trigger a one time play on")]
|
||||
public List<FloatController> ExtraTargetFloatControllers;
|
||||
/// 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);
|
||||
HandleFloatController(TargetFloatController, intensityMultiplier);
|
||||
foreach (FloatController floatController in ExtraTargetFloatControllers)
|
||||
{
|
||||
HandleFloatController(floatController, intensityMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies values to and triggers the target float controller
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="intensityMultiplier"></param>
|
||||
protected virtual void HandleFloatController(FloatController target, float intensityMultiplier)
|
||||
{
|
||||
target.RevertToInitialValueAfterEnd = RevertToInitialValueAfterEnd;
|
||||
|
||||
if (Mode == Modes.OneTime)
|
||||
{
|
||||
target.OneTimeDuration = FeedbackDuration;
|
||||
target.OneTimeAmplitude = OneTimeAmplitude;
|
||||
target.OneTimeCurve = OneTimeCurve;
|
||||
if (NormalPlayDirection)
|
||||
{
|
||||
target.OneTimeRemapMin = OneTimeRemapMin * intensityMultiplier;
|
||||
target.OneTimeRemapMax = OneTimeRemapMax * intensityMultiplier;
|
||||
}
|
||||
else
|
||||
{
|
||||
target.OneTimeRemapMin = OneTimeRemapMax * intensityMultiplier;
|
||||
target.OneTimeRemapMax = OneTimeRemapMin * intensityMultiplier;
|
||||
}
|
||||
target.OneTime();
|
||||
}
|
||||
if (Mode == Modes.ToDestination)
|
||||
{
|
||||
target.ToDestinationCurve = ToDestinationCurve;
|
||||
target.ToDestinationDuration = FeedbackDuration;
|
||||
target.ToDestinationValue = ToDestinationValue;
|
||||
target.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))
|
||||
{
|
||||
ResetFloatController(TargetFloatController);
|
||||
foreach (FloatController controller in ExtraTargetFloatControllers)
|
||||
{
|
||||
ResetFloatController(controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ResetFloatController(FloatController controller)
|
||||
{
|
||||
controller.OneTimeDuration = _oneTimeDurationStorage;
|
||||
controller.OneTimeAmplitude = _oneTimeAmplitudeStorage;
|
||||
controller.OneTimeCurve = _oneTimeCurveStorage;
|
||||
controller.OneTimeRemapMin = _oneTimeRemapMinStorage;
|
||||
controller.OneTimeRemapMax = _oneTimeRemapMaxStorage;
|
||||
controller.ToDestinationCurve = _toDestinationCurveStorage;
|
||||
controller.ToDestinationDuration = _toDestinationDurationStorage;
|
||||
controller.ToDestinationValue = _toDestinationValueStorage;
|
||||
controller.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();
|
||||
foreach (FloatController controller in ExtraTargetFloatControllers)
|
||||
{
|
||||
controller.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On restore, we restore our initial state
|
||||
/// </summary>
|
||||
protected override void CustomRestoreInitialValues()
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TargetFloatController.RestoreInitialValues();
|
||||
foreach (FloatController controller in ExtraTargetFloatControllers)
|
||||
{
|
||||
controller.RestoreInitialValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35b65ddee73b8544486c63441149886c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_FloatController.cs
|
||||
uploadId: 830868
|
||||
164
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_FloatingText.cs
vendored
Normal file
164
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_FloatingText.cs
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
using MoreMountains.Tools;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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;
|
||||
/// a transform to attach the floating text to for the duration of its lifetime. it will then move relative to it
|
||||
[Tooltip("a transform to attach the floating text to for the duration of its lifetime. it will then move relative to it")]
|
||||
public Transform AttachmentTransform;
|
||||
|
||||
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, AttachmentTransform);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b34371db751e55942bc9b51871b77ca1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_FloatingText.cs
|
||||
uploadId: 830868
|
||||
275
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Fog.cs
vendored
Normal file
275
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Fog.cs
vendored
Normal file
@@ -0,0 +1,275 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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;
|
||||
public override bool HasCustomInspectors => 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;
|
||||
|
||||
protected Color _initialInstantColor;
|
||||
protected float _initialInstantStartDistance;
|
||||
protected float _initialInstantEndDistance;
|
||||
protected float _initialInstantDensity;
|
||||
|
||||
protected override void CustomInitialization(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
|
||||
if (Active)
|
||||
{
|
||||
_initialInstantColor = RenderSettings.fogColor;
|
||||
_initialInstantStartDistance = RenderSettings.fogStartDistance;
|
||||
_initialInstantEndDistance = RenderSettings.fogEndDistance;
|
||||
_initialInstantDensity = RenderSettings.fogDensity;
|
||||
|
||||
if (ColorOverTime == null)
|
||||
{
|
||||
ColorOverTime = new Gradient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 = NormalPlayDirection ? InstantColor : _initialColor;
|
||||
}
|
||||
|
||||
if (ModifyStartDistance)
|
||||
{
|
||||
RenderSettings.fogStartDistance = NormalPlayDirection ? StartDistanceInstantChange : _initialInstantStartDistance;
|
||||
}
|
||||
|
||||
if (ModifyEndDistance)
|
||||
{
|
||||
RenderSettings.fogEndDistance = NormalPlayDirection ? EndDistanceInstantChange : _initialInstantEndDistance;
|
||||
}
|
||||
|
||||
if (ModifyFogDensity)
|
||||
{
|
||||
RenderSettings.fogDensity = NormalPlayDirection ? DensityInstantChange * intensityMultiplier : _initialInstantDensity;
|
||||
}
|
||||
break;
|
||||
case Modes.OverTime:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Fog.cs.meta
vendored
Normal file
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Fog.cs.meta
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab9c4511f66964b488597580ab1b228f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Fog.cs
|
||||
uploadId: 830868
|
||||
251
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_ImageAlpha.cs
vendored
Normal file
251
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_ImageAlpha.cs
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
#if MM_UI
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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;
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
protected override void AutomateTargetAcquisition() => BoundImage = FindAutomatedTarget<Image>();
|
||||
|
||||
/// 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")]
|
||||
public MMTweenType Curve = new MMTweenType(MMTween.MMTweenCurve.EaseInCubic, "", "Mode", (int)Modes.OverTime, (int)Modes.ToDestination);
|
||||
/// 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 = false;
|
||||
|
||||
/// 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;
|
||||
protected float _initialInstantAlpha;
|
||||
|
||||
protected override void CustomInitialization(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
|
||||
if (BoundImage == null)
|
||||
{
|
||||
Debug.LogWarning("[Image Alpha Feedback] The image alpha feedback on "+Owner.name+" doesn't have a bound image, it won't work. You need to specify an image in its inspector.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Active)
|
||||
{
|
||||
_initialInstantAlpha = BoundImage.color.a;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 || (BoundImage == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_initialColor = BoundImage.color;
|
||||
Turn(true);
|
||||
switch (Mode)
|
||||
{
|
||||
case Modes.Instant:
|
||||
_imageColor = BoundImage.color;
|
||||
_imageColor.a = NormalPlayDirection ? InstantAlpha : _initialInstantAlpha;
|
||||
BoundImage.color = _imageColor;
|
||||
break;
|
||||
case Modes.OverTime:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_coroutine = Owner.StartCoroutine(ImageSequence());
|
||||
break;
|
||||
case Modes.ToDestination:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_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);
|
||||
}
|
||||
if (_coroutine != null)
|
||||
{
|
||||
Owner.StopCoroutine(_coroutine);
|
||||
}
|
||||
_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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Validate, we init our curves conditions if needed
|
||||
/// </summary>
|
||||
public override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
if (string.IsNullOrEmpty(Curve.EnumConditionPropertyName))
|
||||
{
|
||||
Curve.EnumConditionPropertyName = "Mode";
|
||||
Curve.EnumConditions = new bool[32];
|
||||
Curve.EnumConditions[(int)Modes.OverTime] = true;
|
||||
Curve.EnumConditions[(int)Modes.ToDestination] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14a47d8bf77ba3943a535dae0d46e99d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_ImageAlpha.cs
|
||||
uploadId: 830868
|
||||
247
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_ImageFill.cs
vendored
Normal file
247
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_ImageFill.cs
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
#if MM_UI
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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;
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
protected override void AutomateTargetAcquisition() => BoundImage = FindAutomatedTarget<Image>();
|
||||
|
||||
/// 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")]
|
||||
public MMTweenType Curve = new MMTweenType(MMTween.MMTweenCurve.EaseInCubic, "", "Mode", (int)Modes.OverTime, (int)Modes.ToDestination);
|
||||
/// 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 = false;
|
||||
|
||||
/// 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 float _initialInstantFill;
|
||||
protected bool _initialState;
|
||||
|
||||
protected override void CustomInitialization(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
|
||||
if (BoundImage == null)
|
||||
{
|
||||
Debug.LogWarning("[Image Fill Feedback] The image fill feedback on "+Owner.name+" doesn't have a bound image, it won't work. You need to specify an image in its inspector.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Active)
|
||||
{
|
||||
_initialInstantFill = BoundImage.fillAmount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 || (BoundImage == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_initialState = BoundImage.gameObject.activeInHierarchy;
|
||||
Turn(true);
|
||||
_initialFill = BoundImage.fillAmount;
|
||||
switch (Mode)
|
||||
{
|
||||
case Modes.Instant:
|
||||
BoundImage.fillAmount = NormalPlayDirection ? InstantFill : _initialInstantFill;
|
||||
break;
|
||||
case Modes.OverTime:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_coroutine = Owner.StartCoroutine(ImageSequence());
|
||||
break;
|
||||
case Modes.ToDestination:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_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);
|
||||
}
|
||||
if (_coroutine != null)
|
||||
{
|
||||
Owner.StopCoroutine(_coroutine);
|
||||
}
|
||||
_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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Validate, we init our curves conditions if needed
|
||||
/// </summary>
|
||||
public override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
if (string.IsNullOrEmpty(Curve.EnumConditionPropertyName))
|
||||
{
|
||||
Curve.EnumConditionPropertyName = "Mode";
|
||||
Curve.EnumConditions = new bool[32];
|
||||
Curve.EnumConditions[(int)Modes.OverTime] = true;
|
||||
Curve.EnumConditions[(int)Modes.ToDestination] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95530134bb5ab7b4a959774f63c2e92f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_ImageFill.cs
|
||||
uploadId: 830868
|
||||
87
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Layer.cs
vendored
Normal file
87
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Layer.cs
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
#if MM_UI
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// This feedback will let you change the layer of a target game object when playing the feedback
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
[FeedbackHelp("This feedback will let you change the layer of a target game object when playing the feedback")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("GameObject/Layer")]
|
||||
public class MMF_Layer : 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.GameObjectColor; } }
|
||||
public override bool EvaluateRequiresSetup() { return (TargetGameObject == null); }
|
||||
public override string RequiredTargetText { get { return TargetGameObject != null ? TargetGameObject.name : ""; } }
|
||||
public override string RequiresSetupText { get { return "This feedback requires that a TargetGameObject be set to be able to work properly. You can set one below."; } }
|
||||
#endif
|
||||
|
||||
/// the duration of this feedback is the duration of the Graphic, or 0 if instant
|
||||
public override float FeedbackDuration { get { return 0f; } }
|
||||
public override bool HasChannel => false;
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetGameObject = FindAutomatedTarget<GameObject>();
|
||||
|
||||
[MMFInspectorGroup("Graphic", true, 54, true)]
|
||||
/// the game object you want to change the layer on
|
||||
[Tooltip("the game object you want to change the layer on")]
|
||||
public GameObject TargetGameObject;
|
||||
/// the new layer to assign to the target game object
|
||||
[Tooltip("the new layer to assign to the target game object")]
|
||||
[MMLayer]
|
||||
public int NewLayer;
|
||||
|
||||
protected int _initialLayer;
|
||||
|
||||
/// <summary>
|
||||
/// On init we store the initial layer
|
||||
/// </summary>
|
||||
/// <param name="owner"></param>
|
||||
protected override void CustomInitialization(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
|
||||
if (Active && TargetGameObject != null)
|
||||
{
|
||||
_initialLayer = TargetGameObject.layer;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Play we change our object's layer to the New Layer
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized || (TargetGameObject == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
TargetGameObject.layer = NewLayer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On restore, we restore our initial layer
|
||||
/// </summary>
|
||||
protected override void CustomRestoreInitialValues()
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TargetGameObject.layer = _initialLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Layer.cs.meta
vendored
Normal file
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Layer.cs.meta
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 688b4ab22ad89b24895a20351c49f7d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Layer.cs
|
||||
uploadId: 830868
|
||||
217
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_LineRenderer.cs
vendored
Normal file
217
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_LineRenderer.cs
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// This feedback will let you change the width and color of a target line renderer over time
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
[FeedbackHelp("This feedback will let you change the width and color of a target line renderer over time")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("Renderer/Line Renderer")]
|
||||
public class MMF_LineRenderer : 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 bool EvaluateRequiresSetup() => (TargetLineRenderer == null);
|
||||
public override string RequiredTargetText => TargetLineRenderer != null ? TargetLineRenderer.name : "";
|
||||
public override string RequiresSetupText => "This feedback requires that a TargetLineRenderer be set to be able to work properly. You can set one below.";
|
||||
#endif
|
||||
public override bool HasRandomness => true;
|
||||
public override bool HasCustomInspectors => true;
|
||||
|
||||
/// the possible modes for this feedback
|
||||
public enum Modes { OverTime, Instant }
|
||||
|
||||
[MMFInspectorGroup("Line Renderer", true, 24, true)]
|
||||
/// the line renderer whose properties you want to modify
|
||||
[Tooltip("the line renderer whose properties you want to modify")]
|
||||
public LineRenderer TargetLineRenderer;
|
||||
/// 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;
|
||||
/// a curve to use to animate the line renderer's density over time
|
||||
[Tooltip("a curve to use to animate the line renderer's density over time")]
|
||||
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
|
||||
public MMTweenType Transition = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
|
||||
|
||||
[MMFInspectorGroup("Width", true, 25)]
|
||||
/// whether or not to modify the line renderer's width
|
||||
[Tooltip("whether or not to modify the line renderer's width")]
|
||||
public bool ModifyWidth = true;
|
||||
/// a curve defining the new width of the line renderer, describing the world space width of the line at each point along its length
|
||||
[Tooltip("a curve defining the new width of the line renderer, describing the world space width of the line at each point along its length")]
|
||||
public AnimationCurve NewWidth = new AnimationCurve(new Keyframe(0, 1), new Keyframe(1, 0));
|
||||
|
||||
[MMFInspectorGroup("Color", true, 28)]
|
||||
/// whether or not to modify the line renderer's color
|
||||
[Tooltip("whether or not to modify the line renderer'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")]
|
||||
public Gradient NewColor = new Gradient();
|
||||
|
||||
/// 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 Gradient _initialColor;
|
||||
protected AnimationCurve _initialWidth;
|
||||
|
||||
protected Gradient _firstColor;
|
||||
protected AnimationCurve _firstWidth;
|
||||
|
||||
protected override void CustomInitialization(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
|
||||
if (Active)
|
||||
{
|
||||
if (TargetLineRenderer == null)
|
||||
{
|
||||
Debug.LogWarning("[Line Renderer Feedback] The line renderer feedback on "+Owner.name+" doesn't have a TargetLineRenderer, it won't work. You need to specify one in its inspector.");
|
||||
return;
|
||||
}
|
||||
|
||||
_firstColor = TargetLineRenderer.colorGradient;
|
||||
_firstWidth = TargetLineRenderer.widthCurve;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Play we change the values of our line renderer
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized || (TargetLineRenderer == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_initialColor = TargetLineRenderer.colorGradient;
|
||||
_initialWidth = TargetLineRenderer.widthCurve;
|
||||
|
||||
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
|
||||
switch (Mode)
|
||||
{
|
||||
case Modes.Instant:
|
||||
if (ModifyColor)
|
||||
{
|
||||
TargetLineRenderer.colorGradient = NormalPlayDirection ? NewColor : _firstColor;
|
||||
}
|
||||
if (ModifyWidth)
|
||||
{
|
||||
TargetLineRenderer.widthCurve = NormalPlayDirection ? NewWidth : _firstWidth;
|
||||
}
|
||||
break;
|
||||
case Modes.OverTime:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_coroutine = Owner.StartCoroutine(LineRendererSequence(intensityMultiplier));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This coroutine will modify the values on the line renderer over time
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual IEnumerator LineRendererSequence(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);
|
||||
remappedTime = Transition.Evaluate(remappedTime);
|
||||
SetLineRendererValues(remappedTime, intensityMultiplier);
|
||||
|
||||
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
SetLineRendererValues(Transition.Evaluate(FinalNormalizedTime), intensityMultiplier);
|
||||
_coroutine = null;
|
||||
IsPlaying = false;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the various values on the line renderer on a specified time (between 0 and 1)
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
protected virtual void SetLineRendererValues(float time, float intensityMultiplier)
|
||||
{
|
||||
if (ModifyColor)
|
||||
{
|
||||
if (NormalPlayDirection)
|
||||
{
|
||||
TargetLineRenderer.colorGradient = MMColors.LerpGradients(_initialColor, NewColor, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetLineRenderer.colorGradient = MMColors.LerpGradients(NewColor, _firstColor, time);
|
||||
}
|
||||
}
|
||||
|
||||
if (ModifyWidth)
|
||||
{
|
||||
if (NormalPlayDirection)
|
||||
{
|
||||
TargetLineRenderer.widthCurve = MMAnimationCurves.LerpAnimationCurves(_initialWidth, NewWidth, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetLineRenderer.widthCurve = MMAnimationCurves.LerpAnimationCurves(NewWidth, _firstWidth, time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
TargetLineRenderer.widthCurve = _firstWidth;
|
||||
TargetLineRenderer.colorGradient = _firstColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9316d13625724948a6824fbd529a617
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_LineRenderer.cs
|
||||
uploadId: 830868
|
||||
155
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_LoadScene.cs
vendored
Normal file
155
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_LoadScene.cs
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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 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;
|
||||
/// the chosen way to unload scenes (none, only the active scene, all loaded scenes)
|
||||
[Tooltip("the chosen way to unload scenes (none, only the active scene, all loaded scenes)")]
|
||||
[MMFEnumCondition("LoadingMode", (int)LoadingModes.MMAdditiveSceneLoadingManager)]
|
||||
public MMAdditiveSceneLoadingManagerSettings.UnloadMethods UnloadMethod =
|
||||
MMAdditiveSceneLoadingManagerSettings.UnloadMethods.AllScenes;
|
||||
/// the name of the anti spill scene to use when loading additively.
|
||||
/// If left empty, that scene will be automatically created, but you can specify any scene to use for that. Usually you'll want your own anti spill scene to be just an empty scene, but you can customize its lighting settings for example.
|
||||
[Tooltip("the name of the anti spill scene to use when loading additively." +
|
||||
"If left empty, that scene will be automatically created, but you can specify any scene to use for that. Usually you'll want your own anti spill scene to be just an empty scene, but you can customize its lighting settings for example.")]
|
||||
[MMFEnumCondition("LoadingMode", (int)LoadingModes.MMAdditiveSceneLoadingManager)]
|
||||
public string AntiSpillSceneName = "";
|
||||
/// in additive mode, whether or not to display debug logs of the loading sequence
|
||||
[Tooltip("in additive mode, whether or not to display debug logs of the loading sequence")]
|
||||
[MMFEnumCondition("LoadingMode", (int)LoadingModes.MMAdditiveSceneLoadingManager)]
|
||||
public bool DebugMode = false;
|
||||
|
||||
[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 scene gets activated
|
||||
[Tooltip("a delay (in seconds) to apply before the scene gets activated")]
|
||||
public float BeforeSceneActivationDelay = 0f;
|
||||
/// a delay applied after the scene is loaded
|
||||
[Tooltip("a delay applied after the scene is loaded")]
|
||||
public float AfterSceneActivationDelay = 0f;
|
||||
/// the duration (in seconds) of the exit fade
|
||||
[Tooltip("the duration (in seconds) of the exit fade")]
|
||||
public float ExitFadeDuration = 0.2f;
|
||||
|
||||
[MMFInspectorGroup("Speed", true, 59)]
|
||||
/// 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;
|
||||
/// 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;
|
||||
/// a list of progress intervals (values should be between 0 and 1) and their associated speeds, letting you have the bar progress less linearly
|
||||
[Tooltip("a list of progress intervals (values should be between 0 and 1) and their associated speeds, letting you have the bar progress less linearly")]
|
||||
public List<MMSceneLoadingSpeedInterval> SpeedIntervals;
|
||||
|
||||
[MMFInspectorGroup("Transitions", true, 59)]
|
||||
/// 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 || (DestinationSceneName == ""))
|
||||
{
|
||||
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,
|
||||
BeforeSceneActivationDelay,
|
||||
AfterSceneActivationDelay,
|
||||
ExitFadeDuration,
|
||||
EntryFadeTween, ExitFadeTween,
|
||||
ProgressInterpolationSpeed, FadeMode, UnloadMethod, AntiSpillSceneName,
|
||||
SpeedIntervals, DebugMode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4f6df1207b1c5e478e225b94a41fa42
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_LoadScene.cs
|
||||
uploadId: 830868
|
||||
53
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMGameEvent.cs
vendored
Normal file
53
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMGameEvent.cs
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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;
|
||||
|
||||
[MMFInspectorGroup("Optional Payload", true, 58, true)]
|
||||
public int IntParameter;
|
||||
public Vector2 Vector2Parameter;
|
||||
public Vector3 Vector3Parameter;
|
||||
public bool BoolParameter;
|
||||
public string StringParameter;
|
||||
|
||||
/// <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, IntParameter, Vector2Parameter, Vector3Parameter, BoolParameter, StringParameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5093ea98124b9ba4f88d699459437e2d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMGameEvent.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Threading.Tasks;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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("")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f641f9c946f40f346b424ed65100be88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMSoundManagerAllSoundsControl.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Threading.Tasks;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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("")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 685b5496a166328449da980c010a79f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMSoundManagerSaveLoad.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,872 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using System.Threading.Tasks;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Object = UnityEngine.Object;
|
||||
using Random = UnityEngine.Random;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
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("")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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 HasCustomInspectors => true;
|
||||
public override bool HasAutomaticShakerSetup => true;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SoundDataSO != null)
|
||||
{
|
||||
requiresSetup = false;
|
||||
}
|
||||
return requiresSetup;
|
||||
}
|
||||
public override string RequiredTargetText { get { return Sfx != null ? Sfx.name + " - ID:" + ID : ""; } }
|
||||
|
||||
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."; } }
|
||||
#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;
|
||||
|
||||
public enum Sources { AudioClip, AudioResource }
|
||||
|
||||
[MMFInspectorGroup("Sound", true, 14, true)]
|
||||
/// whether this feedback should play an audio clip or an AudioResource
|
||||
[Tooltip("whether this feedback should play an audio clip or an AudioResource")]
|
||||
public Sources Source = Sources.AudioClip;
|
||||
/// the sound clip to play
|
||||
[Tooltip("the sound clip to play")]
|
||||
[MMFEnumCondition("Source", (int)Sources.AudioClip)]
|
||||
public AudioClip Sfx;
|
||||
/// alternatively, instead of an audio clip you can specify an AudioResource, in which case the Sfx above will be ignored, and the AudioResource will be used
|
||||
[Tooltip("alternatively, instead of an audio clip you can specify an AudioResource, in which case the Sfx above will be ignored, and the AudioResource will be used")]
|
||||
[MMFEnumCondition("Source", (int)Sources.AudioResource)]
|
||||
public AudioResource AudioResourceToPlay;
|
||||
|
||||
[MMFInspectorGroup("Random Sound", true, 39, 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;
|
||||
/// if this is true, sfx will be picked at random until all have been played. once this happens, the list is shuffled again, and it starts over
|
||||
[Tooltip("if this is true, sfx will be picked at random until all have been played. once this happens, the list is shuffled again, and it starts over")]
|
||||
public bool RandomUnique = false;
|
||||
|
||||
[MMFInspectorGroup("Scriptable Object", true, 14, true)]
|
||||
/// a scriptable object (created via the Create/MoreMountains/Audio/MMF_SoundData menu) to define settings that will override all other settings on this feedback
|
||||
[Tooltip("a scriptable object (created via the Create/MoreMountains/Audio/MMF_SoundData menu) to define settings that will override all other settings on this feedback")]
|
||||
public MMF_MMSoundManagerSoundData SoundDataSO;
|
||||
|
||||
[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;
|
||||
|
||||
[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;
|
||||
/// the maximum amount of instances of this sound allowed to play at once. use -1 for unlimited concurrent plays
|
||||
[Tooltip("the maximum amount of instances of this sound allowed to play at once. use -1 for unlimited concurrent plays")]
|
||||
public int MaximumConcurrentInstances = 3;
|
||||
/// 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 In", 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")]
|
||||
[FormerlySerializedAs("Fade")]
|
||||
public bool FadeIn = false;
|
||||
/// if fading, the volume at which to start the fade
|
||||
[Tooltip("if fading, the volume at which to start the fade")]
|
||||
[MMCondition("FadeIn", true)]
|
||||
[FormerlySerializedAs("FadeInitialVolume")]
|
||||
public float FadeInInitialVolume = 0f;
|
||||
/// if fading, the duration of the fade, in seconds
|
||||
[Tooltip("if fading, the duration of the fade, in seconds")]
|
||||
[MMCondition("FadeIn", true)]
|
||||
[FormerlySerializedAs("FadeDuration")]
|
||||
public float FadeInDuration = 1f;
|
||||
/// if fading, the tween over which to fade the sound
|
||||
[Tooltip("if fading, the tween over which to fade the sound ")]
|
||||
[FormerlySerializedAs("FadeTween")]
|
||||
public MMTweenType FadeInTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic, "FadeIn");
|
||||
|
||||
[MMFInspectorGroup("Fade Out", true, 30)]
|
||||
/// whether or not to fade this sound in when stopping the feedback
|
||||
[Tooltip("whether or not to fade this sound in when stopping the feedback")]
|
||||
public bool FadeOutOnStop = false;
|
||||
/// if fading out, the duration of the fade, in seconds
|
||||
[Tooltip("if fading out, the duration of the fade, in seconds")]
|
||||
[MMCondition("FadeOutOnStop", true)]
|
||||
public float FadeOutDuration = 1f;
|
||||
/// if fading out, the tween over which to fade the sound
|
||||
[Tooltip("if fading out, the tween over which to fade the sound ")]
|
||||
public MMTweenType FadeOutTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic, "FadeOutOnStop");
|
||||
|
||||
[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;
|
||||
/// a Transform this sound can 'attach' to and follow it along as it plays
|
||||
[Tooltip("a Transform this sound can 'attach' to and follow it along as it plays")]
|
||||
public Transform AttachToTransform;
|
||||
|
||||
[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("Time Options", true, 15)]
|
||||
/// a timestamp (in seconds, randomized between the defined min and max) at which the sound will start playing, equivalent to the Audiosource API's Time)
|
||||
[Tooltip("a timestamp (in seconds, randomized between the defined min and max) at which the sound will start playing, equivalent to the Audiosource API's Time)")]
|
||||
[MMVector("Min", "Max")]
|
||||
public Vector2 PlaybackTime = new Vector2(0f, 0f);
|
||||
/// a duration (in seconds, randomized between the defined min and max) for which the sound will play before stopping. Ignored if min and max are zero.
|
||||
[Tooltip("a duration (in seconds, randomized between the defined min and max) for which the sound will play before stopping. Ignored if min and max are zero.")]
|
||||
[MMVector("Min", "Max")]
|
||||
public Vector2 PlaybackDuration = new Vector2(0f, 0f);
|
||||
|
||||
[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;
|
||||
/// whether or not to use a custom curve for custom volume rolloff
|
||||
[Tooltip("whether or not to use a custom curve for custom volume rolloff")]
|
||||
public bool UseCustomRolloffCurve = false;
|
||||
/// the curve to use for custom volume rolloff if UseCustomRolloffCurve is true
|
||||
[Tooltip("the curve to use for custom volume rolloff if UseCustomRolloffCurve is true")]
|
||||
[MMFCondition("UseCustomRolloffCurve", true)]
|
||||
public AnimationCurve CustomRolloffCurve;
|
||||
/// whether or not to use a custom curve for spatial blend
|
||||
[Tooltip("whether or not to use a custom curve for spatial blend")]
|
||||
public bool UseSpatialBlendCurve = false;
|
||||
/// the curve to use for custom spatial blend if UseSpatialBlendCurve is true
|
||||
[Tooltip("the curve to use for custom spatial blend if UseSpatialBlendCurve is true")]
|
||||
[MMFCondition("UseSpatialBlendCurve", true)]
|
||||
public AnimationCurve SpatialBlendCurve;
|
||||
/// whether or not to use a custom curve for reverb zone mix
|
||||
[Tooltip("whether or not to use a custom curve for reverb zone mix")]
|
||||
public bool UseReverbZoneMixCurve = false;
|
||||
/// the curve to use for custom reverb zone mix if UseReverbZoneMixCurve is true
|
||||
[Tooltip("the curve to use for custom reverb zone mix if UseReverbZoneMixCurve is true")]
|
||||
[MMFCondition("UseReverbZoneMixCurve", true)]
|
||||
public AnimationCurve ReverbZoneMixCurve;
|
||||
/// whether or not to use a custom curve for spread
|
||||
[Tooltip("whether or not to use a custom curve for spread")]
|
||||
public bool UseSpreadCurve = false;
|
||||
/// the curve to use for custom spread if UseSpreadCurve is true
|
||||
[Tooltip("the curve to use for custom spread if UseSpreadCurve is true")]
|
||||
[MMFCondition("UseSpreadCurve", true)]
|
||||
public AnimationCurve SpreadCurve;
|
||||
|
||||
[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 float _randomPlaybackDuration;
|
||||
protected int _currentIndex = 0;
|
||||
protected Vector3 _gizmoCenter;
|
||||
protected MMShufflebag<int> _randomUniqueShuffleBag;
|
||||
protected AudioClip _lastPlayedClip;
|
||||
protected Coroutine _isPlayingCoroutine;
|
||||
|
||||
protected override void CustomInitialization(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
HandleSO();
|
||||
|
||||
_lastPlayedClip = null;
|
||||
|
||||
if (RandomSfx == null)
|
||||
{
|
||||
RandomSfx = Array.Empty<AudioClip>();
|
||||
}
|
||||
|
||||
if (RandomUnique)
|
||||
{
|
||||
_randomUniqueShuffleBag = new MMShufflebag<int>(RandomSfx.Length);
|
||||
for (int i = 0; i < RandomSfx.Length; i++)
|
||||
{
|
||||
_randomUniqueShuffleBag.Add(i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the debug buttons
|
||||
/// </summary>
|
||||
public override void InitializeCustomAttributes()
|
||||
{
|
||||
base.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 (RandomSfx.Length > 0)
|
||||
{
|
||||
_randomClip = PickRandomClip();
|
||||
|
||||
if (_randomClip != null)
|
||||
{
|
||||
PlaySound(_randomClip, position, intensityMultiplier);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Sfx != null) || (AudioResourceToPlay != null))
|
||||
{
|
||||
PlaySound(Sfx, position, intensityMultiplier, AudioResourceToPlay);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 (FadeOutOnStop)
|
||||
{
|
||||
Owner.StartCoroutine(FadeOutCo());
|
||||
return;
|
||||
}
|
||||
|
||||
StopSound();
|
||||
}
|
||||
|
||||
protected virtual IEnumerator FadeOutCo()
|
||||
{
|
||||
if (_playedAudioSource == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
MMSoundManager.Instance.FadeSound(_playedAudioSource, FadeOutDuration, _playedAudioSource.volume, 0f, FadeOutTween);
|
||||
yield return MMCoroutine.WaitFor(FadeOutDuration);
|
||||
StopSound();
|
||||
}
|
||||
|
||||
protected virtual void StopSound()
|
||||
{
|
||||
if (StopSoundOnFeedbackStop && (_playedAudioSource != null))
|
||||
{
|
||||
_playedAudioSource.Stop();
|
||||
if (RecycleAudioSource == null)
|
||||
{
|
||||
MMSoundManager.Instance.FreeSound(_playedAudioSource);
|
||||
}
|
||||
if (_isPlayingCoroutine != null)
|
||||
{
|
||||
Owner.StopCoroutine(_isPlayingCoroutine);
|
||||
_isPlayingCoroutine = null;
|
||||
}
|
||||
_playedAudioSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If a scriptable object is specified, we grab its values
|
||||
/// </summary>
|
||||
protected virtual void HandleSO()
|
||||
{
|
||||
if (SoundDataSO == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Sfx = SoundDataSO.Sfx;
|
||||
RandomSfx = SoundDataSO.RandomSfx;
|
||||
SequentialOrder = SoundDataSO.SequentialOrder;
|
||||
SequentialOrderHoldLast = SoundDataSO.SequentialOrderHoldLast;
|
||||
SequentialOrderHoldCooldownDuration = SoundDataSO.SequentialOrderHoldCooldownDuration;
|
||||
RandomUnique = SoundDataSO.RandomUnique;
|
||||
MinVolume = SoundDataSO.MinVolume;
|
||||
MaxVolume = SoundDataSO.MaxVolume;
|
||||
MinPitch = SoundDataSO.MinPitch;
|
||||
MaxPitch = SoundDataSO.MaxPitch;
|
||||
PlaybackTime = SoundDataSO.PlaybackTime;
|
||||
PlaybackDuration = SoundDataSO.PlaybackDuration;
|
||||
MmSoundManagerTrack = SoundDataSO.MmSoundManagerTrack;
|
||||
ID = SoundDataSO.ID;
|
||||
AudioGroup = SoundDataSO.AudioGroup;
|
||||
RecycleAudioSource = SoundDataSO.RecycleAudioSource;
|
||||
Loop = SoundDataSO.Loop;
|
||||
Persistent = SoundDataSO.Persistent;
|
||||
DoNotPlayIfClipAlreadyPlaying = SoundDataSO.DoNotPlayIfClipAlreadyPlaying;
|
||||
MaximumConcurrentInstances = SoundDataSO.MaximumConcurrentInstances;
|
||||
StopSoundOnFeedbackStop = SoundDataSO.StopSoundOnFeedbackStop;
|
||||
FadeIn = SoundDataSO.FadeIn;
|
||||
FadeInInitialVolume = SoundDataSO.FadeInInitialVolume;
|
||||
FadeInDuration = SoundDataSO.FadeInDuration;
|
||||
FadeInTween = SoundDataSO.FadeInTween;
|
||||
FadeOutOnStop = SoundDataSO.FadeOutOnStop;
|
||||
FadeOutDuration = SoundDataSO.FadeOutDuration;
|
||||
FadeOutTween = SoundDataSO.FadeOutTween;
|
||||
SoloSingleTrack = SoundDataSO.SoloSingleTrack;
|
||||
SoloAllTracks = SoundDataSO.SoloAllTracks;
|
||||
AutoUnSoloOnEnd = SoundDataSO.AutoUnSoloOnEnd;
|
||||
PanStereo = SoundDataSO.PanStereo;
|
||||
SpatialBlend = SoundDataSO.SpatialBlend;
|
||||
if (AttachToTransform == null)
|
||||
{
|
||||
AttachToTransform = SoundDataSO.AttachToTransform;
|
||||
}
|
||||
BypassEffects = SoundDataSO.BypassEffects;
|
||||
BypassListenerEffects = SoundDataSO.BypassListenerEffects;
|
||||
BypassReverbZones = SoundDataSO.BypassReverbZones;
|
||||
Priority = SoundDataSO.Priority;
|
||||
ReverbZoneMix = SoundDataSO.ReverbZoneMix;
|
||||
DopplerLevel = SoundDataSO.DopplerLevel;
|
||||
Spread = SoundDataSO.Spread;
|
||||
RolloffMode = SoundDataSO.RolloffMode;
|
||||
MinDistance = SoundDataSO.MinDistance;
|
||||
MaxDistance = SoundDataSO.MaxDistance;
|
||||
UseCustomRolloffCurve = SoundDataSO.UseCustomRolloffCurve;
|
||||
CustomRolloffCurve = SoundDataSO.CustomRolloffCurve;
|
||||
UseSpatialBlendCurve = SoundDataSO.UseSpatialBlendCurve;
|
||||
SpatialBlendCurve = SoundDataSO.SpatialBlendCurve;
|
||||
UseReverbZoneMixCurve = SoundDataSO.UseReverbZoneMixCurve;
|
||||
ReverbZoneMixCurve = SoundDataSO.ReverbZoneMixCurve;
|
||||
UseSpreadCurve = SoundDataSO.UseSpreadCurve;
|
||||
SpreadCurve = SoundDataSO.SpreadCurve;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Randomizes playback time and playback duration
|
||||
/// </summary>
|
||||
public virtual void RandomizeTimes()
|
||||
{
|
||||
_randomPlaybackTime = Random.Range(PlaybackTime.x, PlaybackTime.y);
|
||||
_randomPlaybackDuration = Random.Range(PlaybackDuration.x, PlaybackDuration.y);
|
||||
Owner.ComputeCachedTotalDuration();
|
||||
}
|
||||
|
||||
/// <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, AudioResource audioResource = null)
|
||||
{
|
||||
if (DoNotPlayIfClipAlreadyPlaying)
|
||||
{
|
||||
if ((MMSoundManager.Instance.FindByClip(sfx) != null) && (MMSoundManager.Instance.FindByClip(sfx).isPlaying))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (MaximumConcurrentInstances >= 0)
|
||||
{
|
||||
if (MMSoundManager.Instance.CurrentlyPlayingCount(sfx) >= MaximumConcurrentInstances)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float volume = Random.Range(MinVolume, MaxVolume);
|
||||
|
||||
if (!Timing.ConstantIntensity)
|
||||
{
|
||||
volume = volume * intensity;
|
||||
}
|
||||
|
||||
float pitch = Random.Range(MinPitch, MaxPitch);
|
||||
RandomizeTimes();
|
||||
|
||||
int timeSamples = NormalPlayDirection ? 0 : sfx.samples - 1;
|
||||
|
||||
_options.AudioResourceToPlay = audioResource;
|
||||
_options.MmSoundManagerTrack = MmSoundManagerTrack;
|
||||
_options.Location = position;
|
||||
_options.Loop = Loop;
|
||||
_options.Volume = volume;
|
||||
_options.ID = ID;
|
||||
_options.Fade = FadeIn;
|
||||
_options.FadeInitialVolume = FadeInInitialVolume;
|
||||
_options.FadeDuration = FadeInDuration;
|
||||
_options.FadeTween = FadeInTween;
|
||||
_options.Persistent = Persistent;
|
||||
_options.RecycleAudioSource = RecycleAudioSource;
|
||||
_options.AudioGroup = AudioGroup;
|
||||
_options.Pitch = pitch;
|
||||
_options.PlaybackTime = _randomPlaybackTime;
|
||||
_options.PlaybackDuration = _randomPlaybackDuration;
|
||||
_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.AttachToTransform = AttachToTransform;
|
||||
_options.UseSpreadCurve = UseSpreadCurve;
|
||||
_options.SpreadCurve = SpreadCurve;
|
||||
_options.UseCustomRolloffCurve = UseCustomRolloffCurve;
|
||||
_options.CustomRolloffCurve = CustomRolloffCurve;
|
||||
_options.UseSpatialBlendCurve = UseSpatialBlendCurve;
|
||||
_options.SpatialBlendCurve = SpatialBlendCurve;
|
||||
_options.UseReverbZoneMixCurve = UseReverbZoneMixCurve;
|
||||
_options.ReverbZoneMixCurve = ReverbZoneMixCurve;
|
||||
_options.DoNotAutoRecycleIfNotDonePlaying = true;
|
||||
|
||||
_playedAudioSource = MMSoundManagerSoundPlayEvent.Trigger(sfx, _options);
|
||||
|
||||
_isPlayingCoroutine = Owner.StartCoroutine(IsPlayingCoroutine());
|
||||
|
||||
_lastPlayTimestamp = FeedbackTime;
|
||||
_lastPlayedClip = sfx;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A coroutine used to determine if the sound is still playing or not
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual IEnumerator IsPlayingCoroutine()
|
||||
{
|
||||
if (_playedAudioSource != null)
|
||||
{
|
||||
while (_playedAudioSource.isPlaying)
|
||||
{
|
||||
IsPlaying = true;
|
||||
yield return null;
|
||||
}
|
||||
IsPlaying = false;
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the duration of the sound, or of the longest of the random sounds
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual float GetDuration()
|
||||
{
|
||||
if (SoundDataSO != null)
|
||||
{
|
||||
return ComputeDuration(SoundDataSO.Sfx, SoundDataSO.RandomSfx);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ComputeDuration(Sfx, RandomSfx);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual float ComputeDuration(AudioClip sfx, AudioClip[] randomSfx)
|
||||
{
|
||||
if (sfx != null)
|
||||
{
|
||||
return (_randomPlaybackDuration > 0) ? _randomPlaybackDuration : sfx.length - _randomPlaybackTime;
|
||||
}
|
||||
|
||||
float longest = 0f;
|
||||
if ((randomSfx != null) && (randomSfx.Length > 0))
|
||||
{
|
||||
if (_lastPlayedClip != null)
|
||||
{
|
||||
return _lastPlayedClip.length;
|
||||
}
|
||||
|
||||
foreach (AudioClip clip in randomSfx)
|
||||
{
|
||||
if ((clip != null) && (clip.length > longest))
|
||||
{
|
||||
longest = clip.length;
|
||||
}
|
||||
}
|
||||
|
||||
return (_randomPlaybackDuration > 0) ? _randomPlaybackDuration : longest - _randomPlaybackTime;
|
||||
}
|
||||
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public override void OnDrawGizmosSelectedHandler()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Automatically tries to add a MMSoundManager to the scene if none are present
|
||||
/// </summary>
|
||||
public override void AutomaticShakerSetup()
|
||||
{
|
||||
MMSoundManager soundManager = (MMSoundManager)Object.FindAnyObjectByType(typeof(MMSoundManager));
|
||||
if (soundManager == null)
|
||||
{
|
||||
GameObject soundManagerGo = new GameObject("MMSoundManager");
|
||||
soundManagerGo.AddComponent<MMSoundManager>();
|
||||
MMDebug.DebugLogInfo( "Added a MMSoundManager to the scene. You're all set.");
|
||||
}
|
||||
}
|
||||
|
||||
#region TestMethods
|
||||
|
||||
/// <summary>
|
||||
/// A test method that creates an audiosource, plays it, and destroys itself after play
|
||||
/// </summary>
|
||||
public virtual async void TestPlaySound()
|
||||
{
|
||||
AudioClip tmpAudioClip = null;
|
||||
|
||||
if (Sfx != null)
|
||||
{
|
||||
tmpAudioClip = Sfx;
|
||||
}
|
||||
|
||||
if ((RandomSfx != null) && (RandomSfx.Length > 0))
|
||||
{
|
||||
tmpAudioClip = PickRandomClip();
|
||||
}
|
||||
|
||||
if ((tmpAudioClip == null) && (AudioResourceToPlay == 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);
|
||||
RandomizeTimes();
|
||||
GameObject temporaryAudioHost = new GameObject("EditorTestAS_WillAutoDestroy");
|
||||
SceneManager.MoveGameObjectToScene(temporaryAudioHost.gameObject, Owner.gameObject.scene);
|
||||
temporaryAudioHost.transform.position = Owner.transform.position;
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
temporaryAudioHost.AddComponent<MMForceDestroyInPlayMode>();
|
||||
}
|
||||
_editorAudioSource = temporaryAudioHost.AddComponent<AudioSource>() as AudioSource;
|
||||
PlayAudioSource(_editorAudioSource, tmpAudioClip, volume, pitch, _randomPlaybackTime, _randomPlaybackDuration, AudioResourceToPlay);
|
||||
_lastPlayTimestamp = FeedbackTime;
|
||||
_lastPlayedClip = tmpAudioClip;
|
||||
float length = 0f;
|
||||
if (tmpAudioClip != null)
|
||||
{
|
||||
length = (_randomPlaybackDuration > 0) ? _randomPlaybackDuration : tmpAudioClip.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
length = 10f;
|
||||
}
|
||||
length *= 1000;
|
||||
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, float playbackDuration, AudioResource audioResourceToPlay)
|
||||
{
|
||||
// we set that audio source clip to the one in parameters
|
||||
if (audioResourceToPlay == null)
|
||||
{
|
||||
audioSource.clip = sfx;
|
||||
audioSource.time = time;
|
||||
}
|
||||
else
|
||||
{
|
||||
audioSource.resource = audioResourceToPlay;
|
||||
}
|
||||
// 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)
|
||||
{
|
||||
if (RandomUnique)
|
||||
{
|
||||
newIndex = _randomUniqueShuffleBag.Pick();
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On validate we randomize our times
|
||||
/// </summary>
|
||||
public override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
RandomizeTimes();
|
||||
|
||||
if ((RandomSfx != null) && (RandomSfx.Length > 0))
|
||||
{
|
||||
_randomUniqueShuffleBag = new MMShufflebag<int>(RandomSfx.Length);
|
||||
for (int i = 0; i < RandomSfx.Length; i++)
|
||||
{
|
||||
_randomUniqueShuffleBag.Add(i,1);
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(FadeInTween.ConditionPropertyName))
|
||||
{
|
||||
FadeInTween.ConditionPropertyName = "Fade";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae23e6af7cee13748b98cf83b79d01c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMSoundManagerSound.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Threading.Tasks;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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("")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55d739433fa69b24e9b9e0fc7388da77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMSoundManagerSoundControl.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,465 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.PlayerLoop;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Random = UnityEngine.Random;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// A scriptable object used to store data for MMSoundManager play
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[CreateAssetMenu(menuName = "MoreMountains/Audio/MMF_SoundData")]
|
||||
public class MMF_MMSoundManagerSoundData : ScriptableObject
|
||||
{
|
||||
[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;
|
||||
/// 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;
|
||||
/// if this is true, sfx will be picked at random until all have been played. once this happens, the list is shuffled again, and it starts over
|
||||
[Tooltip("if this is true, sfx will be picked at random until all have been played. once this happens, the list is shuffled again, and it starts over")]
|
||||
public bool RandomUnique = false;
|
||||
|
||||
[Header("Sound Properties")]
|
||||
[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")]
|
||||
/// a timestamp (in seconds, randomized between the defined min and max) at which the sound will start playing, equivalent to the Audiosource API's Time)
|
||||
[Tooltip("a timestamp (in seconds, randomized between the defined min and max) at which the sound will start playing, equivalent to the Audiosource API's Time)")]
|
||||
[MMFVector("Min", "Max")]
|
||||
public Vector2 PlaybackTime = new Vector2(0f, 0f);
|
||||
/// a duration (in seconds, randomized between the defined min and max) for which the sound will play before stopping. Ignored if min and max are zero.
|
||||
[Tooltip("a duration (in seconds, randomized between the defined min and max) for which the sound will play before stopping. Ignored if min and max are zero.")]
|
||||
[MMVector("Min", "Max")]
|
||||
public Vector2 PlaybackDuration = new Vector2(0f, 0f);
|
||||
|
||||
[Header("Sound Manager 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;
|
||||
/// the maximum amount of instances of this sound allowed to play at once. use -1 for unlimited concurrent plays
|
||||
[Tooltip("the maximum amount of instances of this sound allowed to play at once. use -1 for unlimited concurrent plays")]
|
||||
public int MaximumConcurrentInstances = -1;
|
||||
/// 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;
|
||||
|
||||
[Header("Fade In")]
|
||||
/// 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 FadeIn = false;
|
||||
/// if fading, the volume at which to start the fade
|
||||
[Tooltip("if fading, the volume at which to start the fade")]
|
||||
[MMCondition("FadeIn", true)]
|
||||
public float FadeInInitialVolume = 0f;
|
||||
/// if fading, the duration of the fade, in seconds
|
||||
[Tooltip("if fading, the duration of the fade, in seconds")]
|
||||
[MMCondition("FadeIn", true)]
|
||||
public float FadeInDuration = 1f;
|
||||
/// if fading, the tween over which to fade the sound
|
||||
[Tooltip("if fading, the tween over which to fade the sound ")]
|
||||
public MMTweenType FadeInTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic, "FadeIn");
|
||||
|
||||
[Header("Fade Out")]
|
||||
/// whether or not to fade this sound in when stopping the feedback
|
||||
[Tooltip("whether or not to fade this sound in when stopping the feedback")]
|
||||
public bool FadeOutOnStop = false;
|
||||
/// if fading out, the duration of the fade, in seconds
|
||||
[Tooltip("if fading out, the duration of the fade, in seconds")]
|
||||
[MMCondition("FadeOutOnStop", true)]
|
||||
public float FadeOutDuration = 1f;
|
||||
/// if fading out, the tween over which to fade the sound
|
||||
[Tooltip("if fading out, the tween over which to fade the sound ")]
|
||||
public MMTweenType FadeOutTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic, "FadeOutOnStop");
|
||||
|
||||
[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;
|
||||
/// a Transform this sound can 'attach' to and follow it along as it plays - when used on a feedback, will only apply if the feedback's AttachToTransform is empty
|
||||
[Tooltip("a Transform this sound can 'attach' to and follow it along as it plays - when used on a feedback, will only apply if the feedback's AttachToTransform is empty")]
|
||||
public Transform AttachToTransform;
|
||||
|
||||
[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;
|
||||
/// whether or not to use a custom curve for custom volume rolloff
|
||||
[Tooltip("whether or not to use a custom curve for custom volume rolloff")]
|
||||
public bool UseCustomRolloffCurve = false;
|
||||
/// the curve to use for custom volume rolloff if UseCustomRolloffCurve is true
|
||||
[Tooltip("the curve to use for custom volume rolloff if UseCustomRolloffCurve is true")]
|
||||
[MMCondition("UseCustomRolloffCurve", true)]
|
||||
public AnimationCurve CustomRolloffCurve;
|
||||
/// whether or not to use a custom curve for spatial blend
|
||||
[Tooltip("whether or not to use a custom curve for spatial blend")]
|
||||
public bool UseSpatialBlendCurve = false;
|
||||
/// the curve to use for custom spatial blend if UseSpatialBlendCurve is true
|
||||
[Tooltip("the curve to use for custom spatial blend if UseSpatialBlendCurve is true")]
|
||||
[MMCondition("UseSpatialBlendCurve", true)]
|
||||
public AnimationCurve SpatialBlendCurve;
|
||||
/// whether or not to use a custom curve for reverb zone mix
|
||||
[Tooltip("whether or not to use a custom curve for reverb zone mix")]
|
||||
public bool UseReverbZoneMixCurve = false;
|
||||
/// the curve to use for custom reverb zone mix if UseReverbZoneMixCurve is true
|
||||
[Tooltip("the curve to use for custom reverb zone mix if UseReverbZoneMixCurve is true")]
|
||||
[MMCondition("UseReverbZoneMixCurve", true)]
|
||||
public AnimationCurve ReverbZoneMixCurve;
|
||||
/// whether or not to use a custom curve for spread
|
||||
[Tooltip("whether or not to use a custom curve for spread")]
|
||||
public bool UseSpreadCurve = false;
|
||||
/// the curve to use for custom spread if UseSpreadCurve is true
|
||||
[Tooltip("the curve to use for custom spread if UseSpreadCurve is true")]
|
||||
[MMCondition("UseSpreadCurve", true)]
|
||||
public AnimationCurve SpreadCurve;
|
||||
|
||||
[MMInspectorButton("TestPlaySound")]
|
||||
public bool TestPlaySoundButton;
|
||||
|
||||
protected AudioClip _randomClip;
|
||||
protected MMShufflebag<int> _randomUniqueShuffleBag;
|
||||
protected int _currentIndex;
|
||||
protected float _randomPlaybackTime;
|
||||
protected float _randomPlaybackDuration;
|
||||
protected MMSoundManagerPlayOptions _options;
|
||||
protected AudioSource _playedAudioSource;
|
||||
protected AudioClip _lastPlayedClip;
|
||||
protected bool _initialized = false;
|
||||
protected AudioSource _editorAudioSource;
|
||||
protected float _lastPlayTimestamp = -float.MaxValue;
|
||||
|
||||
protected virtual void Initialization()
|
||||
{
|
||||
_lastPlayedClip = null;
|
||||
|
||||
if (RandomSfx == null)
|
||||
{
|
||||
RandomSfx = Array.Empty<AudioClip>();
|
||||
}
|
||||
|
||||
if (RandomUnique)
|
||||
{
|
||||
_randomUniqueShuffleBag = new MMShufflebag<int>(RandomSfx.Length);
|
||||
for (int i = 0; i < RandomSfx.Length; i++)
|
||||
{
|
||||
_randomUniqueShuffleBag.Add(i,1);
|
||||
}
|
||||
}
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public virtual void Play(Vector3 position)
|
||||
{
|
||||
if (!_initialized || (RandomUnique && _randomUniqueShuffleBag == null))
|
||||
{
|
||||
Initialization();
|
||||
}
|
||||
|
||||
if (RandomSfx.Length > 0)
|
||||
{
|
||||
_randomClip = PickRandomClip();
|
||||
|
||||
if (_randomClip != null)
|
||||
{
|
||||
PlaySound(_randomClip, position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Sfx != null))
|
||||
{
|
||||
PlaySound(Sfx, position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual AudioSource PlaySound(AudioClip sfx, Vector3 position)
|
||||
{
|
||||
if (DoNotPlayIfClipAlreadyPlaying)
|
||||
{
|
||||
if ((MMSoundManager.Instance.FindByClip(sfx) != null) && (MMSoundManager.Instance.FindByClip(sfx).isPlaying))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (MaximumConcurrentInstances >= 0)
|
||||
{
|
||||
if (MMSoundManager.Instance.CurrentlyPlayingCount(sfx) >= MaximumConcurrentInstances)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
_lastPlayedClip = null;
|
||||
|
||||
float volume = Random.Range(MinVolume, MaxVolume);
|
||||
|
||||
float pitch = Random.Range(MinPitch, MaxPitch);
|
||||
RandomizeTimes();
|
||||
|
||||
_options.MmSoundManagerTrack = MmSoundManagerTrack;
|
||||
_options.Location = position;
|
||||
_options.Loop = Loop;
|
||||
_options.Volume = volume;
|
||||
_options.ID = ID;
|
||||
_options.Fade = FadeIn;
|
||||
_options.FadeInitialVolume = FadeInInitialVolume;
|
||||
_options.FadeDuration = FadeInDuration;
|
||||
_options.FadeTween = FadeInTween;
|
||||
_options.Persistent = Persistent;
|
||||
_options.RecycleAudioSource = RecycleAudioSource;
|
||||
_options.AudioGroup = AudioGroup;
|
||||
_options.Pitch = pitch;
|
||||
_options.PlaybackTime = _randomPlaybackTime;
|
||||
_options.PlaybackDuration = _randomPlaybackDuration;
|
||||
_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.AttachToTransform = AttachToTransform;
|
||||
_options.UseSpreadCurve = UseSpreadCurve;
|
||||
_options.SpreadCurve = SpreadCurve;
|
||||
_options.UseCustomRolloffCurve = UseCustomRolloffCurve;
|
||||
_options.CustomRolloffCurve = CustomRolloffCurve;
|
||||
_options.UseSpatialBlendCurve = UseSpatialBlendCurve;
|
||||
_options.SpatialBlendCurve = SpatialBlendCurve;
|
||||
_options.UseReverbZoneMixCurve = UseReverbZoneMixCurve;
|
||||
_options.ReverbZoneMixCurve = ReverbZoneMixCurve;
|
||||
_options.DoNotAutoRecycleIfNotDonePlaying = true;
|
||||
|
||||
_playedAudioSource = MMSoundManagerSoundPlayEvent.Trigger(sfx, _options);
|
||||
_lastPlayedClip = sfx;
|
||||
|
||||
return _playedAudioSource;
|
||||
}
|
||||
|
||||
public virtual void RandomizeTimes()
|
||||
{
|
||||
_randomPlaybackTime = Random.Range(PlaybackTime.x, PlaybackTime.y);
|
||||
_randomPlaybackDuration = Random.Range(PlaybackDuration.x, PlaybackDuration.y);
|
||||
}
|
||||
|
||||
protected virtual AudioClip PickRandomClip()
|
||||
{
|
||||
int newIndex = 0;
|
||||
|
||||
if (!SequentialOrder)
|
||||
{
|
||||
if (RandomUnique)
|
||||
{
|
||||
newIndex = _randomUniqueShuffleBag.Pick();
|
||||
}
|
||||
else
|
||||
{
|
||||
newIndex = Random.Range(0, RandomSfx.Length);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newIndex = _currentIndex;
|
||||
|
||||
if (newIndex >= RandomSfx.Length)
|
||||
{
|
||||
if (SequentialOrderHoldLast)
|
||||
{
|
||||
newIndex--;
|
||||
if (SequentialOrderHoldCooldownDuration > 0)
|
||||
{
|
||||
newIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newIndex = 0;
|
||||
}
|
||||
}
|
||||
_currentIndex = newIndex + 1;
|
||||
}
|
||||
return RandomSfx[newIndex];
|
||||
}
|
||||
|
||||
public virtual async void TestPlaySound()
|
||||
{
|
||||
if (!_initialized || (RandomUnique && _randomUniqueShuffleBag == null))
|
||||
{
|
||||
Initialization();
|
||||
}
|
||||
|
||||
AudioClip tmpAudioClip = null;
|
||||
|
||||
if (Sfx != null)
|
||||
{
|
||||
tmpAudioClip = Sfx;
|
||||
}
|
||||
|
||||
if ((RandomSfx != null) && (RandomSfx.Length > 0))
|
||||
{
|
||||
tmpAudioClip = PickRandomClip();
|
||||
}
|
||||
|
||||
if (tmpAudioClip == null)
|
||||
{
|
||||
Debug.LogError("This SoundData 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);
|
||||
RandomizeTimes();
|
||||
GameObject temporaryAudioHost = new GameObject("EditorTestAS_WillAutoDestroy");
|
||||
SceneManager.MoveGameObjectToScene(temporaryAudioHost.gameObject, SceneManager.GetActiveScene());
|
||||
temporaryAudioHost.transform.position = Vector3.zero;
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
temporaryAudioHost.AddComponent<MMForceDestroyInPlayMode>();
|
||||
}
|
||||
_editorAudioSource = temporaryAudioHost.AddComponent<AudioSource>() as AudioSource;
|
||||
PlayAudioSource(_editorAudioSource, tmpAudioClip, volume, pitch, _randomPlaybackTime, _randomPlaybackDuration);
|
||||
_lastPlayTimestamp = Time.time;
|
||||
_lastPlayedClip = tmpAudioClip;
|
||||
float length = 0f;
|
||||
if (tmpAudioClip != null)
|
||||
{
|
||||
length = (_randomPlaybackDuration > 0) ? _randomPlaybackDuration : tmpAudioClip.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
length = 10f;
|
||||
}
|
||||
length *= 1000;
|
||||
length = length / Mathf.Abs(pitch);
|
||||
await Task.Delay((int)length);
|
||||
Object.DestroyImmediate(temporaryAudioHost);
|
||||
}
|
||||
|
||||
protected virtual void PlayAudioSource(AudioSource audioSource, AudioClip sfx, float volume, float pitch, float time, float playbackDuration)
|
||||
{
|
||||
audioSource.clip = sfx;
|
||||
audioSource.time = time;
|
||||
audioSource.volume = volume;
|
||||
audioSource.pitch = pitch;
|
||||
audioSource.loop = false;
|
||||
audioSource.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93cb35ed4e3a7554cbb5cdc5e2bdfd4d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMSoundManagerSoundData.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Threading.Tasks;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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("")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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(MMSoundManagerSoundFadeEvent.Modes.PlayFade, SoundID, FadeDuration, FinalVolume, FadeTween);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On stop, we stop our fade via a fade event
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MMSoundManagerSoundFadeEvent.Trigger(MMSoundManagerSoundFadeEvent.Modes.StopFade, SoundID, FadeDuration, FinalVolume, FadeTween);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14c18eda2751dd04ba846546118f8d97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMSoundManagerSoundFade.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Threading.Tasks;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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("")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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 MMF_MMSoundManagerTrackControl : 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 Track.ToString() + " " + ControlMode.ToString(); } }
|
||||
#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 }
|
||||
|
||||
[MMFInspectorGroup("MMSoundManager Track Control", true, 30)]
|
||||
/// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5c2406e2726fb2418de78aecddaefbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMSoundManagerTrackControl.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Threading.Tasks;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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("")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[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 MMF_MMSoundManagerTrackFade : 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 Track.ToString(); } }
|
||||
#endif
|
||||
|
||||
/// the duration of this feedback is the duration of the fade
|
||||
public override float FeedbackDuration { get { return FadeDuration; } }
|
||||
|
||||
[MMFInspectorGroup("MMSoundManager Track Fade", true, 30)]
|
||||
/// 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(MMSoundManagerTrackFadeEvent.Modes.PlayFade, Track, FadeDuration, FinalVolume, FadeTween);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On stop, we stop our fade via a fade event
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MMSoundManagerTrackFadeEvent.Trigger(MMSoundManagerTrackFadeEvent.Modes.StopFade, Track, FadeDuration, FinalVolume, FadeTween);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 266e8e08f7762ff488684f17ba9da511
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_MMSoundManagerTrackFade.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,96 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("PostProcess/PPMovingFilter")]
|
||||
public class MMF_PPMovingFilter : MMF_Feedback
|
||||
{
|
||||
/// a static bool used to disable all feedbacks of this type at once
|
||||
public static bool FeedbackTypeAuthorized = true;
|
||||
|
||||
/// sets the inspector color for this feedback
|
||||
#if UNITY_EDITOR
|
||||
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
|
||||
public override string RequiredTargetText => RequiredChannelText;
|
||||
#endif
|
||||
|
||||
/// the duration of this feedback is the duration of the transition
|
||||
public override float FeedbackDuration { get { return ApplyTimeMultiplier(TransitionDuration); } set { TransitionDuration = value; } }
|
||||
public override bool HasChannel => true;
|
||||
|
||||
/// the possible modes for this feedback
|
||||
public enum Modes { Toggle, On, Off }
|
||||
|
||||
[MMFInspectorGroup("PostProcessing Profile Moving Filter", true, 54)]
|
||||
/// the selected mode for this feedback
|
||||
[Tooltip("the selected mode for this feedback")]
|
||||
public Modes Mode = Modes.Toggle;
|
||||
/// 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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On restore, we put our object back at its initial position
|
||||
/// </summary>
|
||||
protected override void CustomRestoreInitialValues()
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MMPostProcessingMovingFilterEvent.Trigger(Curve, _active, _toggle, FeedbackDuration, restore:true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bad88d19339cd824eae939fb6492e1db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_PPMovingFilter.cs
|
||||
uploadId: 830868
|
||||
102
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Playlist.cs
vendored
Normal file
102
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Playlist.cs
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// This feedback will let you pilot a MMPlaylist
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
[FeedbackHelp("This feedback will let you pilot a MMPlaylist")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("Audio/MMPlaylist")]
|
||||
public class MMF_Playlist : 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 => Mode.ToString(); }
|
||||
public override bool HasChannel => true;
|
||||
#endif
|
||||
|
||||
public enum Modes { Play, PlayNext, PlayPrevious, Stop, Pause, PlaySongAt, SetVolumeMultiplier, ChangePlaylist }
|
||||
|
||||
[MMFInspectorGroup("MMPlaylist", true, 13)]
|
||||
/// 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;
|
||||
/// the volume multiplier to apply
|
||||
[Tooltip("the volume multiplier to apply")]
|
||||
[MMEnumCondition("Mode", (int)Modes.SetVolumeMultiplier)]
|
||||
public float VolumeMultiplier = 1f;
|
||||
/// whether to apply the volume multiplier instantly (true) or only when the next song starts playing (false)
|
||||
[Tooltip("whether to apply the volume multiplier instantly (true) or only when the next song starts playing (false)")]
|
||||
[MMEnumCondition("Mode", (int)Modes.SetVolumeMultiplier)]
|
||||
public bool ApplyVolumeMultiplierInstantly = false;
|
||||
/// in change playlist mode, the playlist to which to switch to. Only works with MMSMPlaylistManager
|
||||
[Tooltip("in change playlist mode, the playlist to which to switch to. Only works with MMSMPlaylistManager")]
|
||||
[MMEnumCondition("Mode", (int)Modes.ChangePlaylist)]
|
||||
public MMSMPlaylist NewPlaylist;
|
||||
/// in change playlist mode, whether or not to play the new playlist after the switch. Only works with MMSMPlaylistManager
|
||||
[Tooltip("in change playlist mode, whether or not to play the new playlist after the switch. Only works with MMSMPlaylistManager")]
|
||||
[MMEnumCondition("Mode", (int)Modes.ChangePlaylist)]
|
||||
public bool ChangePlaylistAndPlay = true;
|
||||
|
||||
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;
|
||||
case Modes.SetVolumeMultiplier:
|
||||
MMPlaylistVolumeMultiplierEvent.Trigger(Channel, VolumeMultiplier, ApplyVolumeMultiplierInstantly);
|
||||
break;
|
||||
case Modes.ChangePlaylist:
|
||||
MMPlaylistChangeEvent.Trigger(Channel, NewPlaylist, ChangePlaylistAndPlay);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Playlist.cs.meta
vendored
Normal file
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Playlist.cs.meta
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd1ba6e99150bc54788ab1cadf6a8f09
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Playlist.cs
|
||||
uploadId: 830868
|
||||
316
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Property.cs
vendored
Normal file
316
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Property.cs
vendored
Normal file
@@ -0,0 +1,316 @@
|
||||
using MoreMountains.Tools;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("GameObject/Property")]
|
||||
public class MMF_Property : 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 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; } }
|
||||
public override bool EvaluateRequiresSetup() { return (Target == null); }
|
||||
public override string RequiredTargetText { get { return Target != null ? Target.TargetObject.name+" - "+Target.TargetPropertyName : ""; } }
|
||||
public override string RequiresSetupText { get { return "This feedback requires that a Target be set to be able to work properly. You can set one below."; } }
|
||||
#endif
|
||||
public override bool HasRandomness => true;
|
||||
public override bool CanForceInitialValue => true;
|
||||
public override bool ForceInitialValueDelayed => true;
|
||||
public override bool HasCustomInspectors => true;
|
||||
|
||||
/// the possible modes for this feedback
|
||||
public enum Modes { OverTime, Instant, ToDestination }
|
||||
|
||||
[MMFInspectorGroup("Target Property", true, 12)]
|
||||
/// the receiver to write the level to
|
||||
[Tooltip("the receiver to write the level to")]
|
||||
public MMPropertyReceiver Target;
|
||||
|
||||
[MMFInspectorGroup("Mode", true, 29)]
|
||||
/// 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, (int)Modes.ToDestination)]
|
||||
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;
|
||||
/// if this is true, initial value will be computed for every play, otherwise only once, on initialization
|
||||
[Tooltip("if this is true, initial value will be computed for every play, otherwise only once, on initialization")]
|
||||
public bool DetermineInitialValueOnPlay = false;
|
||||
|
||||
[MMFInspectorGroup("Level", true, 30)]
|
||||
/// the curve to tween the intensity on
|
||||
[Tooltip("the curve to tween the intensity on")]
|
||||
public MMTweenType LevelCurve = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)), "", "Mode", (int)Modes.OverTime, (int)Modes.ToDestination);
|
||||
/// 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;
|
||||
/// the value towards which to animate when in ToDestination mode
|
||||
[Tooltip("the value towards which to animate when in ToDestination mode")]
|
||||
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
|
||||
public float ToDestinationLevel = 5f;
|
||||
|
||||
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(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
|
||||
if (Target == null)
|
||||
{
|
||||
Debug.LogWarning("[Property Feedback] The property feedback on "+Owner.name+" doesn't have a Target, it won't work. You need to specify one in its inspector.");
|
||||
return;
|
||||
}
|
||||
|
||||
Target.Initialization(Owner.gameObject);
|
||||
GetInitialIntensity();
|
||||
|
||||
if (Active)
|
||||
{
|
||||
if (StartsOff)
|
||||
{
|
||||
Turn(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores the current level of the target
|
||||
/// </summary>
|
||||
protected virtual void GetInitialIntensity()
|
||||
{
|
||||
_initialIntensity = Target.GetLevel();
|
||||
}
|
||||
|
||||
/// <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 || !FeedbackTypeAuthorized || (Target == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (DetermineInitialValueOnPlay)
|
||||
{
|
||||
GetInitialIntensity();
|
||||
}
|
||||
|
||||
Turn(true);
|
||||
|
||||
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
case Modes.Instant:
|
||||
float newLevel = NormalPlayDirection ? InstantLevel : _initialIntensity;
|
||||
Target.SetLevel(newLevel);
|
||||
break;
|
||||
case Modes.OverTime:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_coroutine = Owner.StartCoroutine(UpdateValueSequence(intensityMultiplier));
|
||||
break;
|
||||
case Modes.ToDestination:
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_coroutine = Owner.StartCoroutine(ToDestinationSequence(intensityMultiplier));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This coroutine will animate the target property's value towards the defined ToDestinationLevel.
|
||||
/// Note that in RelativeValue mode, this ToDestinationLevel will be added to the initial value
|
||||
/// </summary>
|
||||
/// <param name="intensityMultiplier"></param>
|
||||
protected virtual IEnumerator ToDestinationSequence(float intensityMultiplier)
|
||||
{
|
||||
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
|
||||
float initialValue = Target.GetLevel();
|
||||
float destinationValue = ToDestinationLevel;
|
||||
|
||||
if (RelativeValues)
|
||||
{
|
||||
destinationValue += _initialIntensity;
|
||||
}
|
||||
|
||||
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
|
||||
{
|
||||
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
|
||||
|
||||
SetValues(remappedTime, intensityMultiplier, initialValue, destinationValue, false);
|
||||
|
||||
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
|
||||
yield return null;
|
||||
}
|
||||
SetValues(FinalNormalizedTime, intensityMultiplier, initialValue, destinationValue, false);
|
||||
if (StartsOff)
|
||||
{
|
||||
Turn(false);
|
||||
}
|
||||
|
||||
_coroutine = null;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
/// <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, RemapLevelZero, RemapLevelOne, true);
|
||||
|
||||
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
|
||||
yield return null;
|
||||
}
|
||||
SetValues(FinalNormalizedTime, intensityMultiplier, RemapLevelZero, RemapLevelOne, true);
|
||||
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 remapZero, float remapOne, bool applyRelative)
|
||||
{
|
||||
float intensity = MMTween.Tween(time, 0f, 1f, remapZero, remapOne, LevelCurve);
|
||||
|
||||
intensity *= intensityMultiplier;
|
||||
|
||||
if (applyRelative && 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)
|
||||
{
|
||||
Owner.StopCoroutine(_coroutine);
|
||||
_coroutine = null;
|
||||
Target.SetLevel(_initialIntensity);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On restore, we put our object back at its initial position
|
||||
/// </summary>
|
||||
protected override void CustomRestoreInitialValues()
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (StartsOff)
|
||||
{
|
||||
Turn(false);
|
||||
}
|
||||
|
||||
Target.SetLevel(_initialIntensity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Validate, we init our curves conditions if needed
|
||||
/// </summary>
|
||||
public override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
if (string.IsNullOrEmpty(LevelCurve.EnumConditionPropertyName))
|
||||
{
|
||||
LevelCurve.EnumConditionPropertyName = "Mode";
|
||||
LevelCurve.EnumConditions = new bool[32];
|
||||
LevelCurve.EnumConditions[(int)Modes.OverTime] = true;
|
||||
LevelCurve.EnumConditions[(int)Modes.ToDestination] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Property.cs.meta
vendored
Normal file
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Property.cs.meta
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b567abd7b952dc748b9dd6b139e37bbf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Property.cs
|
||||
uploadId: 830868
|
||||
105
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_RadioSignal.cs
vendored
Normal file
105
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_RadioSignal.cs
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("GameObject/MMRadioSignal")]
|
||||
public class MMF_RadioSignal : MMF_Feedback
|
||||
{
|
||||
/// a static bool used to disable all feedbacks of this type at once
|
||||
public static bool FeedbackTypeAuthorized = true;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.GameObjectColor; } }
|
||||
public override bool EvaluateRequiresSetup() { return (TargetSignal == null); }
|
||||
public override string RequiredTargetText { get { return TargetSignal != null ? TargetSignal.name : ""; } }
|
||||
public override string RequiresSetupText { get { return "This feedback requires that a TargetSignal be set to be able to work properly. You can set one below."; } }
|
||||
#endif
|
||||
|
||||
/// the duration of this feedback is 0
|
||||
public override float FeedbackDuration { get { return 0f; } }
|
||||
public override bool HasRandomness => true;
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetSignal = FindAutomatedTarget<MMRadioSignal>();
|
||||
|
||||
[MMFInspectorGroup("Radio Signal", true, 72)]
|
||||
/// 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;
|
||||
|
||||
|
||||
/// <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 = ComputeIntensity(feedbacksIntensity, position);
|
||||
|
||||
TargetSignal.Duration = Duration;
|
||||
TargetSignal.GlobalMultiplier = GlobalMultiplier * intensityMultiplier;
|
||||
TargetSignal.TimeScale = TimeScale;
|
||||
TargetSignal.StartShaking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Stop, stops the target signal
|
||||
/// </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 (TargetSignal != null)
|
||||
{
|
||||
TargetSignal.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On restore, we put our object back at its initial position
|
||||
/// </summary>
|
||||
protected override void CustomRestoreInitialValues()
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (TargetSignal != null)
|
||||
{
|
||||
TargetSignal.Stop();
|
||||
TargetSignal.ApplyLevel(0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d01c21882f8c03844831b4d587f470b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_RadioSignal.cs
|
||||
uploadId: 830868
|
||||
78
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_RandomEvents.cs
vendored
Normal file
78
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_RandomEvents.cs
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
[System.Serializable]
|
||||
public class WeightedEvent
|
||||
{
|
||||
public int Weight;
|
||||
public UnityEvent Event;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This feedback allows you to play a random Unity Event, out of a weighted list. To use it, add items to its WeightedEvents list. For each of them, you'll need to specify a weight (the higher the weight, the more likely it'll be picked) and the event to trigger. For an event in that list to have a chance to be picked, the weights can't be zero.
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
[FeedbackHelp("This feedback allows you to play a random Unity Event, out of a weighted list. To use it, add items to its WeightedEvents list. For each of them, you'll need to specify a weight (the higher the weight, the more likely it'll be picked) and the event to trigger. For an event in that list to have a chance to be picked, the weights can't be zero.")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("Events/Random Unity Events")]
|
||||
public class MMF_RandomEvents : 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; } }
|
||||
#endif
|
||||
|
||||
[MMFInspectorGroup("Events", true, 44)]
|
||||
/// the list of events from which to pick
|
||||
[Tooltip("the list of events from which to pick")]
|
||||
public List<WeightedEvent> WeightedEvents;
|
||||
|
||||
protected MMShufflebag<int> _weightShuffleBag;
|
||||
|
||||
/// <summary>
|
||||
/// On init, triggers the init events
|
||||
/// </summary>
|
||||
/// <param name="owner"></param>
|
||||
protected override void CustomInitialization(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
if ((WeightedEvents == null) || (WeightedEvents.Count == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_weightShuffleBag = new MMShufflebag<int>(WeightedEvents.Count);
|
||||
for (var index = 0; index < WeightedEvents.Count; index++)
|
||||
{
|
||||
_weightShuffleBag.Add(index, WeightedEvents[index].Weight);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Play, triggers the play events
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((WeightedEvents == null) || (WeightedEvents.Count == 0) || (_weightShuffleBag == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int newIndex = _weightShuffleBag.Pick();
|
||||
WeightedEvents[newIndex].Event.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f1a7efd09d5b3647afbef7890b18017
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_RandomEvents.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,109 @@
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("UI/RectTransform Anchor")]
|
||||
public class MMF_RectTransformAnchor : 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 (TargetRectTransform == null); }
|
||||
public override string RequiredTargetText { get { return TargetRectTransform != null ? TargetRectTransform.name : ""; } }
|
||||
public override string RequiresSetupText { get { return "This feedback requires that a TargetRectTransform be set to be able to work properly. You can set one below."; } }
|
||||
#endif
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
public override bool CanForceInitialValue => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetRectTransform = FindAutomatedTarget<RectTransform>();
|
||||
|
||||
[MMFInspectorGroup("Target RectTransform", true, 37, true)]
|
||||
/// the target RectTransform to control
|
||||
[Tooltip("the target RectTransform to control")]
|
||||
public RectTransform TargetRectTransform;
|
||||
|
||||
[MMFInspectorGroup("Anchor Min", true, 43)]
|
||||
/// 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;
|
||||
|
||||
[MMFInspectorGroup("Anchor Max", true, 44)]
|
||||
/// 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;
|
||||
}
|
||||
|
||||
MMF_FeedbackBaseTarget targetMin = new MMF_FeedbackBaseTarget();
|
||||
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);
|
||||
|
||||
MMF_FeedbackBaseTarget targetMax = new MMF_FeedbackBaseTarget();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40c1cb23e17feb24ca503ff4d7cbf7b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_RectTransformAnchor.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,109 @@
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("UI/RectTransform Offset")]
|
||||
public class MMF_RectTransformOffset : 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 (TargetRectTransform == null); }
|
||||
public override string RequiredTargetText { get { return TargetRectTransform != null ? TargetRectTransform.name : ""; } }
|
||||
public override string RequiresSetupText { get { return "This feedback requires that a TargetRectTransform be set to be able to work properly. You can set one below."; } }
|
||||
#endif
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
public override bool CanForceInitialValue => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetRectTransform = FindAutomatedTarget<RectTransform>();
|
||||
|
||||
[MMFInspectorGroup("Target RectTransform", true, 37, true)]
|
||||
/// The RectTransform we want to modify
|
||||
public RectTransform TargetRectTransform;
|
||||
|
||||
[MMFInspectorGroup("Offset Min", true, 40)]
|
||||
/// 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;
|
||||
|
||||
[MMFInspectorGroup("Offset Max", true, 41)]
|
||||
/// 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;
|
||||
}
|
||||
|
||||
MMF_FeedbackBaseTarget targetMin = new MMF_FeedbackBaseTarget();
|
||||
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);
|
||||
|
||||
MMF_FeedbackBaseTarget targetMax = new MMF_FeedbackBaseTarget();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d18225582eee064fa0fefcd74282b2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_RectTransformOffset.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,73 @@
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("UI/RectTransform Pivot")]
|
||||
public class MMF_RectTransformPivot : 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 (TargetRectTransform == null); }
|
||||
public override string RequiredTargetText { get { return TargetRectTransform != null ? TargetRectTransform.name : ""; } }
|
||||
public override string RequiresSetupText { get { return "This feedback requires that a TargetRectTransform be set to be able to work properly. You can set one below."; } }
|
||||
#endif
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
public override bool CanForceInitialValue => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetRectTransform = FindAutomatedTarget<RectTransform>();
|
||||
|
||||
[MMFInspectorGroup("Target RectTransform", true, 37, true)]
|
||||
/// the RectTransform whose position you want to control over time
|
||||
[Tooltip("the RectTransform whose position you want to control over time")]
|
||||
public RectTransform TargetRectTransform;
|
||||
|
||||
[MMFInspectorGroup("Pivot", true, 39)]
|
||||
/// 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, randomized between its min and max - put the same value in both min and max if you don't want any randomness
|
||||
[Tooltip("the position to remap the curve's 0 to, randomized between its min and max - put the same value in both min and max if you don't want any randomness")]
|
||||
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
|
||||
[MMFVector("Min", "Max")]
|
||||
public Vector2 RemapZero = Vector2.zero;
|
||||
/// the position to remap the curve's 1 to, randomized between its min and max - put the same value in both min and max if you don't want any randomness
|
||||
[Tooltip("the position to remap the curve's 1 to, randomized between its min and max - put the same value in both min and max if you don't want any randomness")]
|
||||
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)MMFeedbackBase.Modes.Instant)]
|
||||
[MMFVector("Min", "Max")]
|
||||
public Vector2 RemapOne = Vector2.one;
|
||||
|
||||
protected override void FillTargets()
|
||||
{
|
||||
if (TargetRectTransform == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MMF_FeedbackBaseTarget target = new MMF_FeedbackBaseTarget();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 047a03483b611234e98bb00d93390155
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_RectTransformPivot.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,72 @@
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("UI/RectTransformSizeDelta")]
|
||||
public class MMF_RectTransformSizeDelta : 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 (TargetRectTransform == null); }
|
||||
public override string RequiredTargetText { get { return TargetRectTransform != null ? TargetRectTransform.name : ""; } }
|
||||
public override string RequiresSetupText { get { return "This feedback requires that a TargetRectTransform be set to be able to work properly. You can set one below."; } }
|
||||
#endif
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
public override bool CanForceInitialValue => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetRectTransform = FindAutomatedTarget<RectTransform>();
|
||||
|
||||
[MMFInspectorGroup("Target RectTransform", true, 37, true)]
|
||||
/// the rect transform we want to impact
|
||||
[Tooltip("the rect transform we want to impact")]
|
||||
public RectTransform TargetRectTransform;
|
||||
|
||||
[MMFInspectorGroup("Size Delta", true, 38)]
|
||||
/// 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, randomized between its min and max - put the same value in both min and max if you don't want any randomness
|
||||
[Tooltip("the value to remap the curve's 0 to, randomized between its min and max - put the same value in both min and max if you don't want any randomness")]
|
||||
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime)]
|
||||
public Vector2 RemapZero = Vector2.zero;
|
||||
/// the value to remap the curve's 1 to, randomized between its min and max - put the same value in both min and max if you don't want any randomness
|
||||
[Tooltip("the value to remap the curve's 1 to, randomized between its min and max - put the same value in both min and max if you don't want any randomness")]
|
||||
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)MMFeedbackBase.Modes.Instant)]
|
||||
public Vector2 RemapOne = Vector2.one;
|
||||
|
||||
protected override void FillTargets()
|
||||
{
|
||||
if (TargetRectTransform == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MMF_FeedbackBaseTarget target = new MMF_FeedbackBaseTarget();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58875ceee40a651498d6e840f42a38bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_RectTransformSizeDelta.cs
|
||||
uploadId: 830868
|
||||
277
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_ShaderController.cs
vendored
Normal file
277
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_ShaderController.cs
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
#if MM_UI
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("Renderer/ShaderController")]
|
||||
public class MMF_ShaderController : 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.RendererColor; } }
|
||||
public override bool EvaluateRequiresSetup() { return (TargetShaderController == null); }
|
||||
public override string RequiredTargetText { get { return TargetShaderController != null ? TargetShaderController.name : ""; } }
|
||||
public override string RequiresSetupText { get { return "This feedback requires that a TargetShaderController be set to be able to work properly. You can set one below."; } }
|
||||
#endif
|
||||
public override bool HasRandomness => true;
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetShaderController = FindAutomatedTarget<ShaderController>();
|
||||
|
||||
[MMFInspectorGroup("Shader Controller", true, 37, 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 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;
|
||||
|
||||
/// whether or not to initialize the initial value to the current value on a OneTime play
|
||||
[Tooltip("whether or not to initialize the initial value to the current value on a OneTime play")]
|
||||
[MMFEnumCondition("Mode", (int)Modes.OneTime)]
|
||||
public bool GetInitialValueOnOneTime = 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(MMF_Player owner)
|
||||
{
|
||||
if (TargetShaderControllerList == null)
|
||||
{
|
||||
TargetShaderControllerList = new List<ShaderController>();
|
||||
}
|
||||
|
||||
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 = ComputeIntensity(feedbacksIntensity, position);
|
||||
|
||||
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.GetInitialValueOnOneTime = GetInitialValueOnOneTime;
|
||||
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>
|
||||
/// Sets the final value on the target shader controller(s)
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomSkipToTheEnd(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (Active && FeedbackTypeAuthorized)
|
||||
{
|
||||
TargetShaderController.SetFinalValue();
|
||||
|
||||
foreach (ShaderController shaderController in TargetShaderControllerList)
|
||||
{
|
||||
shaderController.SetFinalValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On restore, we restore our initial state
|
||||
/// </summary>
|
||||
protected override void CustomRestoreInitialValues()
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TargetShaderController.RestoreInitialValues();
|
||||
|
||||
foreach (ShaderController shaderController in TargetShaderControllerList)
|
||||
{
|
||||
shaderController.RestoreInitialValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09758e9809f18be4db32f0059b184095
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_ShaderController.cs
|
||||
uploadId: 830868
|
||||
534
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Sound.cs
vendored
Normal file
534
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Sound.cs
vendored
Normal file
@@ -0,0 +1,534 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
[ExecuteAlways]
|
||||
[AddComponentMenu("")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("Audio/Sound")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[FeedbackHelp("WARNING: this is a very simple feedback, that will let you play a sound. Nothing wrong with it being simple of course, but if you want more features, you'll want to look at the MMSoundManager Sound feedback.\n\nThis 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 MMF_Sound : 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 HasCustomInspectors => true;
|
||||
public override bool HasAutomaticShakerSetup => true;
|
||||
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."; } }
|
||||
#endif
|
||||
public override bool HasRandomness => true;
|
||||
/// the duration of this feedback is the duration of the clip being played
|
||||
public override float FeedbackDuration { get { return GetDuration(); } }
|
||||
|
||||
/// <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 }
|
||||
|
||||
[MMFInspectorGroup("Sound", true, 14, true)]
|
||||
/// the sound clip to play
|
||||
[Tooltip("the sound clip to play")]
|
||||
public AudioClip Sfx;
|
||||
|
||||
/// an array to pick a random sfx from
|
||||
[Tooltip("an array to pick a random sfx from")]
|
||||
public AudioClip[] RandomSfx;
|
||||
|
||||
/// 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;
|
||||
|
||||
[MMFInspectorGroup("Play Method", true, 27)]
|
||||
/// 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;
|
||||
/// in event mode, whether to use legacy events (MMSfxEvent) or the current events (MMSoundManagerSoundPlayEvent)
|
||||
[Tooltip("in event mode, whether to use legacy events (MMSfxEvent) or the current events (MMSoundManagerSoundPlayEvent)")]
|
||||
[MMFEnumCondition("PlayMethod", (int)PlayMethods.Event)]
|
||||
public bool UseLegacyEventsMode = false;
|
||||
/// if this is true, calling Stop on this feedback will also stop the sound from playing further
|
||||
[Tooltip("if this is true, calling Stop on this feedback will also stop the sound from playing further")]
|
||||
public bool StopSoundOnFeedbackStop = true;
|
||||
|
||||
[MMFInspectorGroup("Sound Properties", true, 28)]
|
||||
|
||||
[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("Mixer")]
|
||||
/// the audiomixer to play the sound with (optional)
|
||||
[Tooltip("the audiomixer to play the sound with (optional)")]
|
||||
public AudioMixerGroup SfxAudioMixerGroup;
|
||||
/// the audiosource priority
|
||||
[Tooltip("the audiosource priority, to be specified if needed between 0 (highest) and 256")]
|
||||
public int Priority = 128;
|
||||
|
||||
[MMFInspectorGroup("Spatial Settings", true, 33, false, true)]
|
||||
/// 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("3D Sound Settings", true, 37, false, true)]
|
||||
/// 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;
|
||||
/// whether or not to use a custom curve for custom volume rolloff
|
||||
[Tooltip("whether or not to use a custom curve for custom volume rolloff")]
|
||||
public bool UseCustomRolloffCurve = false;
|
||||
/// the curve to use for custom volume rolloff if UseCustomRolloffCurve is true
|
||||
[Tooltip("the curve to use for custom volume rolloff if UseCustomRolloffCurve is true")]
|
||||
[MMFCondition("UseCustomRolloffCurve", true)]
|
||||
public AnimationCurve CustomRolloffCurve;
|
||||
/// whether or not to use a custom curve for spatial blend
|
||||
[Tooltip("whether or not to use a custom curve for spatial blend")]
|
||||
public bool UseSpatialBlendCurve = false;
|
||||
/// the curve to use for custom spatial blend if UseSpatialBlendCurve is true
|
||||
[Tooltip("the curve to use for custom spatial blend if UseSpatialBlendCurve is true")]
|
||||
[MMFCondition("UseSpatialBlendCurve", true)]
|
||||
public AnimationCurve SpatialBlendCurve;
|
||||
/// whether or not to use a custom curve for reverb zone mix
|
||||
[Tooltip("whether or not to use a custom curve for reverb zone mix")]
|
||||
public bool UseReverbZoneMixCurve = false;
|
||||
/// the curve to use for custom reverb zone mix if UseReverbZoneMixCurve is true
|
||||
[Tooltip("the curve to use for custom reverb zone mix if UseReverbZoneMixCurve is true")]
|
||||
[MMFCondition("UseReverbZoneMixCurve", true)]
|
||||
public AnimationCurve ReverbZoneMixCurve;
|
||||
/// whether or not to use a custom curve for spread
|
||||
[Tooltip("whether or not to use a custom curve for spread")]
|
||||
public bool UseSpreadCurve = false;
|
||||
/// the curve to use for custom spread if UseSpreadCurve is true
|
||||
[Tooltip("the curve to use for custom spread if UseSpreadCurve is true")]
|
||||
[MMFCondition("UseSpreadCurve", true)]
|
||||
public AnimationCurve SpreadCurve;
|
||||
|
||||
protected AudioClip _randomClip;
|
||||
protected AudioSource _cachedAudioSource;
|
||||
protected AudioSource[] _pool;
|
||||
protected AudioSource _tempAudioSource;
|
||||
protected float _duration;
|
||||
protected AudioSource _editorAudioSource;
|
||||
protected AudioSource _audioSource;
|
||||
protected AudioClip _lastPlayedClip;
|
||||
|
||||
public override void InitializeCustomAttributes()
|
||||
{
|
||||
base.InitializeCustomAttributes();
|
||||
TestPlayButton = new MMF_Button("Debug Play Sound", TestPlaySound);
|
||||
TestStopButton = new MMF_Button("Debug Stop Sound", TestStopSound);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom init to cache the audiosource if required
|
||||
/// </summary>
|
||||
/// <param name="owner"></param>
|
||||
protected override void CustomInitialization(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
if (RandomSfx == null)
|
||||
{
|
||||
RandomSfx = Array.Empty<AudioClip>();
|
||||
}
|
||||
if ((PlayMethod == PlayMethods.Cached) && (_cachedAudioSource == null))
|
||||
{
|
||||
_cachedAudioSource = CreateAudioSource(owner.gameObject, "CachedFeedbackAudioSource");
|
||||
}
|
||||
_lastPlayedClip = null;
|
||||
if (PlayMethod == PlayMethods.Pool)
|
||||
{
|
||||
// create a pool
|
||||
_pool = new AudioSource[PoolSize];
|
||||
for (int i = 0; i < PoolSize; i++)
|
||||
{
|
||||
_pool[i] = CreateAudioSource(owner.gameObject, "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, Owner.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 = ComputeIntensity(feedbacksIntensity, position);
|
||||
|
||||
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))
|
||||
{
|
||||
if (_lastPlayedClip != null)
|
||||
{
|
||||
return _lastPlayedClip.length;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
_lastPlayedClip = sfx;
|
||||
Owner.ComputeCachedTotalDuration();
|
||||
|
||||
switch (PlayMethod)
|
||||
{
|
||||
case PlayMethods.Event:
|
||||
if (UseLegacyEventsMode)
|
||||
{
|
||||
MMSfxEvent.Trigger(sfx, SfxAudioMixerGroup, volume, pitch, Priority);
|
||||
}
|
||||
else
|
||||
{
|
||||
MMSoundManagerPlayOptions options = new MMSoundManagerPlayOptions();
|
||||
options = MMSoundManagerPlayOptions.Default;
|
||||
options.Location = Owner.transform.position;
|
||||
options.AudioGroup = SfxAudioMixerGroup;
|
||||
options.DoNotAutoRecycleIfNotDonePlaying = true;
|
||||
options.Volume = volume;
|
||||
options.Pitch = pitch;
|
||||
options.PanStereo = PanStereo;
|
||||
options.SpatialBlend = SpatialBlend;
|
||||
options.Priority = Priority;
|
||||
options.DopplerLevel = DopplerLevel;
|
||||
options.Spread = Spread;
|
||||
options.RolloffMode = RolloffMode;
|
||||
options.MinDistance = MinDistance;
|
||||
options.MaxDistance = MaxDistance;
|
||||
options.UseSpreadCurve = UseSpreadCurve;
|
||||
options.SpreadCurve = SpreadCurve;
|
||||
options.UseCustomRolloffCurve = UseCustomRolloffCurve;
|
||||
options.CustomRolloffCurve = CustomRolloffCurve;
|
||||
options.UseSpatialBlendCurve = UseSpatialBlendCurve;
|
||||
options.SpatialBlendCurve = SpatialBlendCurve;
|
||||
options.UseReverbZoneMixCurve = UseReverbZoneMixCurve;
|
||||
options.ReverbZoneMixCurve = ReverbZoneMixCurve;
|
||||
|
||||
if (Priority >= 0)
|
||||
{
|
||||
options.Priority = Mathf.Min(Priority, 256);
|
||||
}
|
||||
options.MmSoundManagerTrack = MMSoundManager.MMSoundManagerTracks.Sfx;
|
||||
options.Loop = false;
|
||||
_audioSource = MMSoundManagerSoundPlayEvent.Trigger(sfx, options);
|
||||
}
|
||||
break;
|
||||
case PlayMethods.Cached:
|
||||
// we set that audio source clip to the one in paramaters
|
||||
PlayAudioSource(_cachedAudioSource, sfx, volume, pitch, timeSamples, SfxAudioMixerGroup, Priority);
|
||||
break;
|
||||
case PlayMethods.OnDemand:
|
||||
// we create a temporary game object to host our audio source
|
||||
GameObject temporaryAudioHost = new GameObject("TempAudio");
|
||||
SceneManager.MoveGameObjectToScene(temporaryAudioHost.gameObject, Owner.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
|
||||
Owner.ProxyDestroy(temporaryAudioHost, sfx.length * Time.timeScale);
|
||||
break;
|
||||
case PlayMethods.Pool:
|
||||
_tempAudioSource = GetAudioSourceFromPool();
|
||||
if (_tempAudioSource != null)
|
||||
{
|
||||
PlayAudioSource(_tempAudioSource, sfx, volume, pitch, timeSamples, SfxAudioMixerGroup, Priority);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 && (_audioSource != null))
|
||||
{
|
||||
_audioSource.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, AudioMixerGroup audioMixerGroup = null, int priority = 128)
|
||||
{
|
||||
_audioSource = audioSource;
|
||||
// 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;
|
||||
audioSource.priority = priority;
|
||||
// we set spatial settings
|
||||
audioSource.panStereo = PanStereo;
|
||||
audioSource.spatialBlend = SpatialBlend;
|
||||
audioSource.dopplerLevel = DopplerLevel;
|
||||
audioSource.spread = Spread;
|
||||
audioSource.rolloffMode = RolloffMode;
|
||||
audioSource.minDistance = MinDistance;
|
||||
audioSource.maxDistance = MaxDistance;
|
||||
if (UseSpreadCurve) { audioSource.SetCustomCurve(AudioSourceCurveType.Spread, SpreadCurve); }
|
||||
if (UseCustomRolloffCurve) { audioSource.SetCustomCurve(AudioSourceCurveType.CustomRolloff, CustomRolloffCurve); }
|
||||
if (UseSpatialBlendCurve) { audioSource.SetCustomCurve(AudioSourceCurveType.SpatialBlend, SpatialBlendCurve); }
|
||||
if (UseReverbZoneMixCurve) { audioSource.SetCustomCurve(AudioSourceCurveType.ReverbZoneMix, ReverbZoneMixCurve); }
|
||||
// we set our loop setting
|
||||
audioSource.loop = false;
|
||||
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 " + 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);
|
||||
GameObject temporaryAudioHost = new GameObject("EditorTestAS_WillAutoDestroy");
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
temporaryAudioHost.AddComponent<MMForceDestroyInPlayMode>();
|
||||
}
|
||||
SceneManager.MoveGameObjectToScene(temporaryAudioHost.gameObject, Owner.gameObject.scene);
|
||||
temporaryAudioHost.transform.position = Owner.transform.position;
|
||||
_editorAudioSource = temporaryAudioHost.AddComponent<AudioSource>() as AudioSource;
|
||||
PlayAudioSource(_editorAudioSource, tmpAudioClip, volume, pitch, 0);
|
||||
float length = 1000 * tmpAudioClip.length;
|
||||
await Task.Delay((int)length);
|
||||
Owner.ProxyDestroyImmediate(temporaryAudioHost);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A test method that stops the test sound
|
||||
/// </summary>
|
||||
protected virtual void TestStopSound()
|
||||
{
|
||||
if (_editorAudioSource != null)
|
||||
{
|
||||
_editorAudioSource.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Automatically tries to add a MMSoundManager to the scene if none are present
|
||||
/// </summary>
|
||||
public override void AutomaticShakerSetup()
|
||||
{
|
||||
if (PlayMethod != PlayMethods.Event)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MMSoundManager soundManager = (MMSoundManager)UnityEngine.Object.FindAnyObjectByType(typeof(MMSoundManager));
|
||||
if (soundManager == null)
|
||||
{
|
||||
GameObject soundManagerGo = new GameObject("MMSoundManager");
|
||||
soundManagerGo.AddComponent<MMSoundManager>();
|
||||
MMDebug.DebugLogInfo( "Added a MMSoundManager to the scene. You're all set.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Sound.cs.meta
vendored
Normal file
18
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Sound.cs.meta
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 074e2f162fb1f104087f3cc4bef82972
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_Sound.cs
|
||||
uploadId: 830868
|
||||
81
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_TextFontSize.cs
vendored
Normal file
81
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_TextFontSize.cs
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
#if MM_UI
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
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.")]
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.MMTools")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("UI/Text Font Size")]
|
||||
public class MMF_TextFontSize : MMF_FeedbackBase
|
||||
{
|
||||
/// sets the inspector color for this feedback
|
||||
#if UNITY_EDITOR
|
||||
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.TMPColor; } }
|
||||
public override bool EvaluateRequiresSetup() { return (TargetText == null); }
|
||||
public override string RequiredTargetText { get { return TargetText != null ? TargetText.name : ""; } }
|
||||
public override string RequiresSetupText { get { return "This feedback requires that a TargetText be set to be able to work properly. You can set one below."; } }
|
||||
#endif
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
public override bool CanForceInitialValue => true;
|
||||
protected override void AutomateTargetAcquisition() => TargetText = FindAutomatedTarget<Text>();
|
||||
|
||||
[MMFInspectorGroup("Target", true, 58, true)]
|
||||
/// the TMP_Text component to control
|
||||
[Tooltip("the TMP_Text component to control")]
|
||||
public Text TargetText;
|
||||
|
||||
[MMFInspectorGroup("Font Size", true, 59)]
|
||||
/// the curve to tween on
|
||||
[Tooltip("the curve to tween on")]
|
||||
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)Modes.ToDestination)]
|
||||
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;
|
||||
/// the value to move to in destination mode
|
||||
[Tooltip("the value to move to in destination mode")]
|
||||
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
|
||||
public float DestinationFontSize;
|
||||
|
||||
protected override void FillTargets()
|
||||
{
|
||||
if (TargetText == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MMF_FeedbackBaseTarget target = new MMF_FeedbackBaseTarget();
|
||||
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;
|
||||
target.ToDestinationLevel = DestinationFontSize;
|
||||
|
||||
_targets.Add(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93076aeef94b6194eacceebc74fcd3b5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_TextFontSize.cs
|
||||
uploadId: 830868
|
||||
246
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_TrailRenderer.cs
vendored
Normal file
246
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_TrailRenderer.cs
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// This feedback will let you control the length, width and color of a target TrailRenderer over time
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
[FeedbackHelp("This feedback will let you control the length, width and color of a target TrailRenderer over time")]
|
||||
[System.Serializable]
|
||||
[FeedbackPath("Renderer/Trail Renderer")]
|
||||
public class MMF_TrailRenderer : 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 bool EvaluateRequiresSetup() => (TargetTrailRenderer == null);
|
||||
public override string RequiredTargetText => TargetTrailRenderer != null ? TargetTrailRenderer.name : "";
|
||||
public override string RequiresSetupText => "This feedback requires that a TargetTrailRenderer be set to be able to work properly. You can set one below.";
|
||||
#endif
|
||||
public override bool HasRandomness => true;
|
||||
public override bool HasCustomInspectors => true;
|
||||
|
||||
/// the possible modes for this feedback
|
||||
public enum Modes { OverTime, Instant }
|
||||
|
||||
[MMFInspectorGroup("Trail Renderer", true, 24, true)]
|
||||
/// the trail renderer whose properties you want to modify
|
||||
[Tooltip("the trail renderer whose properties you want to modify")]
|
||||
public TrailRenderer TargetTrailRenderer;
|
||||
/// 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;
|
||||
/// a curve to use to animate the trail renderer's density over time
|
||||
[Tooltip("a curve to use to animate the trail renderer's density over time")]
|
||||
[MMFEnumCondition("Mode", (int)Modes.OverTime)]
|
||||
public MMTweenType Transition = new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
|
||||
|
||||
[MMFInspectorGroup("Width", true, 25)]
|
||||
/// whether or not to modify the trail renderer's width
|
||||
[Tooltip("whether or not to modify the trail renderer's width")]
|
||||
public bool ModifyWidth = true;
|
||||
/// a curve defining the new width of the trail renderer, describing the world space width of the trail at each point along its length
|
||||
[Tooltip("a curve defining the new width of the trail renderer, describing the world space width of the trail at each point along its length")]
|
||||
public AnimationCurve NewWidth = new AnimationCurve(new Keyframe(0, 1), new Keyframe(1, 0));
|
||||
|
||||
[MMFInspectorGroup("Color", true, 28)]
|
||||
/// whether or not to modify the trail renderer's color
|
||||
[Tooltip("whether or not to modify the trail renderer'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")]
|
||||
public Gradient NewColor = new Gradient();
|
||||
|
||||
[MMFInspectorGroup("Trail Renderer Time", true, 28)]
|
||||
/// whether or not to modify the trail renderer's time (how long the trail should be in seconds)
|
||||
[Tooltip("whether or not to modify the trail renderer's time (how long the trail should be in seconds)")]
|
||||
public bool ModifyTime = true;
|
||||
/// the new trail renderer's time (how long the trail should be in seconds) to apply
|
||||
[Tooltip("the new trail renderer's time (how long the trail should be in seconds) to apply")]
|
||||
public float NewTime = 2f;
|
||||
|
||||
/// 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 Gradient _initialColor;
|
||||
protected AnimationCurve _initialWidth;
|
||||
protected float _initialTime;
|
||||
|
||||
protected Gradient _firstColor;
|
||||
protected AnimationCurve _firstWidth;
|
||||
protected float _firstTime;
|
||||
|
||||
protected override void CustomInitialization(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
|
||||
if (Active)
|
||||
{
|
||||
if (TargetTrailRenderer == null)
|
||||
{
|
||||
Debug.LogWarning("[Trail Renderer Feedback] The trail renderer feedback on "+Owner.name+" doesn't have a TargetTrailRenderer, it won't work. You need to specify one in its inspector.");
|
||||
return;
|
||||
}
|
||||
|
||||
_firstColor = TargetTrailRenderer.colorGradient;
|
||||
_firstWidth = TargetTrailRenderer.widthCurve;
|
||||
_firstTime = TargetTrailRenderer.time;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Play we change the values of our trail renderer
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized || (TargetTrailRenderer == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_initialColor = TargetTrailRenderer.colorGradient;
|
||||
_initialWidth = TargetTrailRenderer.widthCurve;
|
||||
_initialTime = TargetTrailRenderer.time;
|
||||
|
||||
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
|
||||
switch (Mode)
|
||||
{
|
||||
case Modes.Instant:
|
||||
if (ModifyColor)
|
||||
{
|
||||
TargetTrailRenderer.colorGradient = NormalPlayDirection ? NewColor : _firstColor;
|
||||
}
|
||||
if (ModifyWidth)
|
||||
{
|
||||
TargetTrailRenderer.widthCurve = NormalPlayDirection ? NewWidth : _firstWidth;
|
||||
}
|
||||
if (ModifyTime)
|
||||
{
|
||||
TargetTrailRenderer.time = NormalPlayDirection ? NewTime : _firstTime;
|
||||
}
|
||||
break;
|
||||
case Modes.OverTime:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_coroutine = Owner.StartCoroutine(TrailRendererSequence(intensityMultiplier));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This coroutine will modify the values on the trail renderer over time
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual IEnumerator TrailRendererSequence(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);
|
||||
remappedTime = Transition.Evaluate(remappedTime);
|
||||
SetTrailRendererValues(remappedTime, intensityMultiplier);
|
||||
|
||||
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
SetTrailRendererValues(Transition.Evaluate(FinalNormalizedTime), intensityMultiplier);
|
||||
_coroutine = null;
|
||||
IsPlaying = false;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the various values on the trail renderer on a specified time (between 0 and 1)
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
protected virtual void SetTrailRendererValues(float time, float intensityMultiplier)
|
||||
{
|
||||
if (ModifyColor)
|
||||
{
|
||||
if (NormalPlayDirection)
|
||||
{
|
||||
TargetTrailRenderer.colorGradient = MMColors.LerpGradients(_initialColor, NewColor, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetTrailRenderer.colorGradient = MMColors.LerpGradients(NewColor, _firstColor, time);
|
||||
}
|
||||
}
|
||||
|
||||
if (ModifyWidth)
|
||||
{
|
||||
if (NormalPlayDirection)
|
||||
{
|
||||
TargetTrailRenderer.widthCurve = MMAnimationCurves.LerpAnimationCurves(_initialWidth, NewWidth, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetTrailRenderer.widthCurve = MMAnimationCurves.LerpAnimationCurves(NewWidth, _firstWidth, time);
|
||||
}
|
||||
}
|
||||
|
||||
if (ModifyTime)
|
||||
{
|
||||
if (NormalPlayDirection)
|
||||
{
|
||||
TargetTrailRenderer.time = MMMaths.Lerp(_initialTime, NewTime, time, FeedbackDeltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetTrailRenderer.time = MMMaths.Lerp(NewTime, _firstTime, time, FeedbackDeltaTime);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
TargetTrailRenderer.widthCurve = _firstWidth;
|
||||
TargetTrailRenderer.colorGradient = _firstColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d52e2caed94cf0408a14edc402b85ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Feedbacks/MMF_TrailRenderer.cs
|
||||
uploadId: 830868
|
||||
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MMRadio.meta
vendored
Normal file
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MMRadio.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f70eabfbd004ab4bbadc093dc39761b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MMRadio/Legacy.meta
vendored
Normal file
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MMRadio/Legacy.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe68cc0665ffaa849842ed77ae03c24a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
256
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MMRadio/Legacy/MMFeedbackBase.cs
vendored
Normal file
256
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MMRadio/Legacy/MMFeedbackBase.cs
vendored
Normal file
@@ -0,0 +1,256 @@
|
||||
using MoreMountains.Tools;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
public class MMFeedbackBaseTarget
|
||||
{
|
||||
/// the receiver to write the level to
|
||||
public MMPropertyReceiver Target;
|
||||
/// the curve to tween the intensity on
|
||||
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
|
||||
public float RemapLevelZero = 0f;
|
||||
/// the value to remap the intensity curve's 1 to
|
||||
public float RemapLevelOne = 1f;
|
||||
/// the value to move the intensity to in instant mode
|
||||
public float InstantLevel;
|
||||
/// the initial value for this level
|
||||
public float InitialLevel;
|
||||
}
|
||||
|
||||
public abstract class MMFeedbackBase : MMFeedback
|
||||
{
|
||||
/// a static bool used to disable all feedbacks of this type at once
|
||||
public static bool FeedbackTypeAuthorized = true;
|
||||
|
||||
/// the possible modes for this feedback
|
||||
public enum Modes { OverTime, Instant }
|
||||
|
||||
[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;
|
||||
|
||||
/// if this is true, the target object will be disabled on stop
|
||||
[Tooltip("if this is true, the target object will be disabled on stop")]
|
||||
public bool DisableOnStop = false;
|
||||
|
||||
/// 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; } } }
|
||||
|
||||
protected List<MMFeedbackBaseTarget> _targets;
|
||||
protected Coroutine _coroutine = null;
|
||||
|
||||
/// <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);
|
||||
|
||||
PrepareTargets();
|
||||
|
||||
if (Active)
|
||||
{
|
||||
if (StartsOff)
|
||||
{
|
||||
Turn(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new list, fills the targets, and initializes them
|
||||
/// </summary>
|
||||
protected virtual void PrepareTargets()
|
||||
{
|
||||
_targets = new List<MMFeedbackBaseTarget>();
|
||||
FillTargets();
|
||||
InitializeTargets();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On validate (if a value has changed in the inspector), we reinitialize what needs to be
|
||||
/// </summary>
|
||||
protected virtual void OnValidate()
|
||||
{
|
||||
PrepareTargets();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills our list of targets, meant to be extended
|
||||
/// </summary>
|
||||
protected abstract void FillTargets();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes each target in the list
|
||||
/// </summary>
|
||||
protected virtual void InitializeTargets()
|
||||
{
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(MMFeedbackBaseTarget target in _targets)
|
||||
{
|
||||
target.Target.Initialization(this.gameObject);
|
||||
target.InitialLevel = target.Target.Level;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 && FeedbackTypeAuthorized)
|
||||
{
|
||||
Turn(true);
|
||||
switch (Mode)
|
||||
{
|
||||
case Modes.Instant:
|
||||
Instant();
|
||||
break;
|
||||
case Modes.OverTime:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_coroutine = StartCoroutine(UpdateValueSequence(feedbacksIntensity));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plays an instant feedback
|
||||
/// </summary>
|
||||
protected virtual void Instant()
|
||||
{
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (MMFeedbackBaseTarget target in _targets)
|
||||
{
|
||||
target.Target.SetLevel(target.InstantLevel);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This coroutine will modify the values on the target property
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual IEnumerator UpdateValueSequence(float feedbacksIntensity)
|
||||
{
|
||||
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
|
||||
IsPlaying = true;
|
||||
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
|
||||
{
|
||||
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
|
||||
SetValues(remappedTime, feedbacksIntensity);
|
||||
|
||||
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
|
||||
yield return null;
|
||||
}
|
||||
SetValues(FinalNormalizedTime, feedbacksIntensity);
|
||||
if (StartsOff)
|
||||
{
|
||||
Turn(false);
|
||||
}
|
||||
IsPlaying = 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 feedbacksIntensity)
|
||||
{
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
|
||||
|
||||
foreach (MMFeedbackBaseTarget target in _targets)
|
||||
{
|
||||
float intensity = MMTween.Tween(time, 0f, 1f, target.RemapLevelZero, target.RemapLevelOne, target.LevelCurve);
|
||||
if (RelativeValues)
|
||||
{
|
||||
intensity += target.InitialLevel;
|
||||
}
|
||||
target.Target.SetLevel(intensity * intensityMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
IsPlaying = false;
|
||||
if (DisableOnStop)
|
||||
{
|
||||
Turn(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns the target object on or off
|
||||
/// </summary>
|
||||
/// <param name="status"></param>
|
||||
protected virtual void Turn(bool status)
|
||||
{
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (MMFeedbackBaseTarget target in _targets)
|
||||
{
|
||||
if (target.Target.TargetComponent.gameObject != null)
|
||||
{
|
||||
target.Target.TargetComponent.gameObject.SetActive(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f4f5b5a7ea2cc745891557ab909c6c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MMRadio/Legacy/MMFeedbackBase.cs
|
||||
uploadId: 830868
|
||||
348
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MMRadio/MMF_FeedbackBase.cs
vendored
Normal file
348
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MMRadio/MMF_FeedbackBase.cs
vendored
Normal file
@@ -0,0 +1,348 @@
|
||||
using MoreMountains.Tools;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
public class MMF_FeedbackBaseTarget
|
||||
{
|
||||
/// the receiver to write the level to
|
||||
public MMPropertyReceiver Target;
|
||||
/// the curve to tween the intensity on
|
||||
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
|
||||
public float RemapLevelZero = 0f;
|
||||
/// the value to remap the intensity curve's 1 to
|
||||
public float RemapLevelOne = 1f;
|
||||
/// the value to move the intensity to in instant mode
|
||||
public float InstantLevel;
|
||||
/// the initial value for this level
|
||||
public float InitialLevel;
|
||||
/// the level to reach in ToDestination mode
|
||||
public float ToDestinationLevel;
|
||||
}
|
||||
|
||||
public abstract class MMF_FeedbackBase : MMF_Feedback
|
||||
{
|
||||
/// a static bool used to disable all feedbacks of this type at once
|
||||
public static bool FeedbackTypeAuthorized = true;
|
||||
|
||||
/// the possible modes for this feedback
|
||||
public enum Modes { OverTime, Instant, ToDestination }
|
||||
|
||||
[MMFInspectorGroup("Mode", true, 64)]
|
||||
/// 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, (int)Modes.ToDestination)]
|
||||
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 that target property should be turned off once the feedback is done playing
|
||||
[Tooltip("whether or not that target property should be turned off once the feedback is done playing")]
|
||||
public bool EndsOff = 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 = false;
|
||||
/// 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;
|
||||
/// if this is true, the target object will be disabled on stop
|
||||
[Tooltip("if this is true, the target object will be disabled on stop")]
|
||||
public bool DisableOnStop = false;
|
||||
/// if this is true, this feedback will only play if its target is active in hierarchy
|
||||
[Tooltip("if this is true, this feedback will only play if its target is active in hierarchy")]
|
||||
public bool OnlyPlayIfTargetIsActive = false;
|
||||
/// 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; } } }
|
||||
public override bool HasRandomness => true;
|
||||
public override bool HasCustomInspectors => true;
|
||||
|
||||
protected List<MMF_FeedbackBaseTarget> _targets;
|
||||
protected Coroutine _coroutine = null;
|
||||
|
||||
/// <summary>
|
||||
/// On init we turn the target property off if needed
|
||||
/// </summary>
|
||||
/// <param name="owner"></param>
|
||||
protected override void CustomInitialization(MMF_Player owner)
|
||||
{
|
||||
base.CustomInitialization(owner);
|
||||
|
||||
PrepareTargets();
|
||||
|
||||
if (Active)
|
||||
{
|
||||
if (StartsOff)
|
||||
{
|
||||
Turn(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new list, fills the targets, and initializes them
|
||||
/// </summary>
|
||||
public virtual void PrepareTargets()
|
||||
{
|
||||
_targets = new List<MMF_FeedbackBaseTarget>();
|
||||
FillTargets();
|
||||
InitializeTargets();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On validate (if a value has changed in the inspector), we reinitialize what needs to be
|
||||
/// </summary>
|
||||
public override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
PrepareTargets();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills our list of targets, meant to be extended
|
||||
/// </summary>
|
||||
protected abstract void FillTargets();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes each target in the list
|
||||
/// </summary>
|
||||
protected virtual void InitializeTargets()
|
||||
{
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(MMF_FeedbackBaseTarget target in _targets)
|
||||
{
|
||||
target.Target.Initialization(Owner.gameObject);
|
||||
target.InitialLevel = target.Target.GetLevel();;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 && FeedbackTypeAuthorized)
|
||||
{
|
||||
if (!CanPlay())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Turn(true);
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
case Modes.Instant:
|
||||
Instant();
|
||||
break;
|
||||
case Modes.OverTime:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_coroutine = Owner.StartCoroutine(UpdateValueOverTimeCo(feedbacksIntensity, position));
|
||||
break;
|
||||
case Modes.ToDestination:
|
||||
if (!AllowAdditivePlays && (_coroutine != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
|
||||
_coroutine = Owner.StartCoroutine(UpdateValueToDestinationCo(feedbacksIntensity, position));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plays an instant feedback
|
||||
/// </summary>
|
||||
protected virtual void Instant()
|
||||
{
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (MMF_FeedbackBaseTarget target in _targets)
|
||||
{
|
||||
float newLevel = NormalPlayDirection ? target.InstantLevel : target.InitialLevel;
|
||||
target.Target.SetLevel(newLevel);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On restore, we put our object back at its initial position
|
||||
/// </summary>
|
||||
protected override void CustomRestoreInitialValues()
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (MMF_FeedbackBaseTarget target in _targets)
|
||||
{
|
||||
target.Target.SetLevel(target.InitialLevel);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This coroutine will modify the values on the target property
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual IEnumerator UpdateValueOverTimeCo(float feedbacksIntensity, Vector3 position)
|
||||
{
|
||||
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
|
||||
IsPlaying = true;
|
||||
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
|
||||
{
|
||||
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
|
||||
SetValues(remappedTime, feedbacksIntensity, position);
|
||||
|
||||
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
|
||||
yield return null;
|
||||
}
|
||||
SetValues(FinalNormalizedTime, feedbacksIntensity, position);
|
||||
if (EndsOff)
|
||||
{
|
||||
Turn(false);
|
||||
}
|
||||
IsPlaying = false;
|
||||
_coroutine = null;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
protected virtual IEnumerator UpdateValueToDestinationCo(float feedbacksIntensity, Vector3 position)
|
||||
{
|
||||
InitializeTargets();
|
||||
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
|
||||
IsPlaying = true;
|
||||
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
|
||||
{
|
||||
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
|
||||
SetValues(remappedTime, feedbacksIntensity, position, Modes.ToDestination);
|
||||
|
||||
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
|
||||
yield return null;
|
||||
}
|
||||
SetValues(FinalNormalizedTime, feedbacksIntensity, position, Modes.ToDestination);
|
||||
if (EndsOff)
|
||||
{
|
||||
Turn(false);
|
||||
}
|
||||
IsPlaying = 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 feedbacksIntensity, Vector3 position, Modes mode = Modes.OverTime)
|
||||
{
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
|
||||
|
||||
foreach (MMF_FeedbackBaseTarget target in _targets)
|
||||
{
|
||||
float intensity = MMTween.Tween(time, 0f, 1f, target.RemapLevelZero, target.RemapLevelOne, target.LevelCurve);
|
||||
|
||||
if (mode == Modes.ToDestination)
|
||||
{
|
||||
intensity = MMTween.Tween(time, 0f, 1f, target.InitialLevel, target.ToDestinationLevel, target.LevelCurve);
|
||||
}
|
||||
|
||||
target.Target.SetLevel(intensity * intensityMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
Owner.StopCoroutine(_coroutine);
|
||||
_coroutine = null;
|
||||
}
|
||||
IsPlaying = false;
|
||||
if (DisableOnStop)
|
||||
{
|
||||
Turn(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns the target object on or off
|
||||
/// </summary>
|
||||
/// <param name="status"></param>
|
||||
protected virtual void Turn(bool status)
|
||||
{
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (MMF_FeedbackBaseTarget target in _targets)
|
||||
{
|
||||
if (target.Target.TargetComponent.gameObject != null)
|
||||
{
|
||||
target.Target.TargetComponent.gameObject.SetActive(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not this feedback should play according to the defined settings
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual bool CanPlay()
|
||||
{
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach (MMF_FeedbackBaseTarget target in _targets)
|
||||
{
|
||||
if (OnlyPlayIfTargetIsActive)
|
||||
{
|
||||
if (!target.Target.TargetComponent.gameObject.activeInHierarchy)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6906d20e526ebe749b396f651e78e047
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MMRadio/MMF_FeedbackBase.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"reference": "GUID:4a1cb1490dc4df8409b2580d6b44e75e"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f66483fc4928824e96ba9aa3eb86e6f
|
||||
AssemblyDefinitionReferenceImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/MoreMountains.Feedbacks.MMTools.asmref
|
||||
uploadId: 830868
|
||||
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Shakers.meta
vendored
Normal file
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Shakers.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f20699338969e5a4bb1837ea73f00963
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,267 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace MoreMountains.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// An event used to move filters on and off a camera
|
||||
/// </summary>
|
||||
public struct MMPostProcessingMovingFilterEvent
|
||||
{
|
||||
static private event Delegate OnEvent;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private static void RuntimeInitialization()
|
||||
{
|
||||
OnEvent = null;
|
||||
}
|
||||
|
||||
static public void Register(Delegate callback)
|
||||
{
|
||||
OnEvent += callback;
|
||||
}
|
||||
|
||||
static public void Unregister(Delegate callback)
|
||||
{
|
||||
OnEvent -= callback;
|
||||
}
|
||||
|
||||
public delegate void Delegate(MMTweenType curve, bool active, bool toggle, float duration, int channel = 0,
|
||||
bool stop = false, bool restore = false);
|
||||
|
||||
static public void Trigger(MMTweenType curve, bool active, bool toggle, float duration, int channel = 0,
|
||||
bool stop = false, bool restore = false)
|
||||
{
|
||||
OnEvent?.Invoke(curve, active, toggle, duration, channel, stop, restore);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// This class lets you create moving filters, very much like the old gelatin camera filters, that will move to connect to your camera
|
||||
/// Typically a moving filter should be made of a MMPostProcessingMovingFilter component,
|
||||
/// a PostProcessing volume, and a BoxCollider (recommended size is 1,1,1 if you want to use the default offset)
|
||||
/// The filter will move on the y axis.
|
||||
///
|
||||
/// Use :
|
||||
/// MMPostProcessingMovingFilterEvent.Trigger(MMTween.MMTweenCurve.EaseInOutCubic, TrueOrFalse, Duration, ChannelID);
|
||||
///
|
||||
/// </summary>
|
||||
[AddComponentMenu("More Mountains/Tools/Camera/MM Post Processing Moving Filter")]
|
||||
public class MMPostProcessingMovingFilter : MonoBehaviour
|
||||
{
|
||||
public enum TimeScales
|
||||
{
|
||||
Unscaled,
|
||||
Scaled
|
||||
}
|
||||
|
||||
[Header("Settings")]
|
||||
/// the channel ID for this filter. Any event with a different channel ID will be ignored
|
||||
public int Channel = 0;
|
||||
|
||||
/// whether this should use scaled or unscaled time
|
||||
public TimeScales TimeScale = TimeScales.Unscaled;
|
||||
|
||||
/// the curve to use for this movement
|
||||
public MMTweenType Curve = new MMTweenType(MMTween.MMTweenCurve.EaseInCubic);
|
||||
|
||||
/// whether the filter is active at start or not
|
||||
public bool Active = false;
|
||||
|
||||
[MMVector("On", "Off")]
|
||||
/// the vertical offsets to apply when the filter is on or off
|
||||
public Vector2 FilterOffset = new Vector2(0f, 5f);
|
||||
|
||||
/// whether or not to add the initial position
|
||||
public bool AddToInitialPosition = true;
|
||||
|
||||
[Header("Tests")]
|
||||
/// the duration to apply to the test methods
|
||||
public float TestDuration = 0.5f;
|
||||
|
||||
/// a test button to toggle the filter on or off
|
||||
[MMInspectorButton("PostProcessingToggle")]
|
||||
public bool PostProcessingToggleButton;
|
||||
|
||||
/// a test button to turn the filter off
|
||||
[MMInspectorButton("PostProcessingTriggerOff")]
|
||||
public bool PostProcessingTriggerOffButton;
|
||||
|
||||
/// a test button to turn the filter on
|
||||
[MMInspectorButton("PostProcessingTriggerOn")]
|
||||
public bool PostProcessingTriggerOnButton;
|
||||
|
||||
protected bool _lastReachedState = false;
|
||||
protected float _duration = 2f;
|
||||
protected float _lastMovementStartedAt = 0f;
|
||||
protected Vector3 _initialPosition;
|
||||
protected Vector3 _positionToRestore;
|
||||
protected Vector3 _newPosition;
|
||||
|
||||
/// <summary>
|
||||
/// On Start we initialize our filter
|
||||
/// </summary>
|
||||
protected virtual void Start()
|
||||
{
|
||||
Initialization();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the filter at the right initial position
|
||||
/// </summary>
|
||||
protected virtual void Initialization()
|
||||
{
|
||||
_lastMovementStartedAt = 0f;
|
||||
|
||||
_positionToRestore = this.transform.localPosition;
|
||||
|
||||
if (AddToInitialPosition)
|
||||
{
|
||||
_initialPosition = this.transform.localPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
_initialPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
_newPosition = _initialPosition;
|
||||
_newPosition.y = Active ? _initialPosition.y + FilterOffset.x : _initialPosition.y + FilterOffset.y;
|
||||
this.transform.localPosition = _newPosition;
|
||||
_lastReachedState = Active;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On update we move if needed
|
||||
/// </summary>
|
||||
protected virtual void Update()
|
||||
{
|
||||
// if we're already at destination, we do nothing and exit
|
||||
if (_lastReachedState == Active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MoveTowardsCurrentTarget();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the filter towards its current target position
|
||||
/// </summary>
|
||||
protected virtual void MoveTowardsCurrentTarget()
|
||||
{
|
||||
if (_newPosition != this.transform.localPosition)
|
||||
{
|
||||
this.transform.localPosition = _newPosition;
|
||||
}
|
||||
|
||||
float originY = Active ? _initialPosition.y + FilterOffset.y : _initialPosition.y + FilterOffset.x;
|
||||
float targetY = Active ? _initialPosition.y + FilterOffset.x : _initialPosition.y + FilterOffset.y;
|
||||
float currentTime = (TimeScale == TimeScales.Unscaled) ? Time.unscaledTime : Time.time;
|
||||
|
||||
_newPosition = this.transform.localPosition;
|
||||
_newPosition.y =
|
||||
MMTween.Tween(currentTime - _lastMovementStartedAt, 0f, _duration, originY, targetY, Curve);
|
||||
|
||||
if (currentTime - _lastMovementStartedAt > _duration)
|
||||
{
|
||||
_newPosition.y = targetY;
|
||||
this.transform.localPosition = _newPosition;
|
||||
_lastReachedState = Active;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RestoreInitialPosition()
|
||||
{
|
||||
this.transform.localPosition = _positionToRestore;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if we get a PostProcessingTriggerEvent
|
||||
/// </summary>
|
||||
/// <param name="curve"></param>
|
||||
/// <param name="active"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <param name="channel"></param>
|
||||
public virtual void OnMMPostProcessingMovingFilterEvent(MMTweenType curve, bool active, bool toggle,
|
||||
float duration, int channel = 0, bool stop = false, bool restore = false)
|
||||
{
|
||||
if ((channel != Channel) && (channel != -1) && (Channel != -1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (stop)
|
||||
{
|
||||
_lastReachedState = Active;
|
||||
return;
|
||||
}
|
||||
|
||||
if (restore)
|
||||
{
|
||||
RestoreInitialPosition();
|
||||
return;
|
||||
}
|
||||
|
||||
Curve = curve;
|
||||
_duration = duration;
|
||||
|
||||
if (toggle)
|
||||
{
|
||||
Active = !Active;
|
||||
}
|
||||
else
|
||||
{
|
||||
Active = active;
|
||||
}
|
||||
|
||||
float currentTime = (TimeScale == TimeScales.Unscaled) ? Time.unscaledTime : Time.time;
|
||||
_lastMovementStartedAt = currentTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On enable, we start listening to MMPostProcessingTriggerEvents
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
MMPostProcessingMovingFilterEvent.Register(OnMMPostProcessingMovingFilterEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On disable, we stop listening to MMPostProcessingTriggerEvents
|
||||
/// </summary>
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
MMPostProcessingMovingFilterEvent.Unregister(OnMMPostProcessingMovingFilterEvent);
|
||||
}
|
||||
|
||||
// TEST METHODS --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the post processing effect on or off
|
||||
/// </summary>
|
||||
protected virtual void PostProcessingToggle()
|
||||
{
|
||||
MMPostProcessingMovingFilterEvent.Trigger(new MMTweenType(MMTween.MMTweenCurve.EaseInOutCubic), false, true,
|
||||
TestDuration, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns the post processing effect off
|
||||
/// </summary>
|
||||
protected virtual void PostProcessingTriggerOff()
|
||||
{
|
||||
MMPostProcessingMovingFilterEvent.Trigger(new MMTweenType(MMTween.MMTweenCurve.EaseInOutCubic), false,
|
||||
false, TestDuration, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns the post processing effect on
|
||||
/// </summary>
|
||||
protected virtual void PostProcessingTriggerOn()
|
||||
{
|
||||
MMPostProcessingMovingFilterEvent.Trigger(new MMTweenType(MMTween.MMTweenCurve.EaseInOutCubic), true, false,
|
||||
TestDuration, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6acbf0a8faacbb342ad72339d38c5a4d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/MMTools/Shakers/MMPostProcessingMovingFilter.cs
|
||||
uploadId: 830868
|
||||
Reference in New Issue
Block a user