Code generation tool to create type safe wrapper for Unity3D's Animator API.
Unity3D uses a string-based API to control its animation state machines. As a result developers do not get compile-time checks on their parameter names, or auto-complete in their code editor.
This tool automates this process of writing Animator
boilerplate,
generating a script exposes a property for each state machine parameter, and
regenerating when they change.
Available as a Unity3D package.
Add the following entry to your <Project>/Packages/manifest.json
:
{
"dependencies": {
"games.feed.destringer": "https://github.com/rhys-vdw/unity-destringer.git",
}
}
Unity will download the package automatically.
Create an AnimatorWrapper object that can be configured to generate a script.
Once given a RuntimeAnimationController
hit the "Generate" button. This
object will automatically update the script whenever its assigned controller
changes.
This will attach generated scripts to any selected GameObjects with animators, creating and updating as necessary.
Given the following animator:
destringer will generate a C# script with the following properties:
public int FidgetType
{
get => _animator.GetInteger(FidgetTypeProperty);
set { _animator.SetInteger(FidgetTypeProperty, value); }
}
public void Fidget()
{
_animator.SetTrigger(FidgetProperty);
}
public bool IsEmerged
{
get => _animator.GetBool(IsEmergedProperty);
set { _animator.SetBool(IsEmergedProperty, value); }
}
public bool IsTransitioning
{
get => _animator.GetBool(IsTransitioningProperty);
set { _animator.SetBool(IsTransitioningProperty, value); }
}
public float NormalizedTimeOffset
{
get => _animator.GetFloat(NormalizedTimeOffsetProperty);
set { _animator.SetFloat(NormalizedTimeOffsetProperty, value); }
}