chore: initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
namespace Animancer.Units
|
||||
{
|
||||
/// <summary>[Editor-Conditional] Applies a different GUI for an animation speed field.</summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/AnimationSpeedAttribute
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class AnimationSpeedAttribute : UnitsAttribute
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="AnimationTimeAttribute"/>.</summary>
|
||||
public AnimationSpeedAttribute()
|
||||
: base("x")
|
||||
{
|
||||
Rule = Validate.Value.IsFiniteOrNaN;
|
||||
IsOptional = true;
|
||||
DefaultValue = 1;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cf93c876d129534c9262b20498de934
|
||||
timeCreated: 1516751545
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
namespace Animancer.Units
|
||||
{
|
||||
/// <summary>[Editor-Conditional]
|
||||
/// Causes a float field to display using 3 fields: Normalized, Seconds, and Frames.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/transitions#time-fields">
|
||||
/// Time Fields</see>
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/AnimationTimeAttribute
|
||||
///
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class AnimationTimeAttribute : UnitsAttribute
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>A unit of measurement used by the <see cref="AnimationTimeAttribute"/>.</summary>
|
||||
public enum Units
|
||||
{
|
||||
/// <summary>A value of 1 represents the end of the animation.</summary>
|
||||
Normalized = 0,
|
||||
|
||||
/// <summary>A value of 1 represents 1 second.</summary>
|
||||
Seconds = 1,
|
||||
|
||||
/// <summary>A value of 1 represents 1 frame.</summary>
|
||||
Frames = 2,
|
||||
}
|
||||
|
||||
/// <summary>An explanation of the suffixes used in fields drawn by this attribute.</summary>
|
||||
public const string Tooltip = "x = Normalized, s = Seconds, f = Frames";
|
||||
|
||||
/// <summary>The <see cref="UnitsAttribute.Multipliers"/> used by instances of this attribute.</summary>
|
||||
private static new readonly float[] Multipliers = new float[3];// Calculated immediately before each use.
|
||||
|
||||
/// <summary>The <see cref="UnitsAttribute.Suffixes"/> used by instances of this attribute.</summary>
|
||||
private static new readonly string[] Suffixes = new string[3] { "x", "s", "f" };
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Cretes a new <see cref="AnimationTimeAttribute"/>.</summary>
|
||||
public AnimationTimeAttribute(Units units)
|
||||
: base(Multipliers, Suffixes, (int)units)
|
||||
{ }
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bacb1073e1dc0241a57779a297b256d
|
||||
timeCreated: 1516751545
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,143 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
namespace Animancer.Units
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>[Editor-Conditional] Angle measured in <c>degrees</c> (<c>º</c>).</summary>
|
||||
/// <remarks>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/other/units">
|
||||
/// Units Attribute</see>
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/DegreesAttribute
|
||||
///
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class DegreesAttribute : UnitsAttribute
|
||||
{
|
||||
/// <summary>Creates a new <see cref="DegreesAttribute"/>.</summary>
|
||||
public DegreesAttribute() : base(" º") { }
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>[Editor-Conditional] Rotational speed measured in <c>degrees per second</c> (<c>º/s</c>).</summary>
|
||||
/// <remarks>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/other/units">
|
||||
/// Units Attribute</see>
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/DegreesPerSecondAttribute
|
||||
///
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class DegreesPerSecondAttribute : UnitsAttribute
|
||||
{
|
||||
/// <summary>Creates a new <see cref="DegreesPerSecondAttribute"/>.</summary>
|
||||
public DegreesPerSecondAttribute() : base(" º/s") { }
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>[Editor-Conditional] Distance measured in <c>meters</c> (<c>m</c>).</summary>
|
||||
/// <remarks>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/other/units">
|
||||
/// Units Attribute</see>
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/MetersAttribute
|
||||
///
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class MetersAttribute : UnitsAttribute
|
||||
{
|
||||
/// <summary>Creates a new <see cref="MetersAttribute"/>.</summary>
|
||||
public MetersAttribute() : base(" m") { }
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>[Editor-Conditional] Speed measured in <c>meters per second</c> (<c>m/s</c>).</summary>
|
||||
/// <remarks>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/other/units">
|
||||
/// Units Attribute</see>
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/MetersPerSecondAttribute
|
||||
///
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class MetersPerSecondAttribute : UnitsAttribute
|
||||
{
|
||||
/// <summary>Creates a new <see cref="MetersPerSecondAttribute"/>.</summary>
|
||||
public MetersPerSecondAttribute() : base(" m/s") { }
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>[Editor-Conditional] Acceleration measured in <c>meters per second per second</c> (<c>m/s²</c>).</summary>
|
||||
/// <remarks>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/other/units">
|
||||
/// Units Attribute</see>
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/MetersPerSecondPerSecondAttribute
|
||||
///
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class MetersPerSecondPerSecondAttribute : UnitsAttribute
|
||||
{
|
||||
/// <summary>Creates a new <see cref="MetersPerSecondPerSecondAttribute"/>.</summary>
|
||||
public MetersPerSecondPerSecondAttribute() : base(" m/s\xB2") { }
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>[Editor-Conditional] A multiplier displayed with an <c>x</c> suffix.</summary>
|
||||
/// <remarks>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/other/units">
|
||||
/// Units Attribute</see>
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/MultiplierAttribute
|
||||
///
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class MultiplierAttribute : UnitsAttribute
|
||||
{
|
||||
/// <summary>Creates a new <see cref="MultiplierAttribute"/>.</summary>
|
||||
public MultiplierAttribute() : base(" x") { }
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>[Editor-Conditional] Time measured in <c>seconds</c> (<c>s</c>).</summary>
|
||||
/// <remarks>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/other/units">
|
||||
/// Units Attribute</see>
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/SecondsAttribute
|
||||
///
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class SecondsAttribute : UnitsAttribute
|
||||
{
|
||||
/// <summary>Creates a new <see cref="SecondsAttribute"/>.</summary>
|
||||
public SecondsAttribute() : base(" s") { }
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>[Editor-Conditional] A value measured <c>per second</c> (<c>/s</c>).</summary>
|
||||
/// <remarks>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/other/units">
|
||||
/// Units Attribute</see>
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/PerSecondAttribute
|
||||
///
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class PerSecondAttribute : UnitsAttribute
|
||||
{
|
||||
/// <summary>Creates a new <see cref="PerSecondAttribute"/>.</summary>
|
||||
public PerSecondAttribute() : base(" /s") { }
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd7f08fff8e76af4da23e74b033b2e60
|
||||
labels:
|
||||
- Example
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,76 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animancer.Units
|
||||
{
|
||||
/// <summary>[Editor-Conditional]
|
||||
/// Causes a float field to display a suffix to indicate what kind of units the value represents as well as
|
||||
/// displaying it as several different fields which convert the value between different units.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/other/units">
|
||||
/// Units Attribute</see>
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Units/UnitsAttribute
|
||||
///
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public class UnitsAttribute : PropertyAttribute
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>The multipliers to convert from the field's actual value to each unit type.</summary>
|
||||
/// <remarks><c>valueInUnitX = valueInBaseUnits * Multipliers[x];</c></remarks>
|
||||
public readonly float[] Multipliers;
|
||||
|
||||
/// <summary>The unit suffix to display at the end of the value in each field.</summary>
|
||||
public readonly string[] Suffixes;
|
||||
|
||||
/// <summary>The index of the multiplier where the field stores its actual value.</summary>
|
||||
/// <remarks>The multiplier at this index must always be 1.</remarks>
|
||||
public readonly int UnitIndex;
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>The validation rule applied to the value.</summary>
|
||||
public Validate.Value Rule { get; set; }
|
||||
|
||||
/// <summary>Should the field have a toggle to set its value to <see cref="float.NaN"/>?</summary>
|
||||
public bool IsOptional { get; set; }
|
||||
|
||||
/// <summary>The value to display if the actual value is <see cref="float.NaN"/>.</summary>
|
||||
public float DefaultValue { get; set; }
|
||||
|
||||
/// <summary>Optional text to display instead of the regular fields when the value is <see cref="float.NaN"/>.</summary>
|
||||
public string DisabledText { get; set; }
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="UnitsAttribute"/>.</summary>
|
||||
protected UnitsAttribute() { }
|
||||
|
||||
/// <summary>Creates a new <see cref="UnitsAttribute"/>.</summary>
|
||||
public UnitsAttribute(string suffix)
|
||||
{
|
||||
Multipliers = new float[] { 1 };
|
||||
Suffixes = new string[] { suffix };
|
||||
}
|
||||
|
||||
/// <summary>Creates a new <see cref="UnitsAttribute"/>.</summary>
|
||||
public UnitsAttribute(float[] multipliers, string[] suffixes, int unitIndex = 0)
|
||||
{
|
||||
Multipliers = multipliers;
|
||||
Suffixes = suffixes;
|
||||
UnitIndex = unitIndex;
|
||||
|
||||
Debug.Assert(multipliers.Length == suffixes.Length,
|
||||
$"[Units] The {nameof(multipliers)} and {nameof(suffixes)} arrays have different lengths.");
|
||||
Debug.Assert((uint)UnitIndex < (uint)multipliers.Length,
|
||||
$"[Units] The {nameof(unitIndex)} is outside the {nameof(multipliers)} array.");
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f4ed3dc29f5f9a49b5c355028aec9db
|
||||
timeCreated: 1516751545
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user