AnimatorGraph class

A whole state machine. Immutable: an editor replaces it.

Constructors

AnimatorGraph({List<AnimatorParameter> parameters = const [], List<AnimatorState> states = const [], List<AnimatorTransition> transitions = const [], String entry = '', String atlasPath = ''})
A graph of states joined by transitions that read parameters, starting in entry. Empty by default.
const
AnimatorGraph.fromJson(Map<String, dynamic> json)
Reads the .animator.json form (toJson's shape). Missing lists are empty and entries that are not maps are skipped.
factory
AnimatorGraph.parse(String source)
Reads source, the text of an .animator.json, as fromJson does. Throws a FormatException when it is not JSON, not a JSON object, or broken as fromJson says (an UnsupportedFormatVersionException when it is from a newer engine).
factory

Properties

atlasPath → String
The atlas the clips were picked from. A hint for tools — the entity's own sprite animation says what actually plays.
final
entry → String
The state an animator starts in; empty starts in the first.
final
entryState → AnimatorState?
Where an animator starts: entry, else the first state.
no setter
hashCode → int
The hash code for this object.
no setterinherited
parameters → List<AnimatorParameter>
The values its transitions' conditions read.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
states → List<AnimatorState>
Its states. The first is where an animator starts when entry is empty.
final
transitions → List<AnimatorTransition>
Its transitions. Their order breaks ties of priority.
final
usesVersion2 → bool
Whether it uses what version 1 can't hold: a crossfading transition or a blend tree.
no setter

Methods

copyWith({List<AnimatorParameter>? parameters, List<AnimatorState>? states, List<AnimatorTransition>? transitions, String? entry, String? atlasPath}) → AnimatorGraph
A copy with the given fields replaced; the lists are shared, not copied.
encode() → String
toJson as text indented by two spaces: what an .animator.json file holds.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parameterNamed(String name) → AnimatorParameter?
The first parameter called name, or null.
stateNamed(String name) → AnimatorState?
The first state called name, or null.
toJson() → Map<String, dynamic>
The .animator.json form: version (formatVersion), atlas when set, entry, parameters, states and transitions.
toString() → String
A string representation of this object.
inherited
transitionsFrom(String state) → List<AnimatorTransition>
The transitions an animator in state may take, in the order they are tried: those from Any State (except into state itself), then state's own; within each, the highest priority first and, among equals, the one listed first. Only transitions into a state that exists. Worked out once per state.
validate() → List<String>
What is wrong with this graph, in words an author can act on: its states and their names, the entry, transitions to and from states that don't exist or that test missing parameters, and its blend trees and crossfades. Empty when nothing is.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

versionOf(Map<String, dynamic> json) → int
The version json declares; 1 when it declares none, as a hand-made file may not. Throws a FormatException when version is not a whole number from 0 up.

Constants

formatVersion → const int
The newest file format version this reads. A graph is written as version 1 unless it uses a version 2 feature (usesVersion2), so files that don't need the new format stay byte for byte as they were.