logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    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
    object
    ModelAnimatorCreator
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Editor.AnimationHub.Authoring
    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
    Type Description
    ModelAnimatorCreator.StateOperationResult

    CreateControllerForModel(Input)

    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
    Type Name Description
    ModelAnimatorCreator.Input input
    Returns
    Type Description
    ModelAnimatorCreator.Result

    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
    Type Description
    ModelAnimatorCreator.StateOperationResult

    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
    Type Name Description
    string controllerAssetPath
    int layerIndex
    string statePath
    string newName
    Returns
    Type Description
    ModelAnimatorCreator.StateOperationResult

    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
    Type Description
    ModelAnimatorCreator.StateOperationResult

    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
    Type Name Description
    string controllerAssetPath
    int layerIndex
    string statePath
    string clipAssetPath
    string clipSubAssetName
    Returns
    Type Description
    ModelAnimatorCreator.StateOperationResult

    Validate(Input)

    Validates a request without creating anything. Re-checked at the top of CreateControllerForModel(Input).

    Declaration
    public static SerenityCreationValidationResult Validate(ModelAnimatorCreator.Input input)
    Parameters
    Type Name Description
    ModelAnimatorCreator.Input input
    Returns
    Type Description
    SerenityCreationValidationResult
    In this article
    © 2026 Serenity. All Rights Reserved