chore: initial commit
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animancer
|
||||
{
|
||||
/// <summary>[Assert-Conditional]
|
||||
/// A <see cref="HelpURLAttribute"/> which points to Animancer's documentation.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
|
||||
[System.Diagnostics.Conditional(Strings.Assertions)]
|
||||
public class AnimancerHelpUrlAttribute : HelpURLAttribute
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="AnimancerHelpUrlAttribute"/>.</summary>
|
||||
public AnimancerHelpUrlAttribute(string url)
|
||||
: base(url)
|
||||
{ }
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="AnimancerHelpUrlAttribute"/>.</summary>
|
||||
public AnimancerHelpUrlAttribute(Type type)
|
||||
: base(GetApiDocumentationUrl(type))
|
||||
{ }
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Returns a URL for the given `type`'s API Documentation page.</summary>
|
||||
public static string GetApiDocumentationUrl(Type type)
|
||||
=> GetApiDocumentationUrl(Strings.DocsURLs.Documentation + "/api/", type);
|
||||
|
||||
/// <summary>Returns a URL for the given `type`'s API Documentation page.</summary>
|
||||
public static string GetApiDocumentationUrl(string prefix, Type type)
|
||||
{
|
||||
var url = StringBuilderPool.Instance.Acquire();
|
||||
|
||||
url.Append(prefix);
|
||||
|
||||
if (!string.IsNullOrEmpty(type.Namespace))
|
||||
url.Append(type.Namespace).Append('/');
|
||||
|
||||
url.Append(type.Name.Replace('`', '_'));
|
||||
|
||||
return url.ReleaseToString();
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 378a8fd785e3db746ab5397f4d959e0d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
namespace Animancer
|
||||
{
|
||||
/// <summary>[Editor-Conditional]
|
||||
/// A <see cref="DefaultValueAttribute"/> which uses the <see cref="AnimancerGraph.DefaultFadeDuration"/> and 0.
|
||||
/// </summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer/DefaultFadeValueAttribute
|
||||
///
|
||||
public class DefaultFadeValueAttribute : DefaultValueAttribute
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override object Primary => AnimancerGraph.DefaultFadeDuration;
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="DefaultValueAttribute"/>.</summary>
|
||||
public DefaultFadeValueAttribute()
|
||||
{
|
||||
// This won't change so there's no need to box the value every time by overriding the property.
|
||||
Secondary = 0f;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8142045e327ce4340b15c6580c89b79f
|
||||
timeCreated: 1516751545
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
using System;
|
||||
|
||||
namespace Animancer
|
||||
{
|
||||
/// <summary>[Editor-Conditional] Specifies the default value of a field and a secondary fallback.</summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer/DefaultValueAttribute
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public class DefaultValueAttribute : Attribute
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>The main default value.</summary>
|
||||
public virtual object Primary { get; protected set; }
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>The fallback value to use if the target value was already equal to the <see cref="Primary"/>.</summary>
|
||||
public virtual object Secondary { get; protected set; }
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="DefaultValueAttribute"/>.</summary>
|
||||
public DefaultValueAttribute(object primary, object secondary = null)
|
||||
{
|
||||
Primary = primary;
|
||||
Secondary = secondary;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="DefaultValueAttribute"/>.</summary>
|
||||
protected DefaultValueAttribute() { }
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 486843cd37aea9b4697ec896db0b0592
|
||||
timeCreated: 1516751545
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
using System;
|
||||
|
||||
namespace Animancer
|
||||
{
|
||||
/// <summary>[Editor-Conditional]
|
||||
/// Causes an Inspector field in an <see cref="ITransition"/>
|
||||
/// to be drawn after its events where the events would normally be drawn last.
|
||||
/// </summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer/DrawAfterEventsAttribute
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class DrawAfterEventsAttribute : Attribute { }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e36db3eac3c4bb4c9c97a4833cb0cce
|
||||
timeCreated: 1516751545
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,366 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
#endif
|
||||
|
||||
namespace Animancer
|
||||
{
|
||||
/// <summary>[Editor-Conditional]
|
||||
/// Specifies a set of acceptable names for <see cref="AnimancerEvent"/>s
|
||||
/// so they can display a warning in the Inspector if an unexpected name is used.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Placing this attribute on a type applies it to all fields in that type.
|
||||
/// <para></para>
|
||||
/// <strong>Documentation:</strong>
|
||||
/// <see href="https://kybernetik.com.au/animancer/docs/manual/events/animancer/usage#event-names">
|
||||
/// Event Names</see>
|
||||
/// <para></para>
|
||||
/// <strong>Example:</strong><code>
|
||||
/// [EventNames(...)]// Apply to all fields in this class.
|
||||
/// public class AttackState
|
||||
/// {
|
||||
/// [SerializeField]
|
||||
/// [EventNames(...)]// Apply to only this field.
|
||||
/// private ClipTransition _Action;
|
||||
/// }
|
||||
/// </code>
|
||||
/// See the constructors for examples of their usage.
|
||||
/// </remarks>
|
||||
///
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer/EventNamesAttribute
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class | AttributeTargets.Struct, Inherited = true)]
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class EventNamesAttribute : Attribute
|
||||
#if UNITY_EDITOR
|
||||
, IInitializable<MemberInfo>
|
||||
#endif
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>[Editor-Only] The names that can be used for events in the attributed field.</summary>
|
||||
public StringReference[] Names { get; private set; }
|
||||
|
||||
/// <summary>[Editor-Only] Has the <see cref="Names"/> array been initialized?</summary>
|
||||
public bool HasNames
|
||||
=> !Names.IsNullOrEmpty();
|
||||
#endif
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="EventNamesAttribute"/>
|
||||
/// with <see cref="Names"/> from the attributed type or declaring type of the attributed member.</summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <strong>Example:</strong><code>
|
||||
/// [EventNames]// Use all StringReference fields in this class for any transitions in this class.
|
||||
/// public class AttackState
|
||||
/// {
|
||||
/// public static readonly StringReference HitStart = "Hit Start";
|
||||
/// public static readonly StringReference HitEnd = "Hit End";
|
||||
///
|
||||
/// [SerializeField]
|
||||
/// [EventNames]// Use all StringReference fields in this class.
|
||||
/// private ClipTransition _Animation;
|
||||
///
|
||||
/// protected virtual void Awake()
|
||||
/// {
|
||||
/// _Animation.Events.SetCallback(HitStart, OnHitStart);
|
||||
/// _Animation.Events.SetCallback(HitEnd, OnHitEnd);
|
||||
/// }
|
||||
///
|
||||
/// private void OnHitStart() { }
|
||||
/// private void OnHitEnd() { }
|
||||
/// }
|
||||
/// </code></remarks>
|
||||
public EventNamesAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="EventNamesAttribute"/> containing the specified `names`.</summary>
|
||||
/// <remarks>
|
||||
/// <strong>Example:</strong><code>
|
||||
/// public class AttackState
|
||||
/// {
|
||||
/// [SerializeField]
|
||||
/// [EventNames("Hit Start", "Hit End")]
|
||||
/// private ClipTransition _Animation;
|
||||
///
|
||||
/// protected virtual void Awake()
|
||||
/// {
|
||||
/// _Animation.Events.SetCallback("Hit Start", OnHitStart);
|
||||
/// _Animation.Events.SetCallback("Hit End", OnHitEnd);
|
||||
/// }
|
||||
///
|
||||
/// private void OnHitStart() { }
|
||||
/// private void OnHitEnd() { }
|
||||
/// }
|
||||
/// </code></remarks>
|
||||
public EventNamesAttribute(params string[] names)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Names = StringReference.Get(names);
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="EventNamesAttribute"/> with <see cref="Names"/> from the `type`.</summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// If the `type` is an enum, all of its values will be used.
|
||||
/// <para></para>
|
||||
/// Otherwise the values of all static <see cref="string"/> and
|
||||
/// <see cref="StringReference"/> fields will be used.
|
||||
/// <para></para>
|
||||
/// <strong>Example:</strong><code>
|
||||
/// public class AttackState
|
||||
/// {
|
||||
/// public static readonly StringReference HitStart = "Hit Start";
|
||||
/// public static readonly StringReference HitEnd = "Hit End";
|
||||
///
|
||||
/// [SerializeField]
|
||||
/// [EventNames(typeof(AttackState))]// Use all StringReference fields in this class.
|
||||
/// private ClipTransition _Animation;
|
||||
///
|
||||
/// protected virtual void Awake()
|
||||
/// {
|
||||
/// _Animation.Events.SetCallback(HitStart, OnHitStart);
|
||||
/// _Animation.Events.SetCallback(HitEnd, OnHitEnd);
|
||||
/// }
|
||||
///
|
||||
/// private void OnHitStart() { }
|
||||
/// private void OnHitEnd() { }
|
||||
/// }
|
||||
/// </code></remarks>
|
||||
///
|
||||
/// <exception cref="ArgumentNullException"/>
|
||||
public EventNamesAttribute(Type type)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Initialize(type);
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="EventNamesAttribute"/> with <see cref="Names"/> from a member in the `type`
|
||||
/// with the specified `name`.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The specified member must be static and can be a Field, Property, or Method.
|
||||
/// <para></para>
|
||||
/// The member type can be anything implementing <see cref="IEnumerable"/> (including arrays, lists, and
|
||||
/// coroutines).
|
||||
/// <para></para>
|
||||
/// <strong>Example:</strong><code>
|
||||
/// public class AttackState
|
||||
/// {
|
||||
/// public static readonly StringReference[] Events = { "Hit Start", "Hit End" };
|
||||
///
|
||||
/// [SerializeField]
|
||||
/// [EventNames(typeof(AttackState), nameof(Events))]// Get the names from AttackState.Events.
|
||||
/// private ClipTransition _Animation;
|
||||
///
|
||||
/// protected virtual void Awake()
|
||||
/// {
|
||||
/// _Animation.Events.SetCallback(Events[0], OnHitStart);
|
||||
/// _Animation.Events.SetCallback(Events[1], OnHitEnd);
|
||||
/// }
|
||||
///
|
||||
/// private void OnHitStart() { }
|
||||
/// private void OnHitEnd() { }
|
||||
/// }
|
||||
/// </code></remarks>
|
||||
///
|
||||
/// <exception cref="ArgumentNullException"/>
|
||||
/// <exception cref="ArgumentException">No member with the specified `name` exists in the `type`.</exception>
|
||||
///
|
||||
public EventNamesAttribute(Type type, string name)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
var obj = GetValue(type, name)
|
||||
?? throw new ArgumentException(
|
||||
$"The collection retrieved from {type.GetNameCS()}.{name} is null");
|
||||
|
||||
if (obj is not IEnumerable collection)
|
||||
throw new ArgumentException(
|
||||
$"The object retrieved from {type.GetNameCS()}.{name} is not an {nameof(IEnumerable)}");
|
||||
|
||||
using (ListPool<StringReference>.Instance.Acquire(out var names))
|
||||
{
|
||||
foreach (var item in collection)
|
||||
{
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
var itemName = item.ToString();
|
||||
if (string.IsNullOrEmpty(itemName))
|
||||
continue;
|
||||
|
||||
names.Add(itemName);
|
||||
}
|
||||
|
||||
if (names.Count == 0)
|
||||
throw new ArgumentException($"The collection retrieved from {type.GetNameCS()}.{name} is empty");
|
||||
|
||||
Names = names.ToArray();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
#if UNITY_EDITOR
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Initializes the <see cref="Names"/> if they weren't already set in the constructor.</summary>
|
||||
public void Initialize(MemberInfo member)
|
||||
{
|
||||
if (HasNames)
|
||||
return;
|
||||
|
||||
if (member == null)
|
||||
throw new ArgumentNullException(nameof(member));
|
||||
|
||||
if (member is Type type)
|
||||
{
|
||||
Initialize(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
Names = GatherNames(member.DeclaringType);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Initializes the <see cref="Names"/> if they weren't already set in the constructor.</summary>
|
||||
public void Initialize(Type type)
|
||||
{
|
||||
if (HasNames)
|
||||
return;
|
||||
|
||||
if (type == null)
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
|
||||
if (type.IsEnum)
|
||||
{
|
||||
Names = StringReference.Get(Enum.GetNames(type));
|
||||
}
|
||||
else
|
||||
{
|
||||
Names = GatherNames(type);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static object GetValue(Type type, string name)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
|
||||
if (name == null)
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
|
||||
var field = type.GetField(name, AnimancerReflection.StaticBindings);
|
||||
if (field != null)
|
||||
return field.GetValue(null);
|
||||
|
||||
var property = type.GetProperty(name, AnimancerReflection.StaticBindings);
|
||||
if (property != null)
|
||||
return property.GetValue(null, null);
|
||||
|
||||
var method = type.GetMethod(name, AnimancerReflection.StaticBindings, null, Type.EmptyTypes, null);
|
||||
if (method != null)
|
||||
return method.Invoke(null, null);
|
||||
|
||||
throw new ArgumentException($"{type.GetNameCS()} does not contain a member named '{name}'");
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static StringReference[] GatherNames(Type type)
|
||||
{
|
||||
using (ListPool<StringReference>.Instance.Acquire(out var names))
|
||||
{
|
||||
while (type != null)
|
||||
{
|
||||
var fields = type.GetFields(AnimancerReflection.StaticBindings | BindingFlags.DeclaredOnly);
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
|
||||
if (field.DeclaringType.Assembly.FullName.StartsWith("Unity"))
|
||||
continue;
|
||||
|
||||
StringReference name;
|
||||
|
||||
if (field.FieldType == typeof(string))
|
||||
{
|
||||
name = (string)field.GetValue(null);
|
||||
}
|
||||
else if (field.FieldType == typeof(StringReference))
|
||||
{
|
||||
name = (StringReference)field.GetValue(null);
|
||||
}
|
||||
else continue;
|
||||
|
||||
if (!name.IsNullOrEmpty() && !names.Contains(name))
|
||||
names.Add(name);
|
||||
}
|
||||
|
||||
type = type.BaseType;
|
||||
}
|
||||
|
||||
if (names.Count == 0)
|
||||
return null;
|
||||
|
||||
names.Sort();
|
||||
return names.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private string _Prefix;
|
||||
private string _NamesToString;
|
||||
|
||||
/// <summary>Returns a string containing all the <see cref="Names"/>.</summary>
|
||||
public string NamesToString(string prefix, string delimiter = "\n• ")
|
||||
{
|
||||
if (!HasNames)
|
||||
return prefix;
|
||||
|
||||
if (_NamesToString != null && _Prefix == prefix)
|
||||
return _NamesToString;
|
||||
|
||||
var text = StringBuilderPool.Instance.Acquire();
|
||||
|
||||
_Prefix = prefix;
|
||||
text.Append(prefix);
|
||||
|
||||
for (int i = 0; i < Names.Length; i++)
|
||||
text.Append(delimiter).Append(Names[i]);
|
||||
|
||||
return _NamesToString = text.ReleaseToString();
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
#endif
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6cecce105052724d99e5197ef26fdad
|
||||
timeCreated: 1516751545
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
using System;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace Animancer.Editor
|
||||
{
|
||||
/// <summary>[Editor-Conditional]
|
||||
/// A <see cref="MovedFromAttribute"/> which indicates that a type may have been previously
|
||||
/// defined in the pre-compiled Animancer Lite DLL in an earlier version of Animancer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This allows <see cref="UnityEngine.SerializeReference"/> fields of the attributed type
|
||||
/// to retain their values when upgrading from Animancer Lite to Animancer Pro.
|
||||
/// </remarks>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Editor/InternalSerializableTypeAttribute
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true)]
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class InternalSerializableTypeAttribute : MovedFromAttribute
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="InternalSerializableTypeAttribute"/>.</summary>
|
||||
public InternalSerializableTypeAttribute()
|
||||
: base(true, sourceAssembly: Strings.LiteAssemblyName)
|
||||
{
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2582013e6d855fc4493ecf34833c8fa9
|
||||
timeCreated: 1516751545
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
using System;
|
||||
|
||||
namespace Animancer
|
||||
{
|
||||
/// <summary>[Editor-Conditional]
|
||||
/// Specifies a custom display label for the <c>Thresholds</c> column of a mixer transition.
|
||||
/// </summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer/ThresholdLabelAttribute
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class | AttributeTargets.Struct, Inherited = true)]
|
||||
[System.Diagnostics.Conditional(Strings.UnityEditor)]
|
||||
public sealed class ThresholdLabelAttribute : Attribute
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>[Editor-Only] The label.</summary>
|
||||
public readonly string Label;
|
||||
#endif
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="ThresholdLabelAttribute"/>.</summary>
|
||||
public ThresholdLabelAttribute(string label)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Label = label;
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ca52e7a7aa74b8419c97f26eccc641b
|
||||
timeCreated: 1516751545
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b78168dc02519bc418b0484be8f4a4ff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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