EventNamesAttribute.

EventNamesAttribute(Type, string) Constructor

Summary

Creates a new Animancer.EventNamesAttribute with Animancer.EventNamesAttribute.Names from a member in the `type` with the specified `name`.
Assembly
Animancer.dll
Namespace
Animancer
Containing Type
EventNamesAttribute

Syntax

public EventNamesAttribute(Type type, string name)

Examples

public class AttackState
{
    public static readonly string[] Events = { "Hit Start", "Hit End" };

    [SerializeField]
    [EventNames(typeof(AttackState), nameof(Events))]// Get the names from AttackState.Events.
    private ClipTransition _Animation;

    private void Awake()
    {
        _Animation.Events.SetCallback(Events[0], OnHitStart);
        _Animation.Events.SetCallback(Events[1], OnHitEnd);
    }

    private void OnHitStart() { }
    private void OnHitEnd() { }
}

Remarks

The specified member must be static and can be a Field, Property, or Method.

The member type can be anything implementing System.Collections.IEnumerable (including arrays, lists, and coroutines).

Parameters

Name Type Description
type Type
name string

Return Value

Type Description
void