Insanely huge initial commit

This commit is contained in:
2026-02-21 17:04:05 -08:00
parent 9cdd36191a
commit 613d75914a
22525 changed files with 4035207 additions and 0 deletions

View File

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

View File

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

View File

@@ -0,0 +1,43 @@
namespace Febucci.UI.Core
{
/// <summary>
/// Base class for all appearance effects. <br/>
/// Inherit from this class if you want to create your own Appearance Effect in C#.
/// </summary>
public abstract class AppearanceBase : EffectsBase
{
public float effectDuration = .3f;
[System.Obsolete("This variable will be removed from next versions. Please use 'effectDuration' instead")]
protected float showDuration => effectDuration;
/// <summary>
/// Initializes the effect's default values. It is called before the effect is applied to letters.
/// </summary>
/// <remarks>
/// Use this to assign values to your effect.
/// </remarks>
/// <example>
/// <code>
/// effectDuration = data.defaults.sizeDuration;
/// amplitude = data.defaults.sizeAmplitude;
/// </code>
/// </example>
/// <param name="data"></param>
public abstract void SetDefaultValues(AppearanceDefaultValues data);
public virtual bool CanShowAppearanceOn(float timePassed)
{
return timePassed <= effectDuration;
}
public override void SetModifier(string modifierName, string modifierValue)
{
switch (modifierName)
{
//duration
case "d": ApplyModifierTo(ref effectDuration, modifierValue); break;
}
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,57 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.ap_DiagExp)]
class DiagonalExpandAppearance : AppearanceBase
{
int targetA;
int targetB;
//--Temp variables--
Vector3 middlePos;
float pct;
public override void SetDefaultValues(AppearanceDefaultValues data)
{
effectDuration = data.defaults.diagonalExpandDuration;
SetOrientation(data.defaults.diagonalFromBttmLeft);
}
void SetOrientation(bool btmLeft)
{
if (btmLeft) //expands bottom left and top right
{
targetA = 0;
targetB = 2;
}
else //expands bottom right and top left
{
targetA = 1;
targetB = 3;
}
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
middlePos = data.vertices.GetMiddlePos();
pct = Tween.EaseInOut(data.passedTime / effectDuration);
data.vertices[targetA] = Vector3.LerpUnclamped(middlePos, data.vertices[targetA], pct);
//top right copies from bottom right
data.vertices[targetB] = Vector3.LerpUnclamped(middlePos, data.vertices[targetB], pct);
}
public override void SetModifier(string modifierName, string modifierValue)
{
base.SetModifier(modifierName, modifierValue);
switch (modifierName)
{
case "bot": SetOrientation(modifierValue == "1"); break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,31 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.ap_Fade)]
class FadeAppearance : AppearanceBase
{
public override void SetDefaultValues(AppearanceDefaultValues data)
{
effectDuration = data.defaults.fadeDuration;
}
Color32 temp;
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
//from transparent to real color
for (int i = 0; i < TextUtilities.verticesPerChar; i++)
{
temp = data.colors[i];
temp.a = 0;
data.colors[i] = Color32.LerpUnclamped(data.colors[i], temp,
Tween.EaseInOut(1 - (data.passedTime / effectDuration)));
}
}
}
}

View File

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

View File

@@ -0,0 +1,94 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.ap_HoriExp)]
class HorizontalExpandAppearance : AppearanceBase
{
//expand type
public enum ExpType
{
Left, //from left to right
Middle, //expands from the middle to te extents
Right //from right to left
}
ExpType type = ExpType.Left;
//--Temp variables--
Vector2 startTop;
Vector2 startBot;
float pct;
public override void SetDefaultValues(AppearanceDefaultValues data)
{
effectDuration = data.defaults.horizontalExpandDuration;
type = data.defaults.horizontalExpandStart;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
pct = Tween.EaseInOut(data.passedTime / effectDuration);
switch (type)
{
default:
case ExpType.Left:
//top left and bot left
startTop = data.vertices[1];
startBot = data.vertices[0];
data.vertices[2] = Vector3.LerpUnclamped(startTop, data.vertices[2], pct);
data.vertices[3] = Vector3.LerpUnclamped(startBot, data.vertices[3], pct);
break;
case ExpType.Right:
//top right and bot right
startTop = data.vertices[2];
startBot = data.vertices[3];
data.vertices[1] = Vector3.LerpUnclamped(startTop, data.vertices[1], pct);
data.vertices[0] = Vector3.LerpUnclamped(startBot, data.vertices[0], pct);
break;
case ExpType.Middle:
//Middle positions
startTop = (data.vertices[1] + data.vertices[2]) / 2;
startBot = (data.vertices[0] + data.vertices[3]) / 2;
//top vertices
data.vertices[1] = Vector3.LerpUnclamped(startTop, data.vertices[1], pct);
data.vertices[2] = Vector3.LerpUnclamped(startTop, data.vertices[2], pct);
//bottom vertices
data.vertices[0] = Vector3.LerpUnclamped(startBot, data.vertices[0], pct);
data.vertices[3] = Vector3.LerpUnclamped(startBot, data.vertices[3], pct);
break;
}
}
public override void SetModifier(string modifierName, string modifierValue)
{
base.SetModifier(modifierName, modifierValue);
switch (modifierName)
{
case "x":
switch (modifierValue)
{
case "-1": type = ExpType.Left; break;
case "0": type = ExpType.Middle; break;
case "1": type = ExpType.Right; break;
default: Debug.LogError($"Text Animator: you set an '{modifierName}' modifier with value '{modifierValue}' for the HorizontalExpandAppearance effect, but it can only be '-1', '0', or '1'"); break;
}
break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,36 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.ap_Offset)]
class OffsetAppearance : AppearanceBase
{
float amount;
Vector2 direction;
public override void SetDefaultValues(AppearanceDefaultValues data)
{
direction = data.defaults.offsetDir;
amount = data.defaults.offsetAmplitude * uniformIntensity;
effectDuration = data.defaults.offsetDuration;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
//Moves all towards a direction
data.vertices.MoveChar(direction * amount * Tween.EaseIn(1 - data.passedTime / effectDuration));
}
public override void SetModifier(string modifierName, string modifierValue)
{
base.SetModifier(modifierName, modifierValue);
switch (modifierName)
{
case "a": ApplyModifierTo(ref amount, modifierValue); break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,49 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.ap_RandomDir)]
class RandomDirectionAppearance : AppearanceBase
{
float amount;
Vector3[] directions;
public override void Initialize(int charactersCount)
{
base.Initialize(charactersCount);
directions = new Vector3[charactersCount];
//Calculates a random direction for each character (which won't change)
for(int i = 0; i < charactersCount; i++)
{
directions[i] = TextUtilities.fakeRandoms[Random.Range(0, TextUtilities.fakeRandomsCount - 1)] * Mathf.Sign(Mathf.Sin(i));
}
}
public override void SetDefaultValues(AppearanceDefaultValues data)
{
amount = data.defaults.randomDirAmplitude;
effectDuration = data.defaults.randomDirDuration;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
//Moves all towards a direction
data.vertices.MoveChar(directions[charIndex] * amount * uniformIntensity * Tween.EaseIn(1 - data.passedTime / effectDuration));
}
public override void SetModifier(string modifierName, string modifierValue)
{
base.SetModifier(modifierName, modifierValue);
switch (modifierName)
{
case "a": ApplyModifierTo(ref amount, modifierValue); break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,40 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.ap_Rot)]
class RotatingAppearance : AppearanceBase
{
float targetAngle;
public override void SetDefaultValues(AppearanceDefaultValues data)
{
effectDuration = data.defaults.rotationDuration;
targetAngle = data.defaults.rotationStartAngle;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
data.vertices.RotateChar(
Mathf.Lerp(
targetAngle,
0,
Tween.EaseInOut(data.passedTime / effectDuration)
)
);
}
public override void SetModifier(string modifierName, string modifierValue)
{
base.SetModifier(modifierName, modifierValue);
switch (modifierName)
{
case "a": ApplyModifierTo(ref targetAngle, modifierValue); break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,31 @@
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.ap_Size)]
class SizeAppearance : AppearanceBase
{
float amplitude;
public override void SetDefaultValues(AppearanceDefaultValues data)
{
effectDuration = data.defaults.sizeDuration;
amplitude = data.defaults.sizeAmplitude * -1 + 1;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
data.vertices.LerpUnclamped(
data.vertices.GetMiddlePos(),
Tween.EaseIn(1 - (data.passedTime / effectDuration)) * amplitude
);
}
public override void SetModifier(string modifierName, string modifierValue)
{
base.SetModifier(modifierName, modifierValue);
switch (modifierName)
{
case "a": ApplyModifierTo(ref amplitude, modifierValue); break;
}
}
}
}

View File

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

View File

@@ -0,0 +1,66 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.ap_VertExp)]
class VerticalExpandAppearance : AppearanceBase
{
int startA, targetA;
int startB, targetB;
//--Temp variables--
float pct;
public override void SetDefaultValues(AppearanceDefaultValues data)
{
effectDuration = data.defaults.verticalExpandDuration;
SetOrientation(data.defaults.verticalFromBottom);
}
void SetOrientation(bool fromBottom)
{
if (fromBottom) //From bottom to top
{
//top left copies bottom left
startA = 0;
targetA = 1;
//top right copies bottom right
startB = 3;
targetB = 2;
}
else //from top to bottom
{
//bottom left copies top left
startA = 1;
targetA = 0;
//bottom right copies top right
startB = 2;
targetB = 3;
}
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
pct = Tween.EaseInOut(data.passedTime / effectDuration);
data.vertices[targetA] = Vector3.LerpUnclamped(data.vertices[startA], data.vertices[targetA], pct);
data.vertices[targetB] = Vector3.LerpUnclamped(data.vertices[startB], data.vertices[targetB], pct);
}
public override void SetModifier(string modifierName, string modifierValue)
{
base.SetModifier(modifierName, modifierValue);
switch (modifierName)
{
case "bot": SetOrientation(modifierValue == "1"); break;
}
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,206 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: "")]
class PresetAppearance : AppearanceBase
{
bool enabled;
//management
Matrix4x4 matrix;
Vector3 offset;
Quaternion rotationQua;
bool hasTransformEffects;
ThreeAxisEffector movement;
ThreeAxisEffector rotation;
TwoAxisEffector scale;
bool setColor;
Color32 color;
ColorCurve colorCurve;
public override void SetDefaultValues(AppearanceDefaultValues data)
{
effectDuration = 0;
enabled = false;
void AssignValues(PresetAppearanceValues result)
{
enabled = SetPreset(
true,
result,
ref movement,
ref effectDuration,
ref rotation,
ref scale,
ref rotationQua,
ref hasTransformEffects,
ref setColor,
ref colorCurve);
}
PresetAppearanceValues values;
//searches for local presets first, which override global presets
if (TAnimBuilder.GetPresetFromArray(effectTag, data.presets, out values))
{
AssignValues(values);
return;
}
//global presets
if (TAnimBuilder.TryGetGlobalPresetAppearance(effectTag, out values))
{
AssignValues(values);
return;
}
}
#region Effector classes
internal abstract class Effector
{
protected abstract Vector3 _EvaluateEffect(float passedTime, int charInde);
public Vector3 EvaluateEffect(float passedTime, int charIndex)
{
return _EvaluateEffect(passedTime, charIndex);
}
}
internal sealed class ThreeAxisEffector : Effector
{
EffectEvaluator x;
EffectEvaluator y;
EffectEvaluator z;
public ThreeAxisEffector(EffectEvaluator x, EffectEvaluator y, EffectEvaluator z)
{
this.x = x;
this.y = y;
this.z = z;
}
protected override Vector3 _EvaluateEffect(float passedTime, int charIndex)
{
return new Vector3(
x.Evaluate(passedTime, charIndex),
y.Evaluate(passedTime, charIndex),
z.Evaluate(passedTime, charIndex)
);
}
}
internal sealed class TwoAxisEffector : Effector
{
EffectEvaluator x;
EffectEvaluator y;
public TwoAxisEffector(EffectEvaluator x, EffectEvaluator y)
{
this.x = x;
this.y = y;
}
protected override Vector3 _EvaluateEffect(float passedTime, int charIndex)
{
return new Vector3(
x.Evaluate(passedTime, charIndex),
y.Evaluate(passedTime, charIndex),
1
);
}
}
#endregion
public static bool SetPreset<T>(
bool isAppearance,
T values,
ref ThreeAxisEffector movement,
ref float showDuration,
ref ThreeAxisEffector rotation,
ref TwoAxisEffector scale,
ref Quaternion rotationQua,
ref bool hasTransformEffects,
ref bool setColor,
ref ColorCurve colorCurve
) where T : PresetBaseValues
{
values.Initialize(isAppearance);
showDuration = values.GetMaxDuration();
movement = new ThreeAxisEffector(
values.movementX,
values.movementY,
values.movementZ);
scale = new TwoAxisEffector(
values.scaleX,
values.scaleY
);
rotation = new ThreeAxisEffector(
values.rotX,
values.rotY,
values.rotZ
);
rotationQua = Quaternion.identity;
hasTransformEffects = values.movementX.enabled || values.movementY.enabled || values.movementZ.enabled
|| values.rotX.enabled || values.rotY.enabled || values.rotZ.enabled
|| values.scaleX.enabled || values.scaleY.enabled;
setColor = values.color.enabled;
if (setColor)
{
colorCurve = values.color;
colorCurve.Initialize(isAppearance);
}
return hasTransformEffects || setColor;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
if (!enabled)
return;
if (hasTransformEffects)
{
offset = (data.vertices[0] + data.vertices[2]) / 2f;
rotationQua.eulerAngles = rotation.EvaluateEffect(data.passedTime, charIndex);
matrix.SetTRS(
movement.EvaluateEffect(data.passedTime, charIndex) * uniformIntensity,
rotationQua,
scale.EvaluateEffect(data.passedTime, charIndex));
for (byte i = 0; i < data.vertices.Length; i++)
{
data.vertices[i] -= offset;
data.vertices[i] = matrix.MultiplyPoint3x4(data.vertices[i]);
data.vertices[i] += offset;
}
}
if (setColor)
{
color = colorCurve.GetColor(data.passedTime, charIndex);
data.colors.LerpUnclamped(color, 1 - data.passedTime / effectDuration);
}
}
}
}

View File

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

View File

@@ -0,0 +1,13 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[System.Serializable]
internal class PresetAppearanceValues : PresetBaseValues
{
public PresetAppearanceValues() : base()
{
}
}
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,27 @@
namespace Febucci.UI.Core
{
/// <summary>
/// Base class for all behavior effects.<br/>
/// Inherit from this class if you want to create your own Behavior Effect in C#.
/// </summary>
public abstract class BehaviorBase : EffectsBase
{
public abstract void SetDefaultValues(BehaviorDefaultValues data);
[System.Obsolete("This variable will be removed from next versions. Please use 'time.timeSinceStart' instead")]
public float animatorTime => time.timeSinceStart;
[System.Obsolete("This variable will be removed from next versions. Please use 'time.deltaTime' instead")]
public float animatorDeltaTime => time.deltaTime;
/// <summary>
/// Contains data/settings from the TextAnimator component that is linked to (and managing) this effect.
/// </summary>
public TextAnimator.TimeData time { get; private set; }
internal void SetAnimatorData(in TextAnimator.TimeData time)
{
this.time = time;
}
}
}

View File

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

View File

@@ -0,0 +1,39 @@
using UnityEngine;
namespace Febucci.UI.Core
{
/// <summary>
/// Behavior helper class that automatically manages the following modifiers: (a = <see cref="amplitude"/>), (f = <see cref="frequency"/>) and (w = <see cref="waveSize"/>).<br/><br/>
/// You can inerith from this class and use the modifiers as you prefer in your effects, without having to set up them inside the <see cref="SetModifier(string, string)"/> method.
/// </summary>
/// <example>
/// All the TextAnimator effects that have 3 modifiers inerith from this class. You can check their source code to see how they are set up, example: <see cref="WiggleBehavior"/> or <see cref="WaveBehavior"/>
/// </example>
public abstract class BehaviorSine : BehaviorBase
{
protected float amplitude = 1;
protected float frequency = 1;
protected float waveSize = .08f;
public override void SetModifier(string modifierName, string modifierValue)
{
switch (modifierName)
{
//amplitude
case "a": ApplyModifierTo(ref amplitude, modifierValue); break;
//frequency
case "f": ApplyModifierTo(ref frequency, modifierValue); break;
//wave size
case "w": ApplyModifierTo(ref waveSize, modifierValue); break;
}
}
public override string ToString()
{
return $"freq: {frequency}\n" +
$"ampl: {amplitude}\n" +
$"waveSize: {waveSize}" +
$"\n{base.ToString()}";
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,41 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Bounce)]
class BounceBehavior : BehaviorSine
{
public override void SetDefaultValues(BehaviorDefaultValues data)
{
amplitude = data.defaults.bounceAmplitude;
frequency = data.defaults.bounceFrequency;
waveSize = data.defaults.bounceWaveSize;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
//Calculates the tween percentage
float BounceTween(float t)
{
const float stillTime = .2f;
const float easeIn = .2f;
const float bounce = 1 - stillTime - easeIn;
if (t <= easeIn)
return Tween.EaseInOut(t / easeIn);
t -= easeIn;
if (t <= bounce)
return 1 - Tween.BounceOut(t / bounce);
return 0;
}
data.vertices.MoveChar(Vector3.up * uniformIntensity * BounceTween((Mathf.Repeat(time.timeSinceStart * frequency - waveSize * charIndex, 1))) * amplitude);
}
}
}

View File

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

View File

@@ -0,0 +1,43 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Dangle)]
class DangleBehavior : BehaviorSine
{
float sin;
int targetIndex1;
int targetIndex2;
public override void SetDefaultValues(BehaviorDefaultValues data)
{
amplitude = data.defaults.dangleAmplitude;
frequency = data.defaults.dangleFrequency;
waveSize = data.defaults.dangleWaveSize;
//bottom
if (data.defaults.dangleAnchorBottom)
{
targetIndex1 = 1;
targetIndex2 = 2;
}
else
{
targetIndex1 = 0;
targetIndex2 = 3;
}
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
sin = Mathf.Sin(frequency * time.timeSinceStart + charIndex * waveSize) * amplitude * uniformIntensity;
//moves one side (top or bottom) torwards one direction
data.vertices[targetIndex1] += Vector3.right * sin;
data.vertices[targetIndex2] += Vector3.right * sin;
}
}
}

View File

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

View File

@@ -0,0 +1,75 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Fade)]
class FadeBehavior : BehaviorBase
{
float delay = .3f;
float[] charPCTs;
public override void SetDefaultValues(BehaviorDefaultValues data)
{
delay = data.defaults.fadeDelay;
}
public override void Initialize(int charactersCount)
{
base.Initialize(charactersCount);
charPCTs = new float[charactersCount];
}
public override void SetModifier(string modifierName, string modifierValue)
{
switch (modifierName)
{
//delay
case "d": ApplyModifierTo(ref delay, modifierValue); break;
}
}
Color32 temp;
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
if (data.passedTime <= delay) //not passed enough time yet
return;
charPCTs[charIndex] += time.deltaTime;
if (charPCTs[charIndex] > 1) charPCTs [charIndex] = 1;
//Lerps
if (charPCTs[charIndex] < 1 && charPCTs[charIndex] >= 0)
{
for (var i = 0; i < TextUtilities.verticesPerChar; i++)
{
temp = data.colors[i];
temp.a = 0;
data.colors[i] = Color32.LerpUnclamped(data.colors[i], temp, Tween.EaseInOut(charPCTs[charIndex]));
}
}
else //Keeps them hidden
{
for (var i = 0; i < TextUtilities.verticesPerChar; i++)
{
temp = data.colors[i];
temp.a = 0;
data.colors[i] = temp;
}
}
}
public override string ToString()
{
return $"delay: {delay}\n" +
$"\n{ base.ToString()}";
}
}
}

View File

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

View File

@@ -0,0 +1,41 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Pendulum)]
class PendulumBehavior : BehaviorSine
{
int targetVertex1;
int targetVertex2;
public override void SetDefaultValues(BehaviorDefaultValues data)
{
frequency = data.defaults.pendFrequency;
amplitude = data.defaults.pendAmplitude;
waveSize = data.defaults.pendWaveSize;
if (data.defaults.pendInverted)
{
//anchored at the bottom
targetVertex1 = 0;
targetVertex2 = 3;
}
else
{
//anchored at the top
targetVertex1 = 1;
targetVertex2 = 2;
}
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
data.vertices.RotateChar(
Mathf.Sin(-time.timeSinceStart * frequency + waveSize * charIndex) * amplitude,
(data.vertices[targetVertex1] + data.vertices[targetVertex2]) / 2 //bottom center as their rotation pivot
);
}
}
}

View File

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

View File

@@ -0,0 +1,50 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Rainb)]
class RainbowBehavior : BehaviorBase
{
float hueShiftSpeed = 0.8f;
float hueShiftWaveSize = 0.08f;
public override void SetDefaultValues(BehaviorDefaultValues data)
{
hueShiftSpeed = data.defaults.hueShiftSpeed;
hueShiftWaveSize = data.defaults.hueShiftWaveSize;
}
public override void SetModifier(string modifierName, string modifierValue)
{
switch (modifierName)
{
//frequency
case "f": ApplyModifierTo(ref hueShiftSpeed, modifierValue); break;
//wave size
case "s": ApplyModifierTo(ref hueShiftWaveSize, modifierValue); break;
}
}
Color32 temp;
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
for (byte i = 0; i < TextUtilities.verticesPerChar; i++)
{
//shifts hue
temp = Color.HSVToRGB(Mathf.PingPong(time.timeSinceStart * hueShiftSpeed + charIndex * hueShiftWaveSize, 1), 1, 1);
temp.a = data.colors[i].a; //preserves original alpha
data.colors[i] = temp;
}
}
public override string ToString()
{
return $"hueShiftSpeed: {hueShiftSpeed}\n" +
$"hueShiftWaveSize: {hueShiftWaveSize}" +
$"\n{base.ToString()}";
}
}
}

View File

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

View File

@@ -0,0 +1,43 @@
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Rot)]
class RotationBehavior : BehaviorBase
{
float angleSpeed = 180;
float angleDiffBetweenChars = 10;
public override void SetDefaultValues(BehaviorDefaultValues data)
{
angleSpeed = data.defaults.angleSpeed;
angleDiffBetweenChars = data.defaults.angleDiffBetweenChars;
}
public override void SetModifier(string modifierName, string modifierValue)
{
switch (modifierName)
{
//frequency
case "f": ApplyModifierTo(ref angleSpeed, modifierValue); break;
//angle diff
case "s": ApplyModifierTo(ref angleDiffBetweenChars, modifierValue); break;
}
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
data.vertices.RotateChar(-time.timeSinceStart * angleSpeed + angleDiffBetweenChars * charIndex);
}
public override string ToString()
{
return $"angleSpeed: {angleSpeed}\n" +
$"angleDiffBetweenChars: {angleDiffBetweenChars}" +
$"\n{base.ToString()}";
}
}
}

View File

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

View File

@@ -0,0 +1,92 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Shake)]
class ShakeBehavior : BehaviorBase
{
public float shakeStrength;
public float shakeDelay;
float timePassed;
int randIndex;
public override void SetDefaultValues(BehaviorDefaultValues data)
{
shakeDelay = data.defaults.shakeDelay;
shakeStrength = data.defaults.shakeStrength;
ClampValues();
}
void ClampValues()
{
shakeDelay = Mathf.Clamp(shakeDelay, 0.002f, 500);
}
public override void Initialize(int charactersCount)
{
base.Initialize(charactersCount);
randIndex = Random.Range(0, TextUtilities.fakeRandomsCount);
lastRandomIndex = randIndex;
}
public override void SetModifier(string modifierName, string modifierValue)
{
switch (modifierName)
{
//amplitude
case "a": ApplyModifierTo(ref shakeStrength, modifierValue); break;
//delay
case "d": ApplyModifierTo(ref shakeDelay, modifierValue); break;
}
ClampValues();
}
int lastRandomIndex;
public override void Calculate()
{
timePassed += time.deltaTime;
//Changes the shake direction if enough time passed
if (timePassed >= shakeDelay)
{
timePassed = 0;
randIndex = Random.Range(0, TextUtilities.fakeRandomsCount);
//Avoids repeating the same index twice
if (lastRandomIndex == randIndex)
{
randIndex++;
if (randIndex >= TextUtilities.fakeRandomsCount)
randIndex = 0;
}
lastRandomIndex = randIndex;
}
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
data.vertices.MoveChar
(
TextUtilities.fakeRandoms[
Mathf.RoundToInt((charIndex + randIndex) % (TextUtilities.fakeRandomsCount - 1))
] * shakeStrength * uniformIntensity
);
}
public override string ToString()
{
return $"shake delay: {shakeDelay}\n" +
$"strength: {shakeStrength}" +
$"\n{ base.ToString()}";
}
}
}

View File

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

View File

@@ -0,0 +1,23 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Incr)]
sealed class SizeBehavior : BehaviorSine
{
public override void SetDefaultValues(BehaviorDefaultValues data)
{
amplitude = data.defaults.sizeAmplitude * -1 + 1;
frequency = data.defaults.sizeFrequency;
waveSize = data.defaults.sizeWaveSize;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
data.vertices.LerpUnclamped(
data.vertices.GetMiddlePos(),
(Mathf.Cos(time.timeSinceStart* frequency + charIndex * waveSize) + 1) / 2f * amplitude);
}
}
}

View File

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

View File

@@ -0,0 +1,30 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Slide)]
class SlideBehavior : BehaviorSine
{
float sin;
public override void SetDefaultValues(BehaviorDefaultValues data)
{
amplitude = data.defaults.slideAmplitude;
frequency = data.defaults.slideFrequency;
waveSize = data.defaults.slideWaveSize;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
sin = Mathf.Sin(frequency * time.timeSinceStart + charIndex * waveSize) * amplitude * uniformIntensity;
//bottom, torwards one direction
data.vertices[0] += Vector3.right * sin;
data.vertices[3] += Vector3.right * sin;
//top, torwards the opposite dir
data.vertices[1] += Vector3.right * -sin;
data.vertices[2] += Vector3.right * -sin;
}
}
}

View File

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

View File

@@ -0,0 +1,22 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Swing)]
class SwingBehavior : BehaviorSine
{
public override void SetDefaultValues(BehaviorDefaultValues data)
{
amplitude = data.defaults.swingAmplitude;
frequency = data.defaults.swingFrequency;
waveSize = data.defaults.swingWaveSize;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
data.vertices.RotateChar(Mathf.Cos(time.timeSinceStart * frequency + charIndex * waveSize) * amplitude);
}
}
}

View File

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

View File

@@ -0,0 +1,23 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Wave)]
class WaveBehavior : BehaviorSine
{
public override void SetDefaultValues(BehaviorDefaultValues data)
{
amplitude = data.defaults.waveAmplitude;
frequency = data.defaults.waveFrequency;
waveSize = data.defaults.waveWaveSize;
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
data.vertices.MoveChar(Vector3.up * Mathf.Sin(time.timeSinceStart * frequency + charIndex * waveSize) * amplitude * uniformIntensity);
}
}
}

View File

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

View File

@@ -0,0 +1,59 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: TAnimTags.bh_Wiggle)]
class WiggleBehavior : BehaviorBase
{
float amplitude = 0.15f;
float frequency = 7.67f;
Vector3[] directions;
public override void SetDefaultValues(BehaviorDefaultValues data)
{
amplitude = data.defaults.wiggleAmplitude;
frequency = data.defaults.wiggleFrequency;
}
public override void Initialize(int charactersCount)
{
base.Initialize(charactersCount);
directions = new Vector3[charactersCount];
//Calculates a random direction for each character (which won't change)
for(int i = 0; i < charactersCount; i++)
{
directions[i] = TextUtilities.fakeRandoms[Random.Range(0, TextUtilities.fakeRandomsCount - 1)] * Mathf.Sign(Mathf.Sin(i));
}
}
public override void SetModifier(string modifierName, string modifierValue)
{
switch (modifierName)
{
//amplitude
case "a": ApplyModifierTo(ref amplitude, modifierValue); break;
//frequency
case "f": ApplyModifierTo(ref frequency, modifierValue); break;
}
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
data.vertices.MoveChar(directions[charIndex] * Mathf.Sin(time.timeSinceStart* frequency + charIndex) * amplitude * uniformIntensity);
}
public override string ToString()
{
return $"freq: {frequency}\n" +
$"ampl: {amplitude}" +
$"\n{ base.ToString()}";
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,149 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[UnityEngine.Scripting.Preserve]
[EffectInfo(tag: "")]
class PresetBehavior : BehaviorBase
{
bool enabled;
//modifiers
float timeSpeed;
float weightMult;
//management
Matrix4x4 matrix;
Vector3 offset;
Quaternion rotationQua;
float uniformEffectTime;
bool hasTransformEffects;
bool isOnOneCharacter;
float weight = 1;
EmissionControl emissionControl;
PresetAppearance.ThreeAxisEffector movement;
PresetAppearance.ThreeAxisEffector rotation;
PresetAppearance.TwoAxisEffector scale;
bool setColor;
Color32 color;
ColorCurve colorCurve;
public override void SetDefaultValues(BehaviorDefaultValues data)
{
weightMult = 1;
timeSpeed = 1;
uniformEffectTime = 0;
weight = 0;
isOnOneCharacter = false;
enabled = false;
void AssignValues(PresetBehaviorValues result)
{
float showDuration = 0;
emissionControl = result.emission;
enabled = PresetAppearance.SetPreset(
false,
result,
ref movement,
ref showDuration,
ref rotation,
ref scale,
ref rotationQua,
ref hasTransformEffects,
ref setColor,
ref colorCurve);
emissionControl.Initialize(showDuration);
}
PresetBehaviorValues values;
//searches for local presets first, which override global presets
if (TAnimBuilder.GetPresetFromArray(effectTag, data.presets, out values))
{
AssignValues(values);
return;
}
//global presets
if (TAnimBuilder.TryGetGlobalPresetBehavior(effectTag, out values))
{
AssignValues(values);
return;
}
}
public override void SetModifier(string modifierName, string modifierValue)
{
switch (modifierName)
{
case "f": //frequency, increases the time speed
ApplyModifierTo(ref timeSpeed, modifierValue);
break;
case "a": //increase the amplitude
ApplyModifierTo(ref weightMult, modifierValue);
break;
}
}
public override void Calculate()
{
if (!isOnOneCharacter)
return;
uniformEffectTime = emissionControl.IncreaseEffectTime(time.deltaTime * timeSpeed);
}
public override void ApplyEffect(ref CharacterData data, int charIndex)
{
if (!enabled)
return;
if (!isOnOneCharacter)
isOnOneCharacter = data.passedTime > 0;
weight = emissionControl.effectWeigth * weightMult;
if (weight == 0) //no effect
return;
if (hasTransformEffects)
{
offset = (data.vertices[0] + data.vertices[2]) / 2f;
//weighted rotation
rotationQua.eulerAngles = rotation.EvaluateEffect(uniformEffectTime, charIndex) * weight;
matrix.SetTRS(
movement.EvaluateEffect(uniformEffectTime, charIndex) * uniformIntensity * weight,
rotationQua,
Vector3.LerpUnclamped(Vector3.one, scale.EvaluateEffect(uniformEffectTime, charIndex), weight));
for (byte i = 0; i < data.vertices.Length; i++)
{
data.vertices[i] -= offset;
data.vertices[i] = matrix.MultiplyPoint3x4(data.vertices[i]);
data.vertices[i] += offset;
}
}
if (setColor)
{
color = colorCurve.GetColor(uniformEffectTime, charIndex);
data.colors.LerpUnclamped(color, Mathf.Clamp(weight, -1, 1));
}
}
}
}

View File

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

View File

@@ -0,0 +1,20 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[System.Serializable]
internal class PresetBehaviorValues : PresetBaseValues
{
#pragma warning disable 0649 //disabling the error or unity will throw "field is never assigned" [..], because we actually assign the variables from the custom drawers
[SerializeField] public EmissionControl emission;
#pragma warning restore 0649
public override void Initialize(bool isAppearance)
{
base.Initialize(isAppearance);
emission.Initialize(GetMaxDuration());
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,42 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[System.Serializable]
internal class ColorCurve
{
#pragma warning disable 0649 //disabling the error or unity will throw "field is never assigned" [..], because we actually assign the variables from the custom drawers
[SerializeField] public bool enabled;
[SerializeField] protected Gradient gradient;
[SerializeField, Attributes.MinValue(0.1f)] protected float duration;
[SerializeField, Range(0, 100)] protected float charsTimeOffset; //clamping to 100 because it repeates the behavior after it
#pragma warning restore 0649
public float GetDuration()
{
return duration;
}
bool isAppearance;
public void Initialize(bool isAppearance)
{
this.isAppearance = isAppearance;
if (duration < .1f)
{
duration = .1f;
}
}
public Color32 GetColor(float time, int characterIndex)
{
if (isAppearance)
return gradient.Evaluate(Mathf.Clamp01(time / duration));
return gradient.Evaluate(((time / duration) % 1f + characterIndex * (charsTimeOffset / 100f)) % 1f);
}
}
}

View File

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

View File

@@ -0,0 +1,12 @@
namespace Febucci.UI.Core
{
interface EffectEvaluator
{
void Initialize(int type);
bool isEnabled { get; }
float Evaluate(float time, int characterIndex);
float GetDuration();
}
}

View File

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

View File

@@ -0,0 +1,96 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[System.Serializable]
internal struct EmissionControl
{
#pragma warning disable 0649 //disables warning 0649, "value declared but never assigned", since Unity actually assigns the variable in the inspector through the [SerializeField] attribute, but the compiler doesn't know this and throws warnings
[SerializeField, Attributes.MinValue(0)] int cycles;
[SerializeField] AnimationCurve attackCurve;
[SerializeField, Attributes.MinValue(0)] float overrideDuration;
[SerializeField] bool continueForever;
[SerializeField] AnimationCurve decayCurve;
#pragma warning restore 0649
[System.NonSerialized] float maxDuration;
[System.NonSerialized] AnimationCurve intensityOverDuration;
[System.NonSerialized] float passedTime;
[System.NonSerialized] float cycleDuration;
[System.NonSerialized] public float effectWeigth;
public void Initialize(float effectsMaxDuration)
{
passedTime = 0;
Keyframe[] totalKeys = new Keyframe[
attackCurve.length + (continueForever ? 0 : decayCurve.length)
];
for (int i = 0; i < attackCurve.length; i++)
{
totalKeys[i] = attackCurve[i];
}
if (!continueForever)
{
if (overrideDuration > 0)
{
effectsMaxDuration = overrideDuration;
}
float attackDuration = attackCurve.CalculateCurveDuration();
for (int i = attackCurve.length; i < totalKeys.Length; i++)
{
totalKeys[i] = decayCurve[i - attackCurve.length];
totalKeys[i].time += effectsMaxDuration + attackDuration;
}
}
intensityOverDuration = new AnimationCurve(totalKeys);
intensityOverDuration.preWrapMode = WrapMode.Loop;
intensityOverDuration.postWrapMode = WrapMode.Loop;
this.cycleDuration = intensityOverDuration.CalculateCurveDuration();
effectWeigth = intensityOverDuration.Evaluate(passedTime); //sets the initial/start weight of the effect, so that effects will be correctly applied on the first frame
maxDuration = cycleDuration * cycles;
}
public float IncreaseEffectTime(float deltaTime)
{
if (deltaTime == 0)
return passedTime;
passedTime += deltaTime;
if (passedTime < 0)
passedTime = 0;
//inside duration
if (passedTime > cycleDuration) //increases cycle
{
if (continueForever)
{
effectWeigth = 1;
return passedTime;
}
}
//outside cycles
if (cycles > 0 && passedTime >= maxDuration)
{
effectWeigth = 0;
return 0;
}
effectWeigth = intensityOverDuration.Evaluate(passedTime);
return passedTime;
}
}
}

View File

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

View File

@@ -0,0 +1,75 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[System.Serializable]
internal class FloatCurve : EffectEvaluator
{
#pragma warning disable 0649 //disabling the error or unity will throw "field is never assigned" [..], because we actually assign the variables from the custom drawers
public bool enabled;
[SerializeField] protected float amplitude;
[SerializeField] protected AnimationCurve curve;
[SerializeField, HideInInspector] protected float defaultReturn;
[SerializeField, Range(0, 100)] protected float charsTimeOffset; //clamping to 100 because it repeates the behavior after it
[System.NonSerialized] float calculatedDuration;
#pragma warning restore 0649
public bool isEnabled => enabled;
public float GetDuration()
{
return calculatedDuration;
}
bool isAppearance;
public void Initialize(int type)
{
calculatedDuration = curve.CalculateCurveDuration();
isAppearance = type >= 3;
switch (type)
{
//mov
default:
case 0: defaultReturn = 0; break;
//scale
case 1: defaultReturn = 1; break;
//rot
case 2: defaultReturn = 0; break;
//app mov
case 3: defaultReturn = 0; break;
//app scale
case 4: defaultReturn = 1; break;
//app rot
case 5: defaultReturn = 0; break;
}
}
public float Evaluate(float time, int characterIndex)
{
if (!enabled)
return defaultReturn;
if (isAppearance)
{
return Mathf.LerpUnclamped(amplitude, defaultReturn, curve.Evaluate(time) * Mathf.Cos(Mathf.Deg2Rad * (characterIndex * charsTimeOffset / 2f)));
}
//behavior
return curve.Evaluate(time + characterIndex * (charsTimeOffset / 100f)) * amplitude;
}
}
}

View File

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

View File

@@ -0,0 +1,63 @@
using UnityEngine;
namespace Febucci.UI.Core
{
[System.Serializable]
internal class PresetBaseValues
{
#pragma warning disable 0649 //disabling the error or unity will throw "field is never assigned" [..], because we actually assign the variables from the custom drawers
public string effectTag;
[SerializeField] public FloatCurve movementX;
[SerializeField] public FloatCurve movementY;
[SerializeField] public FloatCurve movementZ;
[SerializeField] public FloatCurve scaleX;
[SerializeField] public FloatCurve scaleY;
[SerializeField] public FloatCurve rotX;
[SerializeField] public FloatCurve rotY;
[SerializeField] public FloatCurve rotZ;
[SerializeField] public ColorCurve color;
#pragma warning restore 0649
public float GetMaxDuration()
{
float GetEffectEvaluatorDuration(EffectEvaluator effect)
{
if (effect.isEnabled)
return effect.GetDuration();
return 0;
}
return Mathf.Max
(
GetEffectEvaluatorDuration(movementX),
GetEffectEvaluatorDuration(movementY),
GetEffectEvaluatorDuration(movementZ),
GetEffectEvaluatorDuration(scaleX),
GetEffectEvaluatorDuration(scaleY),
color.enabled ? color.GetDuration() : 0
);
}
public virtual void Initialize(bool isAppearance)
{
int baseIdentifier = isAppearance ? 3 : 0;
movementX.Initialize(baseIdentifier);
movementY.Initialize(baseIdentifier);
movementZ.Initialize(baseIdentifier);
scaleX.Initialize(baseIdentifier + 1);
scaleY.Initialize(baseIdentifier + 1);
rotX.Initialize(baseIdentifier + 2);
rotY.Initialize(baseIdentifier + 2);
rotZ.Initialize(baseIdentifier + 2);
color.Initialize(isAppearance);
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,15 @@
using UnityEngine;
namespace Febucci.UI.Core
{
/// <summary>
/// Scriptable Object that contains Appearances data that can be shared among multiple TextAnimator components.
/// - Manual: <see href="https://www.febucci.com/text-animator-unity/docs/how-to-add-effects-to-your-texts/#shared-built-in-values">Shared built-in values.</see><br/>
/// </summary>
[System.Serializable]
[CreateAssetMenu(fileName = "Built-in Appearances values", menuName = "TextAnimator/Create Built-in Appearances values")]
public class BuiltinAppearancesDataScriptable : BuiltinDataScriptableBase<AppearanceDefaultValues.Defaults>
{
}
}

View File

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

View File

@@ -0,0 +1,15 @@
using UnityEngine;
namespace Febucci.UI.Core
{
/// <summary>
/// Scriptable Object that contains Behaviors data that can be shared among multiple TextAnimator components.
/// - Manual: <see href="https://www.febucci.com/text-animator-unity/docs/how-to-add-effects-to-your-texts/#shared-built-in-values">Shared built-in values.</see><br/>
/// </summary>
[System.Serializable]
[CreateAssetMenu(fileName = "Built-in Behaviors values", menuName = "TextAnimator/Create Built-in Behaviors values")]
public class BuiltinBehaviorsDataScriptable : BuiltinDataScriptableBase<BehaviorDefaultValues.Defaults>
{
}
}

View File

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

View File

@@ -0,0 +1,9 @@
using UnityEngine;
namespace Febucci.UI.Core
{
public class BuiltinDataScriptableBase<T> : ScriptableObject where T : new()
{
[SerializeField] public T effectValues = new T();
}
}

View File

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