Implement hand menu features
This commit is contained in:
499
Assets/DamageNumbersPro/Scripts/Internal/DNPPreset.cs
Normal file
499
Assets/DamageNumbersPro/Scripts/Internal/DNPPreset.cs
Normal file
@@ -0,0 +1,499 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using DamageNumbersPro;
|
||||
|
||||
namespace DamageNumbersPro.Internal
|
||||
{
|
||||
[CreateAssetMenu(fileName = "Preset", menuName = "TextMeshPro/Preset for DNP", order = -1)]
|
||||
public class DNPPreset : ScriptableObject
|
||||
{
|
||||
//Font:
|
||||
public bool changeFontAsset;
|
||||
public TMP_FontAsset fontAsset;
|
||||
|
||||
//Color:
|
||||
public bool changeColor;
|
||||
public Color color = Color.white;
|
||||
public bool enableGradient;
|
||||
public VertexGradient gradient = new VertexGradient(Color.white, Color.white, Color.white, Color.white);
|
||||
|
||||
//Number:
|
||||
public bool changeNumber;
|
||||
public bool enableNumber = true;
|
||||
public TextSettings numberSettings = new TextSettings(0);
|
||||
public DigitSettings digitSettings = new DigitSettings(0);
|
||||
|
||||
//Left Text:
|
||||
public bool changeLeftText;
|
||||
public bool enableLeftText = true;
|
||||
public string leftText;
|
||||
public TextSettings leftTextSettings = new TextSettings(0f);
|
||||
|
||||
//Right Text:
|
||||
public bool changeRightText;
|
||||
public bool enableRightText = true;
|
||||
public string rightText;
|
||||
public TextSettings rightTextSettings = new TextSettings(0f);
|
||||
|
||||
//Vertical Text:
|
||||
public bool hideVerticalTexts = false;
|
||||
|
||||
//Fade In:
|
||||
public bool changeFadeIn = false;
|
||||
public float durationFadeIn = 0.2f;
|
||||
public bool enableOffsetFadeIn = true;
|
||||
[Tooltip("TextA and TextB move together from this offset.")]
|
||||
public Vector2 offsetFadeIn = new Vector2(0.5f, 0);
|
||||
public bool enableScaleFadeIn = true;
|
||||
[Tooltip("Scales in from this scale.")]
|
||||
public Vector2 scaleFadeIn = new Vector2(2, 2);
|
||||
public bool enableCrossScaleFadeIn = false;
|
||||
[Tooltip("Scales TextA in from this scale and TextB from the inverse of this scale.")]
|
||||
public Vector2 crossScaleFadeIn = new Vector2(1, 1.5f);
|
||||
public bool enableShakeFadeIn = false;
|
||||
[Tooltip("Shakes in from this offset.")]
|
||||
public Vector2 shakeOffsetFadeIn = new Vector2(0, 1.5f);
|
||||
[Tooltip("Shakes in at this frequency.")]
|
||||
public float shakeFrequencyFadeIn = 4f;
|
||||
|
||||
//Fade Out:
|
||||
public bool changeFadeOut = false;
|
||||
public float durationFadeOut = 0.2f;
|
||||
public bool enableOffsetFadeOut = true;
|
||||
[Tooltip("TextA and TextB move apart to this offset.")]
|
||||
public Vector2 offsetFadeOut = new Vector2(0.5f, 0);
|
||||
public bool enableScaleFadeOut = false;
|
||||
[Tooltip("Scales out to this scale.")]
|
||||
public Vector2 scaleFadeOut = new Vector2(2, 2);
|
||||
public bool enableCrossScaleFadeOut = false;
|
||||
[Tooltip("Scales TextA out to this scale and TextB to the inverse of this scale.")]
|
||||
public Vector2 crossScaleFadeOut = new Vector2(1, 1.5f);
|
||||
public bool enableShakeFadeOut = false;
|
||||
[Tooltip("Shakes out to this offset.")]
|
||||
public Vector2 shakeOffsetFadeOut = new Vector2(0, 1.5f);
|
||||
[Tooltip("Shakes out at this frequency.")]
|
||||
public float shakeFrequencyFadeOut = 4f;
|
||||
|
||||
//Movement:
|
||||
public bool changeMovement = false;
|
||||
public bool enableLerp = true;
|
||||
public LerpSettings lerpSettings = new LerpSettings(0);
|
||||
public bool enableVelocity = false;
|
||||
public VelocitySettings velocitySettings = new VelocitySettings(0);
|
||||
public bool enableShaking = false;
|
||||
[Tooltip("Shake settings during idle.")]
|
||||
public ShakeSettings shakeSettings = new ShakeSettings(new Vector2(0.005f, 0.005f));
|
||||
public bool enableFollowing = false;
|
||||
public FollowSettings followSettings = new FollowSettings(0);
|
||||
|
||||
//Rotation:
|
||||
public bool changeRotation = false;
|
||||
public bool enableStartRotation = false;
|
||||
[Tooltip("The minimum z-angle for the random spawn rotation.")]
|
||||
public float minRotation = -4f;
|
||||
[Tooltip("The maximum z-angle for the random spawn rotation.")]
|
||||
public float maxRotation = 4f;
|
||||
public bool enableRotateOverTime = false;
|
||||
[Tooltip("The minimum rotation speed for the z-angle.")]
|
||||
public float minRotationSpeed = -15f;
|
||||
[Tooltip("The maximum rotation speed for the z-angle.")]
|
||||
public float maxRotationSpeed = 15;
|
||||
[Tooltip("Defines rotation speed over lifetime.")]
|
||||
public AnimationCurve rotateOverTime = new AnimationCurve(new Keyframe[] { new Keyframe(0, 1), new Keyframe(0.4f, 1), new Keyframe(0.8f, 0), new Keyframe(1, 0) });
|
||||
|
||||
//Scaling:
|
||||
public bool changeScaling = false;
|
||||
public bool enableScaleByNumber = false;
|
||||
public ScaleByNumberSettings scaleByNumberSettings = new ScaleByNumberSettings(0);
|
||||
public bool enableScaleOverTime = false;
|
||||
[Tooltip("Will scale over it's lifetime using this curve.")]
|
||||
public AnimationCurve scaleOverTime = new AnimationCurve(new Keyframe(0, 1), new Keyframe(1, 0.7f));
|
||||
|
||||
//Spam Control:
|
||||
public bool changeSpamControl = false;
|
||||
public string spamGroup = "";
|
||||
public bool enableCombination = false;
|
||||
public CombinationSettings combinationSettings = new CombinationSettings(0);
|
||||
public bool enableDestruction = false;
|
||||
public DestructionSettings destructionSettings = new DestructionSettings(0);
|
||||
public bool enableCollision = false;
|
||||
public CollisionSettings collisionSettings = new CollisionSettings(0);
|
||||
public bool enablePush = false;
|
||||
public PushSettings pushSettings = new PushSettings(0);
|
||||
|
||||
public bool IsApplied(DamageNumber dn)
|
||||
{
|
||||
TMP_Text[] textMeshs = dn.GetTextMeshs();
|
||||
|
||||
if (textMeshs[0] == null)
|
||||
{
|
||||
dn.GetReferencesIfNecessary();
|
||||
textMeshs = dn.GetTextMeshs();
|
||||
}
|
||||
|
||||
bool isApplied = true;
|
||||
|
||||
//Font:
|
||||
if (changeFontAsset)
|
||||
{
|
||||
foreach(TMP_Text tmp in textMeshs)
|
||||
{
|
||||
if (fontAsset != tmp.font)
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Color:
|
||||
if (changeColor)
|
||||
{
|
||||
foreach (TMP_Text tmp in textMeshs)
|
||||
{
|
||||
if (color != tmp.color || enableGradient != tmp.enableVertexGradient || !gradient.Equals(tmp.colorGradient))
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Number:
|
||||
if(changeNumber)
|
||||
{
|
||||
if(enableNumber != dn.enableNumber || !numberSettings.Equals(dn.numberSettings) || !digitSettings.Equals(dn.digitSettings))
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Left Text:
|
||||
if(changeLeftText)
|
||||
{
|
||||
if(enableLeftText != dn.enableLeftText || !leftTextSettings.Equals(dn.leftTextSettings) || leftText != dn.leftText)
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Right Text:
|
||||
if (changeRightText)
|
||||
{
|
||||
if (enableRightText != dn.enableRightText || !rightTextSettings.Equals(dn.rightTextSettings) || rightText != dn.rightText)
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Vertical Texts:
|
||||
if (hideVerticalTexts)
|
||||
{
|
||||
if(dn.enableTopText || dn.enableBottomText)
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Fade In:
|
||||
if(changeFadeIn)
|
||||
{
|
||||
if(durationFadeIn != dn.durationFadeIn || enableOffsetFadeIn != dn.enableOffsetFadeIn || offsetFadeIn != dn.offsetFadeIn ||
|
||||
enableScaleFadeIn != dn.enableScaleFadeIn || scaleFadeIn != dn.scaleFadeIn || enableCrossScaleFadeIn != dn.enableCrossScaleFadeIn ||
|
||||
crossScaleFadeIn != dn.crossScaleFadeIn || enableShakeFadeIn != dn.enableShakeFadeIn || shakeOffsetFadeIn != dn.shakeOffsetFadeIn ||
|
||||
shakeFrequencyFadeIn != dn.shakeFrequencyFadeIn)
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Fade Out:
|
||||
if (changeFadeOut)
|
||||
{
|
||||
if (durationFadeOut != dn.durationFadeOut || enableOffsetFadeOut != dn.enableOffsetFadeOut || offsetFadeOut != dn.offsetFadeOut ||
|
||||
enableScaleFadeOut != dn.enableScaleFadeOut || scaleFadeOut != dn.scaleFadeOut || enableCrossScaleFadeOut != dn.enableCrossScaleFadeOut ||
|
||||
crossScaleFadeOut != dn.crossScaleFadeOut || enableShakeFadeOut != dn.enableShakeFadeOut || shakeOffsetFadeOut != dn.shakeOffsetFadeOut ||
|
||||
shakeFrequencyFadeOut != dn.shakeFrequencyFadeOut)
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Movement:
|
||||
if(changeMovement)
|
||||
{
|
||||
if(enableLerp != dn.enableLerp || !lerpSettings.Equals(dn.lerpSettings) ||
|
||||
enableVelocity != dn.enableVelocity || !velocitySettings.Equals(dn.velocitySettings) ||
|
||||
enableShaking != dn.enableShaking || !shakeSettings.Equals(dn.shakeSettings) ||
|
||||
enableFollowing != dn.enableFollowing || !followSettings.Equals(dn.followSettings))
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Rotation:
|
||||
if(changeRotation)
|
||||
{
|
||||
if(enableStartRotation != dn.enableStartRotation || minRotation != dn.minRotation || maxRotation != dn.maxRotation ||
|
||||
enableRotateOverTime != dn.enableRotateOverTime || minRotationSpeed != dn.minRotationSpeed || maxRotationSpeed != dn.maxRotationSpeed || !rotateOverTime.Equals(dn.rotateOverTime))
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Scale:
|
||||
if(changeScaling)
|
||||
{
|
||||
if(enableScaleByNumber != dn.enableScaleByNumber || !scaleByNumberSettings.Equals(dn.scaleByNumberSettings) ||
|
||||
enableScaleOverTime != dn.enableScaleOverTime || !scaleOverTime.Equals(dn.scaleOverTime))
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Spam Group:
|
||||
if(changeSpamControl)
|
||||
{
|
||||
if(enableCombination != dn.enableCombination || !combinationSettings.Equals(dn.combinationSettings) ||
|
||||
enableDestruction != dn.enableDestruction || !destructionSettings.Equals(dn.destructionSettings) ||
|
||||
enableCollision != dn.enableCollision || !collisionSettings.Equals(dn.collisionSettings) ||
|
||||
enablePush != dn.enablePush || !pushSettings.Equals(dn.pushSettings))
|
||||
{
|
||||
isApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
return isApplied;
|
||||
}
|
||||
|
||||
public void Apply(DamageNumber dn)
|
||||
{
|
||||
TMP_Text[] textMeshs = dn.GetTextMeshs();
|
||||
|
||||
//Font:
|
||||
if (changeFontAsset)
|
||||
{
|
||||
foreach(TMP_Text tmp in textMeshs)
|
||||
{
|
||||
tmp.font = fontAsset;
|
||||
}
|
||||
}
|
||||
|
||||
//Color:
|
||||
if (changeColor)
|
||||
{
|
||||
foreach (TMP_Text tmp in textMeshs)
|
||||
{
|
||||
tmp.color = color;
|
||||
tmp.enableVertexGradient = enableGradient;
|
||||
tmp.colorGradient = gradient;
|
||||
}
|
||||
}
|
||||
|
||||
//Number:
|
||||
if (changeNumber)
|
||||
{
|
||||
dn.enableNumber = enableNumber;
|
||||
dn.numberSettings = numberSettings;
|
||||
dn.digitSettings = digitSettings;
|
||||
}
|
||||
|
||||
//Left Text:
|
||||
if (changeLeftText)
|
||||
{
|
||||
dn.enableLeftText = enableLeftText;
|
||||
dn.leftText = leftText;
|
||||
dn.leftTextSettings = leftTextSettings;
|
||||
}
|
||||
|
||||
//Right Text:
|
||||
if (changeRightText)
|
||||
{
|
||||
dn.enableRightText = enableRightText;
|
||||
dn.rightText = rightText;
|
||||
dn.rightTextSettings = rightTextSettings;
|
||||
}
|
||||
|
||||
//Hide Vertical Texts:
|
||||
if(hideVerticalTexts)
|
||||
{
|
||||
dn.enableTopText = dn.enableBottomText = false;
|
||||
}
|
||||
|
||||
//Fade In:
|
||||
if(changeFadeIn)
|
||||
{
|
||||
dn.durationFadeIn = durationFadeIn;
|
||||
dn.enableOffsetFadeIn = enableOffsetFadeIn;
|
||||
dn.offsetFadeIn = offsetFadeIn;
|
||||
dn.enableScaleFadeIn = enableScaleFadeIn;
|
||||
dn.scaleFadeIn = scaleFadeIn;
|
||||
dn.enableCrossScaleFadeIn = enableCrossScaleFadeIn;
|
||||
dn.crossScaleFadeIn = crossScaleFadeIn;
|
||||
dn.enableShakeFadeIn = enableShakeFadeIn;
|
||||
dn.shakeOffsetFadeIn = shakeOffsetFadeIn;
|
||||
dn.shakeFrequencyFadeIn = shakeFrequencyFadeIn;
|
||||
}
|
||||
|
||||
//Fade Out:
|
||||
if (changeFadeOut)
|
||||
{
|
||||
dn.durationFadeOut = durationFadeOut;
|
||||
dn.enableOffsetFadeOut = enableOffsetFadeOut;
|
||||
dn.offsetFadeOut = offsetFadeOut;
|
||||
dn.enableScaleFadeOut = enableScaleFadeOut;
|
||||
dn.scaleFadeOut = scaleFadeOut;
|
||||
dn.enableCrossScaleFadeOut = enableCrossScaleFadeOut;
|
||||
dn.crossScaleFadeOut = crossScaleFadeOut;
|
||||
dn.enableShakeFadeOut = enableShakeFadeOut;
|
||||
dn.shakeOffsetFadeOut = shakeOffsetFadeOut;
|
||||
dn.shakeFrequencyFadeOut = shakeFrequencyFadeOut;
|
||||
}
|
||||
|
||||
//Movement:
|
||||
if(changeMovement)
|
||||
{
|
||||
dn.enableLerp = enableLerp;
|
||||
dn.lerpSettings = lerpSettings;
|
||||
dn.enableVelocity = enableVelocity;
|
||||
dn.velocitySettings = velocitySettings;
|
||||
dn.enableShaking = enableShaking;
|
||||
dn.shakeSettings = shakeSettings;
|
||||
dn.enableFollowing = enableFollowing;
|
||||
dn.followSettings = followSettings;
|
||||
}
|
||||
|
||||
//Rotation:
|
||||
if(changeRotation)
|
||||
{
|
||||
dn.enableStartRotation = enableStartRotation;
|
||||
dn.minRotation = minRotation;
|
||||
dn.maxRotation = maxRotation;
|
||||
dn.enableRotateOverTime = enableRotateOverTime;
|
||||
dn.minRotationSpeed = minRotationSpeed;
|
||||
dn.maxRotationSpeed = maxRotationSpeed;
|
||||
dn.rotateOverTime = rotateOverTime;
|
||||
}
|
||||
|
||||
//Scale:
|
||||
if(changeScaling)
|
||||
{
|
||||
dn.enableScaleByNumber = enableScaleByNumber;
|
||||
dn.scaleByNumberSettings = scaleByNumberSettings;
|
||||
dn.enableScaleOverTime = enableScaleOverTime;
|
||||
dn.scaleOverTime = scaleOverTime;
|
||||
}
|
||||
|
||||
//Spam Control:
|
||||
if(changeSpamControl)
|
||||
{
|
||||
if(dn.spamGroup == null || dn.spamGroup == "")
|
||||
{
|
||||
dn.spamGroup = spamGroup;
|
||||
}
|
||||
|
||||
dn.enableCombination = enableCombination;
|
||||
dn.combinationSettings = combinationSettings;
|
||||
dn.enableDestruction = enableDestruction;
|
||||
dn.destructionSettings = destructionSettings;
|
||||
dn.enableCollision = enableCollision;
|
||||
dn.collisionSettings = collisionSettings;
|
||||
dn.enablePush = enablePush;
|
||||
dn.pushSettings = pushSettings;
|
||||
}
|
||||
}
|
||||
|
||||
public void Get(DamageNumber dn)
|
||||
{
|
||||
TMP_Text[] textMeshs = dn.GetTextMeshs();
|
||||
|
||||
//Font:
|
||||
changeFontAsset = true;
|
||||
foreach (TMP_Text tmp in textMeshs)
|
||||
{
|
||||
if(tmp != null)
|
||||
{
|
||||
fontAsset = tmp.font;
|
||||
}
|
||||
}
|
||||
|
||||
//Color:
|
||||
changeColor = true;
|
||||
foreach (TMP_Text tmp in textMeshs)
|
||||
{
|
||||
if(tmp != null)
|
||||
{
|
||||
color = tmp.color;
|
||||
enableGradient = tmp.enableVertexGradient;
|
||||
gradient = tmp.colorGradient;
|
||||
}
|
||||
}
|
||||
|
||||
//Fade In:
|
||||
changeFadeIn = true;
|
||||
durationFadeIn = dn.durationFadeIn;
|
||||
enableOffsetFadeIn = dn.enableOffsetFadeIn;
|
||||
offsetFadeIn = dn.offsetFadeIn;
|
||||
enableScaleFadeIn = dn.enableScaleFadeIn;
|
||||
scaleFadeIn = dn.scaleFadeIn;
|
||||
enableCrossScaleFadeIn = dn.enableCrossScaleFadeIn;
|
||||
crossScaleFadeIn = dn.crossScaleFadeIn;
|
||||
enableShakeFadeIn = dn.enableShakeFadeIn;
|
||||
shakeOffsetFadeIn = dn.shakeOffsetFadeIn;
|
||||
shakeFrequencyFadeIn = dn.shakeFrequencyFadeIn;
|
||||
|
||||
//Fade Out:
|
||||
changeFadeOut = true;
|
||||
durationFadeOut = dn.durationFadeOut;
|
||||
enableOffsetFadeOut = dn.enableOffsetFadeOut;
|
||||
offsetFadeOut = dn.offsetFadeOut;
|
||||
enableScaleFadeOut = dn.enableScaleFadeOut;
|
||||
scaleFadeOut = dn.scaleFadeOut;
|
||||
enableCrossScaleFadeOut = dn.enableCrossScaleFadeOut;
|
||||
crossScaleFadeOut = dn.crossScaleFadeOut;
|
||||
enableShakeFadeOut = dn.enableShakeFadeOut;
|
||||
shakeOffsetFadeOut = dn.shakeOffsetFadeOut;
|
||||
shakeFrequencyFadeOut = dn.shakeFrequencyFadeOut;
|
||||
|
||||
//Movement:
|
||||
changeMovement = true;
|
||||
enableLerp = dn.enableLerp;
|
||||
lerpSettings = dn.lerpSettings;
|
||||
enableVelocity = dn.enableVelocity;
|
||||
velocitySettings = dn.velocitySettings;
|
||||
enableShaking = dn.enableShaking;
|
||||
shakeSettings = dn.shakeSettings;
|
||||
enableFollowing = dn.enableFollowing;
|
||||
followSettings = dn.followSettings;
|
||||
|
||||
//Rotation:
|
||||
changeRotation = true;
|
||||
enableStartRotation = dn.enableStartRotation;
|
||||
minRotation = dn.minRotation;
|
||||
maxRotation = dn.maxRotation;
|
||||
enableRotateOverTime = dn.enableRotateOverTime;
|
||||
minRotationSpeed = dn.minRotationSpeed;
|
||||
maxRotationSpeed = dn.maxRotationSpeed;
|
||||
rotateOverTime = dn.rotateOverTime;
|
||||
|
||||
//Scale:
|
||||
changeScaling = true;
|
||||
enableScaleByNumber = dn.enableScaleByNumber;
|
||||
scaleByNumberSettings = dn.scaleByNumberSettings;
|
||||
enableScaleOverTime = dn.enableScaleOverTime;
|
||||
scaleOverTime = dn.scaleOverTime;
|
||||
|
||||
//Spam Group:
|
||||
changeSpamControl = true;
|
||||
spamGroup = dn.spamGroup != "" ? "Default" : "";
|
||||
enableCombination = dn.enableCombination;
|
||||
combinationSettings = dn.combinationSettings;
|
||||
enableDestruction = dn.enableDestruction;
|
||||
destructionSettings = dn.destructionSettings;
|
||||
enableCollision = dn.enableCollision;
|
||||
collisionSettings = dn.collisionSettings;
|
||||
enablePush = dn.enablePush;
|
||||
pushSettings = dn.pushSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/DamageNumbersPro/Scripts/Internal/DNPPreset.cs.meta
Normal file
11
Assets/DamageNumbersPro/Scripts/Internal/DNPPreset.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d57d6f502e7c30a4ca03abf7f4c97bbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/DamageNumbersPro/Scripts/Internal/DNPType.cs
Normal file
12
Assets/DamageNumbersPro/Scripts/Internal/DNPType.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum DNPType
|
||||
{
|
||||
All
|
||||
,
|
||||
Mesh
|
||||
,
|
||||
GUI
|
||||
}
|
||||
11
Assets/DamageNumbersPro/Scripts/Internal/DNPType.cs.meta
Normal file
11
Assets/DamageNumbersPro/Scripts/Internal/DNPType.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fae86257cb5b74d498f64e6825132b12
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
141
Assets/DamageNumbersPro/Scripts/Internal/DNPUpdater.cs
Normal file
141
Assets/DamageNumbersPro/Scripts/Internal/DNPUpdater.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DamageNumbersPro;
|
||||
|
||||
namespace DamageNumbersPro.Internal
|
||||
{
|
||||
public class DNPUpdater : MonoBehaviour
|
||||
{
|
||||
//Dicitonary:
|
||||
static Dictionary<float, DNPUpdater> unscaledUpdaters;
|
||||
static Dictionary<float, DNPUpdater> scaledUpdaters;
|
||||
|
||||
//Static:
|
||||
public static Vector3 upVector;
|
||||
public static Vector3 rightVector;
|
||||
public static bool vectorsNeedUpdate;
|
||||
public static Quaternion cameraRotation;
|
||||
|
||||
//Settings:
|
||||
public bool isUnscaled = false;
|
||||
public float updateDelay = 0.0125f;
|
||||
public HashSet<DamageNumber> activePopups;
|
||||
public HashSet<DamageNumber> removedPopups;
|
||||
|
||||
//Internal:
|
||||
float lastUpdateTime = 0;
|
||||
float delta = 0;
|
||||
float time = 0;
|
||||
|
||||
void Start()
|
||||
{
|
||||
StartCoroutine(UpdatePopups());
|
||||
}
|
||||
|
||||
IEnumerator UpdatePopups()
|
||||
{
|
||||
//Delay:
|
||||
WaitForSecondsRealtime delay = new WaitForSecondsRealtime(updateDelay);
|
||||
|
||||
while(true)
|
||||
{
|
||||
//Vector Update:
|
||||
vectorsNeedUpdate = true;
|
||||
|
||||
//Update:
|
||||
foreach (DamageNumber popup in activePopups)
|
||||
{
|
||||
if(popup != null)
|
||||
{
|
||||
popup.UpdateDamageNumber(delta, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
removedPopups.Add(popup);
|
||||
}
|
||||
}
|
||||
|
||||
//Clean Up:
|
||||
if(removedPopups.Count > 0)
|
||||
{
|
||||
foreach (DamageNumber removed in removedPopups)
|
||||
{
|
||||
activePopups.Remove(removed);
|
||||
}
|
||||
removedPopups = new HashSet<DamageNumber>();
|
||||
}
|
||||
|
||||
//Wait:
|
||||
if (isUnscaled)
|
||||
{
|
||||
lastUpdateTime = Time.unscaledTime;
|
||||
yield return delay;
|
||||
time = Time.unscaledTime;
|
||||
delta = time - lastUpdateTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastUpdateTime = Time.time;
|
||||
yield return delay;
|
||||
time = Time.time;
|
||||
delta = time - lastUpdateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RegisterPopup(bool unscaledTime, float updateDelay, DamageNumber popup)
|
||||
{
|
||||
ref Dictionary<float, DNPUpdater> updaters = ref unscaledTime ? ref unscaledUpdaters : ref scaledUpdaters;
|
||||
|
||||
if (updaters == null)
|
||||
{
|
||||
updaters = new Dictionary<float, DNPUpdater>();
|
||||
}
|
||||
|
||||
bool containsKey = updaters.ContainsKey(updateDelay);
|
||||
if (containsKey && updaters[updateDelay] != null)
|
||||
{
|
||||
updaters[updateDelay].activePopups.Add(popup);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(containsKey)
|
||||
{
|
||||
updaters.Remove(updateDelay);
|
||||
}
|
||||
|
||||
GameObject newUpdater = new GameObject("");
|
||||
newUpdater.hideFlags = HideFlags.HideInHierarchy;
|
||||
|
||||
DNPUpdater dnpUpdater = newUpdater.AddComponent<DNPUpdater>();
|
||||
dnpUpdater.activePopups = new HashSet<DamageNumber>();
|
||||
dnpUpdater.removedPopups = new HashSet<DamageNumber>();
|
||||
dnpUpdater.isUnscaled = unscaledTime;
|
||||
dnpUpdater.updateDelay = updateDelay;
|
||||
DontDestroyOnLoad(newUpdater);
|
||||
|
||||
updaters.Add(updateDelay, dnpUpdater);
|
||||
|
||||
dnpUpdater.activePopups.Add(popup);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnregisterPopup(bool unscaledTime, float updateDelay, DamageNumber popup)
|
||||
{
|
||||
Dictionary<float, DNPUpdater> updaters = unscaledTime ? unscaledUpdaters : scaledUpdaters;
|
||||
|
||||
if (updaters != null && updaters.ContainsKey(updateDelay) && updaters[updateDelay].activePopups.Contains(popup))
|
||||
{
|
||||
updaters[updateDelay].removedPopups.Add(popup);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateVectors(Transform popup)
|
||||
{
|
||||
vectorsNeedUpdate = false;
|
||||
upVector = popup.up;
|
||||
rightVector = popup.right;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/DamageNumbersPro/Scripts/Internal/DNPUpdater.cs.meta
Normal file
11
Assets/DamageNumbersPro/Scripts/Internal/DNPUpdater.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70295d7c27ed57f429198ae6c41fd45f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 526
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
2908
Assets/DamageNumbersPro/Scripts/Internal/DamageNumber.cs
Normal file
2908
Assets/DamageNumbersPro/Scripts/Internal/DamageNumber.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb457e4f4b6f37c4ba7cbb64769f967e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 520
|
||||
icon: {fileID: 2800000, guid: 47a7c3a675ab92247b88f6f2978ea88d, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/DamageNumbersPro/Scripts/Internal/Editor.meta
Normal file
8
Assets/DamageNumbersPro/Scripts/Internal/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 922277e9523a7064c959ec3b68e0d55f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1366
Assets/DamageNumbersPro/Scripts/Internal/Editor/DNPEditorInternal.cs
Normal file
1366
Assets/DamageNumbersPro/Scripts/Internal/Editor/DNPEditorInternal.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 945de8189a19b914f8d54c4af7ea2187
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace DamageNumbersPro.Internal
|
||||
{
|
||||
[CustomEditor(typeof(DNPPreset))]
|
||||
public class DNPPresetEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
//Prepare:
|
||||
GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
|
||||
labelStyle.richText = true;
|
||||
|
||||
|
||||
//Copying:
|
||||
EditorGUILayout.Space(4);
|
||||
DamageNumber dn = (DamageNumber) EditorGUILayout.ObjectField(null, typeof(DamageNumber), true,GUILayout.Height(80));
|
||||
GUIStyle dropStyle = new GUIStyle(GUI.skin.box);
|
||||
dropStyle.alignment = TextAnchor.MiddleCenter;
|
||||
Rect lastRect = GUILayoutUtility.GetLastRect();
|
||||
GUI.Box(lastRect, "Drop damage number here.", dropStyle);
|
||||
if(dn != null)
|
||||
{
|
||||
DNPPreset preset = (DNPPreset)target;
|
||||
Undo.RegisterCompleteObjectUndo(preset, "Copied damage number.");
|
||||
preset.Get(dn);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
|
||||
//Get First Property:
|
||||
SerializedProperty currentProperty = serializedObject.FindProperty("changeFontAsset");
|
||||
|
||||
//Display Properties:
|
||||
EditorGUILayout.BeginVertical();
|
||||
bool visible = true;
|
||||
do
|
||||
{
|
||||
bool isNewCategory = currentProperty.name.StartsWith("change") || currentProperty.name == "hideVerticalTexts";
|
||||
if (isNewCategory)
|
||||
{
|
||||
visible = true;
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
}
|
||||
|
||||
if(visible)
|
||||
{
|
||||
if(isNewCategory)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("<size=14><b>" + currentProperty.displayName + "</b></size>", labelStyle);
|
||||
EditorGUILayout.PropertyField(currentProperty, GUIContent.none, true);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(currentProperty, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (isNewCategory)
|
||||
{
|
||||
visible = currentProperty.boolValue;
|
||||
|
||||
if(visible && currentProperty.name.StartsWith("change"))
|
||||
{
|
||||
DNPEditorInternal.Lines();
|
||||
}
|
||||
}
|
||||
|
||||
} while (currentProperty.NextVisible(false));
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
//Save Changes:
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c55b1576eec682446928e58fab62ee59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 668f6245f82e2b8428228e6bf559c394
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user