Released 2020-12-04
Upgrade Guide
- See the Animancer v5.0 Upgrade Guide first if you're upgrading from a version older than that.
- The
Animancer.FSM
system now uses a newStateChange
system:- The following types no longer require a generic argument:
IState
,StateBehaviour
,DelegateState
. IState.CanEnterState
andCanExitState
are now properties. The State Change Details section explains how to access the previous and next state which were previously passed in as parameters.
- The following types no longer require a generic argument:
Here is a summary of how to modify a state class to accomodate the new changes.
Old
class CharacterState : IState<CharacterState>
{
// Expression Bodied Method:
public virtual bool CanEnterState(CharacterState previousState) => true;
// Regular (Block Bodied) Method:
public virtual bool CanExitState(CharacterState nextState)
{
return true;
}
public virtual void OnEnterState() { }
public virtual void OnExitState() { }
}
New
class CharacterState : IState// Remove the generic argument from IState.
{
// Change the Can... methods to properties.
// Expression Bodied Property:
public virtual bool CanEnterState => true;
// Regular (Block Bodied) Property:
public virtual bool CanExitState
{
get
{
return true;
}
}
// No change to OnEnterState or OnExitState.
public virtual void OnEnterState() { }
public virtual void OnExitState() { }
}
The old previousState
and nextState
that were passed into CanEnterState
and CanExitState
are now accessible via static properties in StateChange<CharacterState>
as well as several other options explained in the State Change Details section.
Major Features
- Added a search bar to the top of the documentation which uses Google Programmable Search.
Native Animator Controllers
Added proper support for Native Animator Controllers (ones assigned to the regular Controller
field on the Animator
component):
- Adding an
AnimancerComponent
no longer clears that field or collapses theAnimator
Inspector. - The
AnimancerComponent
Inspector no longer displays theAnimator
fields nested inside itself since they are now all usable andtheController
field doesn't need to be highlighted as a warning. - Replaced the
Basics/Simple Hybridexample withAnimator Controllers/Hybrid Basics. - Added Controller State Generator to Weaver which can procedurally generate a class that inherits from
ControllerState
with properties for directly accessing the parameters of a specific Animator Controller asset. - Added Generate Transition context menu functions on everything inside Animator Controllers (States, Blend Trees, etc.) which will generate Transition Assets from them.
Animancer Tools
Added the Animancer Tools window which can be opened via Window/Animation/Animancer Tools and has 5 panels:
- Modify Sprites: allows you to modify the
rect
,pivot
,alignment
, andborders
of multiplSprite
s at once. - Rename Sprites: allows you to rename multiple
Sprite
s at once. - Generate Sprite Animations: allows you to generate animations from
Sprite
s based ontheir names. - Remap Sprite Animation: allows you to change an animation to use different
Sprite
s. - Remap Animation Bindings: allows you to change the Hierarchy paths used by an animation. This is particularly useful for bone animations if you want to rename the bones in a model.
Improved State Machines
Improved the Finite State Machine system:
- Added a new system for accessing State Change Details as explained in the Upgrade Guide
- Added State Selectors for managing a prioritised list of potential states.
- Added
Game Managerexample as the first in the State Machines group which demonstrates theAnimancer.FSM
withoutStateBehaviour
s in comparison to an enum based system. It is currently the second longest of all 32 examples (longest is 3D Game Kit).
Flexible Mixer Transitions
Mixer Transitions can now use either AnimationClip
s or Transition Assets (any ITransition
that inherits from UnityEngine.Object
) for their children, meaning that you can now fully set up Nested Mixers using transitions instead of in code.
- Renamed
ManualMixerTransition.Clips
toStates
and changed it from anAnimationClip[]
to anObject[]
. - Added several
AnimancerUtilities.TryGet...
methods that take anObject
and output a particular value from it as anAnimationClip
or the corresponding value from anITransition
.
Minor Features
- Animancer Events:
- The
AnimancerNode
context menu now shows the details of all Animancer Events instead of only the End Events. - Added
AnimancerEvent.Sequence.RemoveCallback
. #77 - Added a
startIndex
parameter toAnimancerEvent.Sequence.IndexOf
andIndexOfRequired
(default value 0). - Added equality operators to
AnimancerEvent
. - Added
AnimancerEvent.Sequence.Serializable.SetNormalizedEndTime
. - Added
ITransitionDetailed.Events
andSerializedEvents
. - Added context menu functions to the
TimeRuler
for all the functions that can be executed via keyboard controls.
- The
- Added
State
as anabstract
class that implementsIState
usingvirtual
methods so you can inherit from it to avoid needing to specify all 4 members ofIState
yourself. - Added
Initialize 8 Directions
function to theThresholds
menu forMixerTransition2D
. - Added
ITransitionDetailed.AverageAngularSpeed
andAverageVelocity
. - Added
AnimancerPlayable.SkipFirstFade
to control whether playing an animation with the Base Layer at 0Weight
should snap theWeight
to 1 (as it did previously) or allow the fade to play normally (so that it can fade from the Native Animator Controller). - Added
AnimancerEditorUtilities.IsNaN
forVector2
andVector3
.
Changes
- Renamed
AnimancerLayer.Play(object)
toTryPlay
to match the name used inAnimancerPlayable
andAnimancerComponent
. - Renamed
AnimancerNode.EditorName
toDebugName
and made it available in Development Builds as well as in the Unity Editor. - Renamed
ControllerState.Parameter
toParameterID
and cleaned up its usage:- It is now a
readonly
struct. - Added a constructor that takes both a
name
andhash
(but doesn't verify them). Float1ControllerState
now exposes itsParameterID
directly instead of having separate properties for the name and hash (same for the2
and3
variants).
- It is now a
- Changed
AnimancerState.Duration
to properly account for the End Time. - Changed
AnimancerState.RemainingDuration
to properly account for the End Time and negative speeds and not give different results for looping animations since End Events don't work any differently for them. - Changed
AnimancerState.IsPlaying
to not bevirtual
and addedOnSetIsPlaying
instead since only the setter should ever be overridden. - Changed
AnimancerUtilities.Wrap01
andAnimancerUtilities.Wrap
to not be extension methods since they aren't used that often. - State Machines:
- Changed
StateMachine
s to not allow the state to be set to null unless you callSetAllowNullStates
first. This assertion is only performed in the Unity Editor and Development Builds. - Removed
StateExtensions.CanEnterState
since it is too similar to theIState.CanEnterState
property. - Removed the
DelegateState
constructor since object initializer syntax is clearer anyway. - Removed the
InterruptManagement.Character
script and modified itsCharacterState
to inherit fromCharacters.CharacterState
now thatStateBehaviour
is no longer generic. - Changed the
StateMachine<TState>.InputBuffer.StateMachine
to a readonly field.
- Changed
- Animancer Events:
- Removed the Inspector toggle from event times which was previously used to remove them.
- Changed the Add Event button in the Inspector into an
X
to remove the selected event (while one is selected). - Changed
AnimancerEvent.Sequence.SetCallback
to triggerOptionalWarning.DuplicateEvent
if necessary. - Changed
AnimancerEvent.Sequence
methods that modify callbacks to throw anArgumentNullException
if the callback is null rather than just logging an assertion. - Moved
AnimancerEvent.Sequence.Serializable.DummyCallback
out toAnimancerEvent
and added aDummy
method so that it has a proper name instead of a compiler generated name for an anonymous method..
- Inverse Kinematics:
- Changed
AnimancerPlayable
,AnimancerLayer
, andMixerState
to store whatever IK flags you set (ApplyAnimatorIK
andApplyFootIK
) so that when a child is added it can get the same flags. - You can disable the static
AnimancerNode.ApplyParentAnimatorIK
andApplyParentFootIK
properties to prevent children from receiving their parent's flags. - Added the IK flags to
AnimancerNode.AppendDescription
. - Removed
IHasIK
and merged it intoIPlayableWrapper
. - Removed
AnimancerPlayable.DefaultApplyAnimatorIK
andDefaultApplyFootIK
.
- Changed
- Removed
AnimancerPlayable.LayerList.RespectSingleLayerWeight
since it is now handled byAnimancerPlayable.SkipFirstFade
. - Removed
AnimancerEditorUtilities.GetIsInspectorExpanded
andSetIsInspectorExpanded
since they are now unused. They were just wrappers aroundUnityEditorInternal.InternalEditorUtility
methods anyway. - Removed
AnimancerUtilities.IfMultiComponentThenChangeType
. - Removed the ability to
Ctrl + Shift + Click
on states in the Inspector to queue them to Cross Fade in a sequence (and the context menu function) since it was more complex to maintain than its usefulness warranted.
Improvements
- The Time bars displayed on states in the
AnimancerComponent
Inspector now scale their height proportional to theAnimancerNode.EffectiveWeight
.- Added a Display Option in the context menu to disable that feature.
- Improved Timeline track binding support:
- Added
OptionalWarning.PlayableAssetAnimatorBinding
in case aPlayableAssetState
tries to bind to the sameAnimator
as Animancer. - The
IsPlaying
state is now propogated onto all tracks. - Tracks which don't require an object to bind will now properly create their output and are shown in the Inspector as a simple label without an
Object
field. - If a binding has the wrong type, it is now highlighted as a warning in the Inspector.
- Added
- Optimised
AnimancerEvent.Sequence
methods that search for a particular item. - Added
Remove
function to the event sub-menus of theAnimancerState
Inspector context menu. - Improved the
AnimationGatherer
to be able to gather clips and transitions separately.
Fixes
- Implemented a workaround for the Serialized Array Initialization Bug for Transitions: if all the fields of a transition are at the default values of their type (i.e.
Fade Duration
andSpeed
at 0 rather than the 0.25 and 1 set by their field initializers) then assigning its main object (i.e. theAnimationClip
for aClipTransition
) will initialize its values properly.- Removed the
Reset Transition
Context Menu Function since it was mainly just a manual workaround for that issue. Inspector Gadgets has Context Menu Functions toReset
,Copy
, andPaste
any serialized field (and many others).
- Removed the
- Fixed
AnimancerLayer.Play(state, fadeDuration, fadeMode)
to set theWeight = 1
if it redirects toPlay(state)
(usually due to havingfadeDuration <= 0
).- Removed
AnimancerEditorUtilities.TopologicalSort
since it is no longer needed.
- Removed
- Fixed
AnimationBindings.GetBindings
to allow gathering multiple times per frame by default and only disable it for GUI calls. - Fixed the
TransitionPreviewWindow
models list to automatically remove duplicates. - Fixed
TransitionPreviewWindow
to not cause errors when it instantiates a copy of an object that has[RequireComponent]
attributes on its components which create a circular reference (A
requiresB
andB
requiresA
). It doesn't seem to be possible to destroy such components so it now just disables all undesirable components instead of destroying them. - Fixed the
TransitionPreviewWindow
to properly initialize the camera when the target has no bounds. - Fixed the keyed
StateMachine
to properly register the default state provided in the constructor. - Fixed
AnimancerGUI.DoOptionalTimeToggle
to properly indicate when the selected objects have different values.- Fixed
AnimancerState.EventRunner
to allow events to be assigned before theAnimancerNode.Root
is set. - Fixed
EventSequenceDrawer
to avoid causing errors when multiple objects are selected with different values.
- Fixed
- Fixed
AnimancerUtilities.Wrap01
andWrap
to never return the maximum value (unlikeMathf.Repeat
). - Animancer Events:
- Fixed
AnimancerState.EventRunner
to allow events to be assigned before theAnimancerNode.Root
is set. - Fixed
EventSequenceDrawer
to avoid causing errors when multiple objects are selected with different values. - Fixed
AnimancerEvent.Sequence.Serializable.OnBeforeSerialize
to not cause an exception if called when there is noEditor.EventSequenceDrawer.Context.Current
.
- Fixed
- Fixed
UnityVersionChecker
to get properly removed when overriding Animancer Lite with Animancer Pro by moving it into theReadMe.cs
file. - Fixed the
AnimancerState
Inspector context menu to disable theInvoke
function for events using theAnimancerEvent.DummyCallback
. - Fixed
TransitionPreviewWindow.GetCurrentState
to not throw an exception if the state doesn't exist. - Fixed the
AssemblyInfo.cs
file to be properly included in Animancer Pro.