Animancer v7.3

Released 2022-07-03

When upgrading to a newer version of Animancer, you must delete any previous version from your project first.

See the Animancer v7.0 Upgrade Guide if you're upgrading from a version older than that.

Features

  • Made StateMachine<TState> and its children [Serializable].
    • The Serialized Fields pattern is now the recommended way of setting up a state machine in most situations.
  • Added ICopyable<T> to standardize types with a CopyFrom method.
    • Added AnimancerUtilities.Clone as an extension method.
    • Implemented that interface in all Transition Types. #195
  • Added AnimancerTransitionAssetBase.UnShared which is an UnShared class that can have any type of Transition Asset assigned to it (instead of only a specific type).
  • Improved the Pack Textures window:
    • It will now re-pack Sprites that were already packed into textures so that wasted space in the original textures doesn't affect the new packing.
    • Fixed several bugs with specific input asset configurations.
  • Added the ability to specify an environment prefab in the Transition Preview Window via its Settings tab. #199

Examples

All Examples

  • Improved the information blocks at the start of each example:
    • Removed Difficulty because calling them "Beginner" or "Intermediate" wasn't a very useful distinction.
    • Removed Namespace because that isn't important information and the example scripts don't have detailed comments so linking to the namespace's API page wasn't useful either.
    • Recommended After is now a key point (previously is was included on the same line as Difficulty).
    • Added Learning Outcomes to outline what you are expected to learn from that example so that if you feel you haven't learned something by the end you can re-read it or ask for Help.
Old New
  • Added code architecture diagrams to all examples.
  • Added support for the new Input System Package in the examples (as well as the legacy Input Manager).
  • Added a Humanoid-PistolShoot animation and a Pistol model for various examples.
  • Cleaned up the Humanoid-Walk, Humanoid-Run, and Spider Bot animations a bit.
  • Removed the GolfPutt and Tennis animations and models.
  • Cleaned up all example UI canvases.
  • All example objects now have materials so they can get properly updated by SRP (because apparently the default material can't).
  • Fixed example scene lighting to use a Spot Light instead of Directional because it's attached to the camera and having a continually moving Directional Light was causing warnings in Unity 2022.

Specific Examples

  • Basics completely remade everything:
    • Quick Play now only covers the scene setup and plays a single animation on startup.
    • Basic Movement swaps between Idle and Move animations based on whether a key is being held.
    • Basic Action performs an Action when the user clicks the mouse and then returns to Idle.
    • Transitions implements the same logic as Basic Action but with Fading between animations.
    • Basic Character combines Basic Movement and Transitions to explain some of the issues that arise when you start implementing more complex behaviours.
    • Playing and Fading has been removed since its important points are now covered by Transitions.
    • Moved Named Animations to the Fine Control group since it isn't necessary to understand how to use Animancer and isn't a recommended workflow.
  • Fine Control:
    • Renamed Spider Bot to Speed and Time.
      • It no longer involves inheritance since it was confusing for beginners.
      • Instead, it uses a [SerializeReference] for its Move animation so that the Polymorphic Drawer system can allow the Directional Mixers to reuse the same script with a 2D Mixer.
    • Greatly simplified the OnValidate method in Doors.
  • Directional Sprites:
  • Events:
    • Changed FootstepEvents to be sealed and have FootstepEventsAnimation reference it with a field instead of inheriting because it was confusing to beginners.
    • Simplified Golf Events to only contain one character demonstrating hybrid Animancer Events instead of also re-explaining the regular ways of using each system that were already explained in Footstep Events.
  • State Machines completely remade everything:
    • Removed Game Manager. It was supposed to be a short introduction to demonstrate how Animancer's FSM could be used for a non-animation situation, but it ended up being way too long by explaining all the other irrelevant details like enums, switches, camera movement, text formatting, etc. so now Characters does the job much better anyway.
    • Removed Brain Transplants because it spent far too long explaining things that weren't directly relevant to Animancer or even how to use the FSM system.
    • Renamed Interrupt Management to Interruptions.
    • Completely replaced Characters to re-implement the same behaviour as Basic Character using Animancer's Finite State Machine.
    • Changed Brains, Interruptions, and Weapons to directly reuse the same scripts from Characters instead of having their own slightly different copies. This just means the Characters scripts have some parts which aren't explained until later example.
    • Included an example scene for Weapons. It isn't very good since the example animations are limited, but it works as a proof of concept while the documentation shows what it could look like with a proper character and animations.
  • Layers completely remade everything:
    • Split the old example into two which are based on the behaviour of Basic Character instead of using UI buttons.
    • Basic Layers for playing and masking.
    • Dynamic Layers for playing the Action on the whole body if the character would be Idle or just the upper body while they Walk.
  • Animator Controllers:

Improvements

  • The Layer header is no longer shown in the AnimancerComponent Inspector when there's only one and has all default values. This can be disabled as a Display Option.
  • Added OptionalWarning.LockedEvents.
    • Added AnimancerEvent.Sequence.ShouldNotModifyReason and SetShouldNotModifyReason.
    • When a Transition is played it calls SetShouldNotModifyReason to explain that modifying the events on a state played from a Transition is a common source of bugs.
    • When an AnimancerEvent.Sequence is modified, if its ShouldNotModifyReason has been set, it logs OptionalWarning.LockedEvents (with the reason included in the warning message).
    • The AnimancerEvent.Sequence.endEvent field is no longer public, but now has an EndEvent property.
    • Changed the other properties relating to End Events to not use ref returns because they now need to properly detect when their value is set (for OptionalWarning.LockedEvents).
  • Added AnimancerComponent Inspector warnings if there are multiple animation systems trying to control the same object:
    • Multiple AnimancerComponents on the same object targeting the same Animator.
    • A Legacy Animation component on the same object as the target Animator.
  • Added an AnimancerComponent Inspector warning when a state is playing at Weight == 0 with AnimancerPlayable.KeepPlayablesConnected set to false.
  • Added AnimancerLayer.WeightlessThreshold as a small leeway value for GetOrCreateWeightlessState.
  • Added PlayableAssetState.AppendDetails to describe its Bindings.
  • Added ClipTransition.Length.
  • Added ClipTransitionSequence.AddEvent for adding events relative to the entire sequence. #183
  • Added AnimancerEvent.Sequence.AddAllEvents for turning Animation Events from an AnimationClip into Animancer Events. #198
  • Added AnimancerTransitionAssetBase.UnShared.ClearCachedEvents.
  • Added support for NO_RUNTIME_PLAYER_PREFS Conditional Compilation Symbol to remove all usage of PlayerPrefs from Runtime Builds because it is not allowed on some platforms.
  • Added assertions to ensure that MixerState and ControllerState parameters are not NaN or Infinity.
  • Added AnimancerUtilities.GetUnsupportedMessage and CreateUnsupportedArgumentException.
  • Added AnimancerTransitionAssetBase as the base class of AnimancerTransitionAsset<T>.
  • Added assertions to Transition Assets to give more useful errors if you try to use them when their transition isn't assigned.
  • Added an Open Animancer Tools button to the AnimationClip Inspector.
  • Added overloads of EndEventReceiver.GetFadeOutDuration which take an AnimancerState.
  • Added AnimancerState.DelayedPause. #207
  • Added non-generic IStateMachine interface.
  • Added keyed StateMachine<TKey, TState>.WithDefault.

Changes

  • Un-sealed lots of classes.
  • Replaced ControllerState.KeepStateOnStop with ActionsOnStop to give individual control over each layer.
    • ActionOnStop.Continue can be used for sync layers so it doesn't try to control them (because Unity gives a warning for that but doesn't give Animancer any way to detect which layers are synced at runtime).
    • Removed ControllerState.NormalizedStartTime since it overlaps with the new ActionsOnStop and only worked on Layer 0 anyway.
  • Replaced the exception for reaching the maximum state depth in AnimancerLayer.GetOrCreateWeightlessState with OptionalWarning.MaxStateDepth since it is only a recommendation anyway.
  • Changed the default NormalizedStartTime of ClipTransition and PlayableAssetTransition to NaN instead of 0 so they won't use FadeMode.FromStart by default and will share the same default behaviour as playing an AnimationClip.
  • Changed the default value of SoloAnimation.ApplyInEditMode to false to avoid modifying scene objects unexpectedly.
  • Changed AnimancerPlayable.StateDictionary.Create and GetOrCreate to not connect the states to layer 0. If you want to do that, you can use animancerComponent.Layers[0].CreateState instead.
  • Changed AnimancerPlayable.StateDictionary.ReferenceKeysOnly into an EqualityComparer so you could potentially assign a custom comparer rather than only the two included in Animancer.
  • Removed the code that disables object selection in the Transition Preview Window.
  • Cleaned up PlayableAssetState.InitializeBindings.
  • Refactored AnimancerToolsWinow:
    • Moved it into the Animancer.Editor.Tools namespace.
    • Moved the panels out of it so they are no longer nested classes.
    • It now uses reflection to gather the tools rather than hard coding them as individual fields so new tools can be added without modifying the window.
  • Removed the exception for adding a new layer beyond the AnimancerPlayable.LayerList.Capacity. It now just doubles the capacity like a regular list.
  • Removed the standard Animation Event names systems (SimpleEventReceiver and EndEventReceiver).
    • SimpleEventReceiver was inefficient due to requiring an AnimationEvent parameter (which allocates garbage every time an event is triggered) to backtrack and try to figure out which animation the event actually came from to avoid triggering the callback in response to an event from the wrong state.
    • EndEventReceiver was unreliable because it relied on registering your callback as an End Event but didn't actually prevent Animancer from checking and triggering that End Event like it normally would, meaning you might as well just use an End Event.
    • Those scripts were originally created before Animancer Events were implemented and have been removed because they don't facilitate an effective workflow for any common use case.
    • If you still want to use those scripts, they're available on request (simply use any of the contact methods listed on the Help page).
    • ExitEvent is still included because it serves a notably different purpose (though its use is generally not encouraged).

Fixes

  • Fixed AnimancerPlayable to not give compile warnings in Unity 2022.1. #208
  • Fixed InvalidCastException in ControllerState.ValidateHasParameter, AnimancerPlayableDrawer.DoNativeAnimatorControllerGUI, and ControllerTransition.Drawer.DoChildPropertyGUI when using an Animator Controller loaded from an Asset Bundle.
  • Fixed potential InvalidCastException in SpriteEditor.
  • Fixed AnimancerPlayable.TryGetOutput to actually work.
  • Fixed Animancer Events on looping animations to be triggered properly when calling AnimancerComponent.Play repeatedly.
  • Fixed potential NullReferenceException in AnimationGatherer.
  • Fixed the TransitionPreviewWindow to not disable scripts with runInEditMode, ExecuteAlways, or ExecuteInEditMode.
    • This prevents it from breaking SpriteSkin components from the 2D Animation package.
  • Fixed TransitionPreviewWindow.OpenOrClose to not give warnings about camera rotation in 2D Mode in Unity 2021.2.
  • Fixed incorrect Binding Type Mismatch error in PlayableAssetState. #171
  • Fixed PlayableAssetState to properly bind an INotificationReceiver to a SignalTrack.
  • Fixed "PlayableGraph was not destroyed" warning in AnimationClipEditor if you exit Play Mode with an AnimationClip asset showing in the Inspector.
  • Fixed AnimancerState.EventDispatcher.GetLoopDelta to work correctly when the nextTime is exactly on the eventTime. #205
  • Fixed AnimancerState.HasEvents to not get a sequence from the ObjectPool if it has an EventDispatcher without a sequence when accessing the AnimancerState.Events.
  • Fixed ControllerState.RawTime to allow the time to be set while it is paused. #207
  • Fixed AnimationBindings to not clear its cache every time the hierarchy is changed.
  • Fixed EndEventReceiver.TryInvokeOnEndEvent to not complain about a missing receiver if it found one that has no events.
  • Fixed possible ArgumentException in AnimancerEvent.Sequence.Insert.
  • Fixed the "playing at 0 weight" Inspector warning to not appear when the state is fading.
  • Fixed SerializableEventSequenceDrawer height to only take up one line when showing the "Multi-object editing message".
  • Fixed mixer transitions to not allow their Animations to be edited when multiple objects are selected with different values. Previously, one of the objects would immediately overwrite the others.
  • Fixed ClipTransitionSequence.IsLooping to not cause infinite recursion when there is only one clip.
  • Fixed the base UnShared.Asset property setter to clear the cached State and Events.
  • Fixed "Identifier uniqueness violation" issues in the Modify Sprites and Rename Sprites tools by adding support for the 2D Sprite package.
  • Fixed the fade duration to be calculated correctly for a layer if its state is already mid-fade.
  • Fixed several incorrect values in [DefaultValue] attributes (0 instead of 0f).