Awesome
unity-dots-animation
Simple animation system for the unity dots stack.
Samples
Benchmark Scence
To execute the sample:
- Open or create a unity 2022.2 project using the URP pipeline
- Add the package using the package manager -> "Add package from git url" using the https url of this repo
- Go to the samples tab of this package in the package manager and open the benchmark sample
- Open the "SampleScene"
Usage
Setup
- Install the package using the package manager -> "Add package from git url" using the https url of this repo
- Add the
AnimationsAuthoring
component to the root entity of a rigged model/prefab - Add animation clips to the "clips" list
- Add the
SkinnedMeshAuthoring
component to any children that should be deformed (have a skinned mesh renderer)
Now the first animation clip should be executed on entering playmode.
Playing & switching animations
Use the AnimationAspect
to to easily play and switch animations.
The animation clip will also start from 0 even if the same index is used again.
This example plays the animationClip with index 1 for all entities:
var clipIndex = 1;
foreach (var animationAspect in SystemAPI.Query<AnimationAspect>())
{
animationAspect.Play(clipIndex);
}
This example blends from the current clip to the next with the specified duration & set it to loop:
var clipIndex = 1;
foreach (var animationAspect in SystemAPI.Query<AnimationAspect>())
{
animationAspect.Crossfade(clipIndex, 0.5f, true);
}
For more advanced usage, you can modify the AnimationPlayer
component directly.