Class ModelAnimatorCreator
Creates (or wires) an UnityEditor.Animations.AnimatorController for a model prefab, and edits the states of an
already-created one. Mirrors Serenity.GameSave.Infrastructure.Editor.Builder.GameSaveCreator's
shape for the one-time controller creation (Input/SerenityCreationValidationResult/Result DTOs,
Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction rollback-on-failure). The per-state edits below it
(AddState(string, int, string), RenameState(string, int, string, string), DeleteState(string, int, string), SetDefaultState(string, int, string),
SetStateMotion(string, int, string, string, string)) target an EXISTING controller asset and are never routed through that
transaction — a creation-transaction rollback deletes the assets IT created, and this controller was
not one of them; each edit instead follows the plain Unity idiom
(UnityEditor.Undo.RegisterCompleteObjectUndo(UnityEngine.Object,System.String) → mutate → UnityEditor.EditorUtility.SetDirty(UnityEngine.Object) +
UnityEditor.AssetDatabase.SaveAssets).
Inheritance
ModelAnimatorCreator
Assembly: Serenity.AnimationHub.Editor.dll
Syntax
public static class ModelAnimatorCreator
Methods
AddState(string, int, string)
Adds a new empty state to a layer's root state machine, grid-positioned past every existing
state so it never overlaps one (states default to overlapping at (0,0) otherwise).
Declaration
public static ModelAnimatorCreator.StateOperationResult AddState(string controllerAssetPath, int layerIndex, string stateName)
Parameters
| Type |
Name |
Description |
| string |
controllerAssetPath |
|
| int |
layerIndex |
|
| string |
stateName |
|
Returns
Validates the request, then creates an UnityEditor.Animations.AnimatorController (optionally seeded with an
"Idle" default state) and wires it onto the model prefab. On any failure every mutation is rolled
back so the project is left untouched.
Declaration
public static ModelAnimatorCreator.Result CreateControllerForModel(ModelAnimatorCreator.Input input)
Parameters
Returns
DeleteState(string, int, string)
Removes a state from its containing state machine — its own outgoing transitions are
removed with it; a transition on ANOTHER state that targeted it is left with a null destination,
the same dangling shape ModelAnimationScanner already tolerates.
Declaration
public static ModelAnimatorCreator.StateOperationResult DeleteState(string controllerAssetPath, int layerIndex, string statePath)
Parameters
| Type |
Name |
Description |
| string |
controllerAssetPath |
|
| int |
layerIndex |
|
| string |
statePath |
|
Returns
RenameState(string, int, string, string)
Renames a state, resolving statePath through nested sub-state-machines
the same way ModelAnimationScanner flattens them.
Declaration
public static ModelAnimatorCreator.StateOperationResult RenameState(string controllerAssetPath, int layerIndex, string statePath, string newName)
Parameters
Returns
SetDefaultState(string, int, string)
Marks a state as the default of its containing (sub-)state machine.
Declaration
public static ModelAnimatorCreator.StateOperationResult SetDefaultState(string controllerAssetPath, int layerIndex, string statePath)
Parameters
| Type |
Name |
Description |
| string |
controllerAssetPath |
|
| int |
layerIndex |
|
| string |
statePath |
|
Returns
SetStateMotion(string, int, string, string, string)
Assigns a clip to a state's motion. clipSubAssetName resolves an FBX-embedded
clip by sub-asset name via UnityEditor.AssetDatabase.LoadAllAssetRepresentationsAtPath(System.String); leave it
empty (the default) for a standalone .anim asset, resolved by clipAssetPath alone.
Declaration
public static ModelAnimatorCreator.StateOperationResult SetStateMotion(string controllerAssetPath, int layerIndex, string statePath, string clipAssetPath, string clipSubAssetName = null)
Parameters
Returns
Declaration
public static SerenityCreationValidationResult Validate(ModelAnimatorCreator.Input input)
Parameters
Returns
| Type |
Description |
| SerenityCreationValidationResult |
|