架构大更

This commit is contained in:
SoulliesOfficial
2026-03-20 11:56:50 -04:00
parent e60ef64d01
commit d09b58fd80
3663 changed files with 15232012 additions and 105579 deletions

View File

@@ -1,91 +1,100 @@
using MoreMountains.Tools;
using UnityEngine;
using UnityEngine.Scripting.APIUpdating;
#if MM_UGUI2
using TMPro;
#endif
using UnityEngine.Scripting.APIUpdating;
using UnityEngine.Serialization;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you control the line spacing of a target TMP over time
/// This feedback lets you control the line spacing of a target TMP over time
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you control the line spacing of a target TMP over time.")]
#if MM_UGUI2
[FeedbackPath("TextMesh Pro/TMP Line Spacing")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.TextMeshPro")]
public class MMF_TMPLineSpacing : MMF_FeedbackBase
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.TMPColor; } }
public override string RequiresSetupText { get { return "This feedback requires that a TargetTMPText be set to be able to work properly. You can set one below."; } }
#endif
#if UNITY_EDITOR && MM_UGUI2
public override bool EvaluateRequiresSetup() { return (TargetTMPText == null); }
public override string RequiredTargetText { get { return TargetTMPText != null ? TargetTMPText.name : ""; } }
#endif
[FeedbackHelp("This feedback lets you control the line spacing of a target TMP over time.")]
#if MM_UGUI2
[FeedbackPath("TextMesh Pro/TMP Line Spacing")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.TextMeshPro")]
public class MMF_TMPLineSpacing : MMF_FeedbackBase
{
/// the value to move to in destination mode
[Tooltip("the value to move to in destination mode")] [MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float DestinationLineSpacing;
#if MM_UGUI2
public override bool HasAutomatedTargetAcquisition => true;
public override bool CanForceInitialValue => true;
protected override void AutomateTargetAcquisition() => TargetTMPText = FindAutomatedTarget<TMP_Text>();
/// 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 InstantLineSpacing;
[MMFInspectorGroup("Target", true, 12, true)]
/// the TMP_Text component to control
[Tooltip("the TMP_Text component to control")]
public TMP_Text TargetTMPText;
#endif
[MMFInspectorGroup("Paragraph Spacing", true, 37)]
/// the curve to tween on
[Tooltip("the curve to tween on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)Modes.ToDestination)]
public MMTweenType LineSpacingCurve =
new(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)));
[MMFInspectorGroup("Paragraph Spacing", true, 37)]
/// the curve to tween on
[Tooltip("the curve to tween on")]
[MMFEnumCondition("Mode", (int)MMFeedbackBase.Modes.OverTime, (int)Modes.ToDestination)]
public MMTweenType LineSpacingCurve = 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 = 10f;
/// 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 InstantLineSpacing;
/// the value to move to in destination mode
[Tooltip("the value to move to in destination mode")]
[MMFEnumCondition("Mode", (int)Modes.ToDestination)]
public float DestinationLineSpacing;
protected override void FillTargets()
{
#if MM_UGUI2
if (TargetTMPText == null)
{
return;
}
/// 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 = 10f;
MMF_FeedbackBaseTarget target = new MMF_FeedbackBaseTarget();
MMPropertyReceiver receiver = new MMPropertyReceiver();
receiver.TargetObject = TargetTMPText.gameObject;
receiver.TargetComponent = TargetTMPText;
receiver.TargetPropertyName = "lineSpacing";
receiver.RelativeValue = RelativeValues;
target.Target = receiver;
target.LevelCurve = LineSpacingCurve;
target.RemapLevelZero = RemapZero;
target.RemapLevelOne = RemapOne;
target.InstantLevel = InstantLineSpacing;
target.ToDestinationLevel = DestinationLineSpacing;
/// 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;
_targets.Add(target);
#endif
}
protected override void FillTargets()
{
#if MM_UGUI2
if (TargetTMPText == null) return;
}
var target = new MMF_FeedbackBaseTarget();
var receiver = new MMPropertyReceiver();
receiver.TargetObject = TargetTMPText.gameObject;
receiver.TargetComponent = TargetTMPText;
receiver.TargetPropertyName = "lineSpacing";
receiver.RelativeValue = RelativeValues;
target.Target = receiver;
target.LevelCurve = LineSpacingCurve;
target.RemapLevelZero = RemapZero;
target.RemapLevelOne = RemapOne;
target.InstantLevel = InstantLineSpacing;
target.ToDestinationLevel = DestinationLineSpacing;
_targets.Add(target);
#endif
}
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor
{
get { return MMFeedbacksInspectorColors.TMPColor; }
}
public override string RequiresSetupText =>
"This feedback requires that a TargetTMPText be set to be able to work properly. You can set one below.";
#endif
#if UNITY_EDITOR && MM_UGUI2
public override bool EvaluateRequiresSetup()
{
return TargetTMPText == null;
}
public override string RequiredTargetText => TargetTMPText != null ? TargetTMPText.name : "";
#endif
#if MM_UGUI2
public override bool HasAutomatedTargetAcquisition => true;
public override bool CanForceInitialValue => true;
protected override void AutomateTargetAcquisition()
{
TargetTMPText = FindAutomatedTarget<TMP_Text>();
}
[MMFInspectorGroup("Target", true, 12, true)]
/// the TMP_Text component to control
[Tooltip("the TMP_Text component to control")]
public TMP_Text TargetTMPText;
#endif
}
}

View File

@@ -1,227 +1,237 @@
using UnityEngine;
using System.Collections;
using System.Collections;
using UnityEngine;
using UnityEngine.Scripting.APIUpdating;
#if MM_UGUI2
using TMPro;
#endif
using UnityEngine.Scripting.APIUpdating;
namespace MoreMountains.Feedbacks
{
/// <summary>
/// This feedback lets you control the color of a target TMP's outline over time
/// This feedback lets you control the color of a target TMP's outline over time
/// </summary>
[AddComponentMenu("")]
[FeedbackHelp("This feedback lets you control the color of a target TMP's outline over time.")]
#if MM_UGUI2
[FeedbackPath("TextMesh Pro/TMP Outline Color")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.TextMeshPro")]
public class MMF_TMPOutlineColor : MMF_Feedback
{
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.TMPColor; } }
public override string RequiresSetupText { get { return "This feedback requires that a TargetTMPText be set to be able to work properly. You can set one below."; } }
#endif
#if UNITY_EDITOR && MM_UGUI2
public override bool EvaluateRequiresSetup() { return (TargetTMPText == null); }
public override string RequiredTargetText { get { return TargetTMPText != null ? TargetTMPText.name : ""; } }
#endif
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
public enum ColorModes { Instant, Gradient, Interpolate }
[FeedbackHelp("This feedback lets you control the color of a target TMP's outline over time.")]
#if MM_UGUI2
[FeedbackPath("TextMesh Pro/TMP Outline Color")]
#endif
[MovedFrom(false, null, "MoreMountains.Feedbacks.TextMeshPro")]
public class MMF_TMPOutlineColor : MMF_Feedback
{
public enum ColorModes
{
Instant,
Gradient,
Interpolate
}
/// the duration of this feedback is the duration of the color transition, or 0 if instant
public override float FeedbackDuration { get { return (ColorMode == ColorModes.Instant) ? 0f : ApplyTimeMultiplier(Duration); } set { Duration = value; } }
/// a static bool used to disable all feedbacks of this type at once
public static bool FeedbackTypeAuthorized = true;
#if MM_UGUI2
public override bool HasAutomatedTargetAcquisition => true;
protected override void AutomateTargetAcquisition() => TargetTMPText = FindAutomatedTarget<TMP_Text>();
protected Coroutine _coroutine;
[MMFInspectorGroup("Target", true, 12, true)]
/// the TMP_Text component to control
[Tooltip("the TMP_Text component to control")]
public TMP_Text TargetTMPText;
#endif
protected Color _initialColor;
[MMFInspectorGroup("Outline Color", true, 16)]
/// the selected color mode :
/// None : nothing will happen,
/// gradient : evaluates the color over time on that gradient, from left to right,
/// interpolate : lerps from the current color to the destination one
[Tooltip("the selected color mode :" +
"None : nothing will happen," +
"gradient : evaluates the color over time on that gradient, from left to right," +
"interpolate : lerps from the current color to the destination one ")]
public ColorModes ColorMode = ColorModes.Interpolate;
/// how long the color of the text should change over time
[Tooltip("how long the color of the text should change over time")]
[MMFEnumCondition("ColorMode", (int)ColorModes.Interpolate, (int)ColorModes.Gradient)]
public float Duration = 0.2f;
/// the color to apply
[Tooltip("the color to apply")]
[MMFEnumCondition("ColorMode", (int)ColorModes.Instant)]
public Color32 InstantColor = Color.yellow;
/// the gradient to use to animate the color over time
[Tooltip("the gradient to use to animate the color over time")]
[MMFEnumCondition("ColorMode", (int)ColorModes.Gradient)]
[GradientUsage(true)]
public Gradient ColorGradient;
/// the destination color when in interpolate mode
[Tooltip("the destination color when in interpolate mode")]
[MMFEnumCondition("ColorMode", (int)ColorModes.Interpolate)]
public Color32 DestinationColor = Color.yellow;
/// the curve to use when interpolating towards the destination color
[Tooltip("the curve to use when interpolating towards the destination color")]
[MMFEnumCondition("ColorMode", (int)ColorModes.Interpolate)]
public AnimationCurve ColorCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// 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, 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;
protected Color _initialColor;
protected Coroutine _coroutine;
/// the curve to use when interpolating towards the destination color
[Tooltip("the curve to use when interpolating towards the destination color")]
[MMFEnumCondition("ColorMode", (int)ColorModes.Interpolate)]
public AnimationCurve ColorCurve = new(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
/// <summary>
/// On init we store our initial outline color
/// </summary>
/// <param name="owner"></param>
protected override void CustomInitialization(MMF_Player owner)
{
base.CustomInitialization(owner);
/// the gradient to use to animate the color over time
[Tooltip("the gradient to use to animate the color over time")]
[MMFEnumCondition("ColorMode", (int)ColorModes.Gradient)]
[GradientUsage(true)]
public Gradient ColorGradient;
#if MM_UGUI2
if (TargetTMPText == null)
{
return;
}
_initialColor = TargetTMPText.outlineColor;
#endif
}
[MMFInspectorGroup("Outline Color", true, 16)]
/// the selected color mode :
/// None : nothing will happen,
/// gradient : evaluates the color over time on that gradient, from left to right,
/// interpolate : lerps from the current color to the destination one
[Tooltip("the selected color mode :" +
"None : nothing will happen," +
"gradient : evaluates the color over time on that gradient, from left to right," +
"interpolate : lerps from the current color to the destination one ")]
public ColorModes ColorMode = ColorModes.Interpolate;
/// <summary>
/// On Play we change our text's outline's color
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized)
{
return;
}
#if MM_UGUI2
if (TargetTMPText == null)
{
return;
}
switch (ColorMode)
{
case ColorModes.Instant:
TargetTMPText.outlineColor = NormalPlayDirection ? InstantColor : _initialColor;
break;
case ColorModes.Gradient:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
_coroutine = Owner.StartCoroutine(ChangeColor());
break;
case ColorModes.Interpolate:
if (!AllowAdditivePlays && (_coroutine != null))
{
return;
}
if (_coroutine != null) { Owner.StopCoroutine(_coroutine); }
_coroutine = Owner.StartCoroutine(ChangeColor());
break;
}
#endif
}
/// the destination color when in interpolate mode
[Tooltip("the destination color when in interpolate mode")]
[MMFEnumCondition("ColorMode", (int)ColorModes.Interpolate)]
public Color32 DestinationColor = Color.yellow;
/// <summary>
/// Changes the color of the text's outline over time
/// </summary>
/// <returns></returns>
protected virtual IEnumerator ChangeColor()
{
IsPlaying = true;
float journey = NormalPlayDirection ? 0f : FeedbackDuration;
while ((journey >= 0) && (journey <= FeedbackDuration) && (FeedbackDuration > 0))
{
float remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
/// how long the color of the text should change over time
[Tooltip("how long the color of the text should change over time")]
[MMFEnumCondition("ColorMode", (int)ColorModes.Interpolate, (int)ColorModes.Gradient)]
public float Duration = 0.2f;
SetColor(remappedTime);
/// the color to apply
[Tooltip("the color to apply")] [MMFEnumCondition("ColorMode", (int)ColorModes.Instant)]
public Color32 InstantColor = Color.yellow;
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
yield return null;
}
SetColor(FinalNormalizedTime);
_coroutine = null;
IsPlaying = false;
yield break;
}
/// the duration of this feedback is the duration of the color transition, or 0 if instant
public override float FeedbackDuration
{
get => ColorMode == ColorModes.Instant ? 0f : ApplyTimeMultiplier(Duration);
set => Duration = value;
}
/// <summary>
/// Applies the color change
/// </summary>
/// <param name="time"></param>
protected virtual void SetColor(float time)
{
#if MM_UGUI2
if (ColorMode == ColorModes.Gradient)
{
// we set our object inactive then active, otherwise for some reason outline color isn't applied.
TargetTMPText.gameObject.SetActive(false);
TargetTMPText.outlineColor = ColorGradient.Evaluate(time);
TargetTMPText.gameObject.SetActive(true);
}
else if (ColorMode == ColorModes.Interpolate)
{
float factor = ColorCurve.Evaluate(time);
TargetTMPText.gameObject.SetActive(false);
TargetTMPText.outlineColor = Color.LerpUnclamped(_initialColor, DestinationColor, factor);
TargetTMPText.gameObject.SetActive(true);
}
#endif
}
/// <summary>
/// On init we store our initial outline color
/// </summary>
/// <param name="owner"></param>
protected override void CustomInitialization(MMF_Player owner)
{
base.CustomInitialization(owner);
/// <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);
IsPlaying = false;
if (_coroutine != null)
{
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;
}
#if MM_UGUI2
TargetTMPText.gameObject.SetActive(false);
TargetTMPText.outlineColor = _initialColor;
TargetTMPText.gameObject.SetActive(true);
#endif
}
}
#if MM_UGUI2
if (TargetTMPText == null) return;
_initialColor = TargetTMPText.outlineColor;
#endif
}
/// <summary>
/// On Play we change our text's outline's color
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized) return;
#if MM_UGUI2
if (TargetTMPText == null) return;
switch (ColorMode)
{
case ColorModes.Instant:
TargetTMPText.outlineColor = NormalPlayDirection ? InstantColor : _initialColor;
break;
case ColorModes.Gradient:
if (!AllowAdditivePlays && _coroutine != null) return;
if (_coroutine != null) Owner.StopCoroutine(_coroutine);
_coroutine = Owner.StartCoroutine(ChangeColor());
break;
case ColorModes.Interpolate:
if (!AllowAdditivePlays && _coroutine != null) return;
if (_coroutine != null) Owner.StopCoroutine(_coroutine);
_coroutine = Owner.StartCoroutine(ChangeColor());
break;
}
#endif
}
/// <summary>
/// Changes the color of the text's outline over time
/// </summary>
/// <returns></returns>
protected virtual IEnumerator ChangeColor()
{
IsPlaying = true;
var journey = NormalPlayDirection ? 0f : FeedbackDuration;
while (journey >= 0 && journey <= FeedbackDuration && FeedbackDuration > 0)
{
var remappedTime = MMFeedbacksHelpers.Remap(journey, 0f, FeedbackDuration, 0f, 1f);
SetColor(remappedTime);
journey += NormalPlayDirection ? FeedbackDeltaTime : -FeedbackDeltaTime;
yield return null;
}
SetColor(FinalNormalizedTime);
_coroutine = null;
IsPlaying = false;
yield break;
}
/// <summary>
/// Applies the color change
/// </summary>
/// <param name="time"></param>
protected virtual void SetColor(float time)
{
#if MM_UGUI2
if (ColorMode == ColorModes.Gradient)
{
// we set our object inactive then active, otherwise for some reason outline color isn't applied.
TargetTMPText.gameObject.SetActive(false);
TargetTMPText.outlineColor = ColorGradient.Evaluate(time);
TargetTMPText.gameObject.SetActive(true);
}
else if (ColorMode == ColorModes.Interpolate)
{
var factor = ColorCurve.Evaluate(time);
TargetTMPText.gameObject.SetActive(false);
TargetTMPText.outlineColor = Color.LerpUnclamped(_initialColor, DestinationColor, factor);
TargetTMPText.gameObject.SetActive(true);
}
#endif
}
/// <summary>
/// Stops the animation if needed
/// </summary>
/// <param name="position"></param>
/// <param name="feedbacksIntensity"></param>
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
{
if (!Active || !FeedbackTypeAuthorized) return;
base.CustomStopFeedback(position, feedbacksIntensity);
IsPlaying = false;
if (_coroutine != null)
{
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;
#if MM_UGUI2
TargetTMPText.gameObject.SetActive(false);
TargetTMPText.outlineColor = _initialColor;
TargetTMPText.gameObject.SetActive(true);
#endif
}
/// sets the inspector color for this feedback
#if UNITY_EDITOR
public override Color FeedbackColor
{
get { return MMFeedbacksInspectorColors.TMPColor; }
}
public override string RequiresSetupText =>
"This feedback requires that a TargetTMPText be set to be able to work properly. You can set one below.";
#endif
#if UNITY_EDITOR && MM_UGUI2
public override bool EvaluateRequiresSetup()
{
return TargetTMPText == null;
}
public override string RequiredTargetText => TargetTMPText != null ? TargetTMPText.name : "";
#endif
#if MM_UGUI2
public override bool HasAutomatedTargetAcquisition => true;
protected override void AutomateTargetAcquisition()
{
TargetTMPText = FindAutomatedTarget<TMP_Text>();
}
[MMFInspectorGroup("Target", true, 12, true)]
/// the TMP_Text component to control
[Tooltip("the TMP_Text component to control")]
public TMP_Text TargetTMPText;
#endif
}
}

View File

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