logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class ProceduralExpressionScaffoldGenerator

    Static utility class for generating ProceduralExpression assets. Creates complete scaffold with proper references and folder structure.

    Inheritance
    object
    ProceduralExpressionScaffoldGenerator
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.ProceduralExpression.Infrastructure.Editor
    Assembly: Serenity.UnityProceduralExpression.Infrastructure.Editor.dll
    Syntax
    public static class ProceduralExpressionScaffoldGenerator

    Methods

    AssetsExist(string, string)

    Checks if assets already exist at the given root path.

    Declaration
    public static bool AssetsExist(string rootPath, string namePrefix)
    Parameters
    Type Name Description
    string rootPath

    Root path to check.

    string namePrefix

    Name prefix for assets.

    Returns
    Type Description
    bool

    True if any assets exist.

    CreateConstantWeightProvider(string, string, string, float)

    Creates a ConstantWeightProviderSO asset.

    Declaration
    public static ConstantWeightProviderSO CreateConstantWeightProvider(string folderPath, string namePrefix, string name, float value)
    Parameters
    Type Name Description
    string folderPath

    Folder path for the asset.

    string namePrefix

    Prefix for the asset filename (typically prefab name).

    string name

    Descriptive name for the weight provider.

    float value

    Constant weight value.

    Returns
    Type Description
    ConstantWeightProviderSO

    CreateFolderStructure(string)

    Creates the folder structure for a ProceduralExpression setup.

    Declaration
    public static bool CreateFolderStructure(string rootPath)
    Parameters
    Type Name Description
    string rootPath

    Root path starting with Assets/

    Returns
    Type Description
    bool

    True if successful, false if failed.

    CreateFolderStructure(string, out string)

    Creates the folder structure for a ProceduralExpression setup.

    Declaration
    public static bool CreateFolderStructure(string rootPath, out string error)
    Parameters
    Type Name Description
    string rootPath

    Root path starting with Assets/

    string error

    Error message if creation fails.

    Returns
    Type Description
    bool

    True if successful, false if failed.

    CreatePeriodicOscillationLayer(string, string, string, List<string>, UnityStateKey, float, Vector3, Vector3)

    Creates a PeriodicOscillationLayerSO asset using a list of selected bones. Automatically selects the best primary bone from the list.

    Declaration
    public static PeriodicOscillationLayerSO CreatePeriodicOscillationLayer(string folderPath, string namePrefix, string name, List<string> selectedBoneIds, UnityStateKey intensityKey = null, float frequency = 0.25, Vector3 positionScale = null, Vector3 rotationScale = null)
    Parameters
    Type Name Description
    string folderPath

    Folder path for the asset.

    string namePrefix

    Prefix for the asset filename (typically prefab name).

    string name

    Descriptive name for the layer.

    List<string> selectedBoneIds

    List of available bone IDs.

    UnityStateKey intensityKey

    Optional state key controlling oscillation intensity.

    float frequency

    Oscillation frequency in Hz.

    Vector3 positionScale

    Position animation scale.

    Vector3 rotationScale

    Rotation animation scale.

    Returns
    Type Description
    PeriodicOscillationLayerSO

    CreatePeriodicOscillationLayer(string, string, string, string, UnityStateKey, float, Vector3, Vector3)

    Creates a PeriodicOscillationLayerSO asset. Applies sine-wave periodic oscillation to target bones.

    Declaration
    public static PeriodicOscillationLayerSO CreatePeriodicOscillationLayer(string folderPath, string namePrefix, string name, string primaryBoneId, UnityStateKey intensityKey = null, float frequency = 0.25, Vector3 positionScale = null, Vector3 rotationScale = null)
    Parameters
    Type Name Description
    string folderPath

    Folder path for the asset.

    string namePrefix

    Prefix for the asset filename (typically prefab name).

    string name

    Descriptive name for the layer.

    string primaryBoneId

    Bone ID for the primary bone to oscillate.

    UnityStateKey intensityKey

    Optional state key controlling oscillation intensity.

    float frequency

    Oscillation frequency in Hz.

    Vector3 positionScale

    Position animation scale.

    Vector3 rotationScale

    Rotation animation scale.

    Returns
    Type Description
    PeriodicOscillationLayerSO

    CreateProfile(string, string, UnityRigDefinition, ProceduralLayerSO[], ProceduralActionSO[], RuleSO[], string, List<UnityMaterialTargetMapping>, ProceduralLayerSO[])

    Creates a ProceduralExpressionProfileSO asset.

    Declaration
    public static ProceduralExpressionProfileSO CreateProfile(string folderPath, string name, UnityRigDefinition editorRig, ProceduralLayerSO[] layers, ProceduralActionSO[] actions, RuleSO[] rules, string prefabAssetPath = null, List<UnityMaterialTargetMapping> materialTargets = null, ProceduralLayerSO[] baseLayers = null)
    Parameters
    Type Name Description
    string folderPath

    Folder path for the asset.

    string name

    Name for the profile (used in filename).

    UnityRigDefinition editorRig

    Editor rig reference.

    ProceduralLayerSO[] layers

    Array of procedural layers.

    ProceduralActionSO[] actions

    Array of procedural actions.

    RuleSO[] rules

    Array of rules.

    string prefabAssetPath

    Optional prefab asset path as fallback for rig assignment.

    List<UnityMaterialTargetMapping> materialTargets

    Optional material targets for auto-registration.

    ProceduralLayerSO[] baseLayers

    Optional base layers that are always active regardless of rules.

    Returns
    Type Description
    ProceduralExpressionProfileSO
    Remarks

    NOTE: The layers and actions parameters are kept for backward compatibility but are ignored. With the new Rules-as-composition-root architecture, layers and actions are derived from rules. Pass base layers via the baseLayers parameter for always-active layers.

    CreateSetLayerWeightRule(string, string, string, ProceduralLayerSO, WeightProviderSO, int, float, float)

    Creates a RuleSO asset for SetLayerWeight effect with an inline AlwaysTrue condition.

    Declaration
    public static RuleSO CreateSetLayerWeightRule(string folderPath, string namePrefix, string name, ProceduralLayerSO targetLayer, WeightProviderSO weightProvider, int priority = 100, float blendInSeconds = 0.5, float blendOutSeconds = 0.5)
    Parameters
    Type Name Description
    string folderPath

    Folder path for the asset.

    string namePrefix

    Prefix for the asset filename (typically prefab name).

    string name

    Descriptive name for the rule.

    ProceduralLayerSO targetLayer

    Layer to set weight on.

    WeightProviderSO weightProvider

    Provider for weight value.

    int priority

    Rule priority (higher = evaluated first).

    float blendInSeconds

    Blend-in duration.

    float blendOutSeconds

    Blend-out duration.

    Returns
    Type Description
    RuleSO

    CreateStateKey(string, string, string, Vector2, Color)

    Creates a UnityStateKey asset.

    Declaration
    public static UnityStateKey CreateStateKey(string folderPath, string namePrefix, string name, Vector2 rangeHint, Color debugColor)
    Parameters
    Type Name Description
    string folderPath

    Folder path for the asset.

    string namePrefix

    Prefix for the asset filename (typically prefab name).

    string name

    Descriptive name for the state key.

    Vector2 rangeHint

    Value range hint for the state.

    Color debugColor

    Debug visualization color.

    Returns
    Type Description
    UnityStateKey

    DeleteExistingAssets(string, string)

    Deletes all generated assets at the given root path. Uses the same naming convention as asset creation (with namePrefix).

    Declaration
    public static void DeleteExistingAssets(string rootPath, string namePrefix)
    Parameters
    Type Name Description
    string rootPath

    Root folder path.

    string namePrefix

    Prefix used in asset filenames.

    DetectDefaultMaterialTarget(GameObject)

    Detects a default material target from a prefab. Finds the first Renderer on the prefab (root or children) and creates a mapping. IMPORTANT: The EditorRenderer field is assigned for editor UX, and RendererPath/ColorPropertyName are computed from the renderer for runtime resolution.

    Declaration
    public static UnityMaterialTargetMapping? DetectDefaultMaterialTarget(GameObject prefabRoot)
    Parameters
    Type Name Description
    GameObject prefabRoot

    The prefab root GameObject to search.

    Returns
    Type Description
    UnityMaterialTargetMapping?

    A material target mapping, or null if no renderer found.

    EnsureFolderExists(string, out string)

    Ensures a folder exists, creating it and all parent folders if necessary. Uses AssetDatabase.CreateFolder for proper Unity integration.

    Declaration
    public static bool EnsureFolderExists(string assetPath, out string error)
    Parameters
    Type Name Description
    string assetPath

    The asset path (e.g., "Assets/MyFolder/SubFolder").

    string error

    Error message if creation fails.

    Returns
    Type Description
    bool

    True if folder exists or was created successfully.

    GenerateMinimalIdleSetup(string, string, List<string>, UnityRigDefinition, string)

    Generates the complete minimal idle setup using a list of selected bones. Automatically selects the best chest/spine bone from the list. Also detects and creates default material targets from the prefab.

    Declaration
    public static ProceduralExpressionProfileSO GenerateMinimalIdleSetup(string rootPath, string namePrefix, List<string> selectedBoneIds, UnityRigDefinition editorRig = null, string prefabAssetPath = null)
    Parameters
    Type Name Description
    string rootPath

    Root folder path starting with Assets/

    string namePrefix

    Prefix for all assets (usually prefab name)

    List<string> selectedBoneIds

    List of selected bone IDs

    UnityRigDefinition editorRig

    Optional rig reference for the profile

    string prefabAssetPath

    Optional prefab asset path as fallback for rig assignment

    Returns
    Type Description
    ProceduralExpressionProfileSO

    The created profile, or null if failed.

    GenerateMinimalIdleSetup(string, string, string, UnityRigDefinition, string)

    Generates the complete minimal idle setup.

    Declaration
    public static ProceduralExpressionProfileSO GenerateMinimalIdleSetup(string rootPath, string namePrefix, string chestBoneId, UnityRigDefinition editorRig = null, string prefabAssetPath = null)
    Parameters
    Type Name Description
    string rootPath

    Root folder path starting with Assets/

    string namePrefix

    Prefix for all assets (usually prefab name)

    string chestBoneId

    Bone ID for the chest bone

    UnityRigDefinition editorRig

    Optional rig reference for the profile

    string prefabAssetPath

    Optional prefab asset path as fallback for rig assignment

    Returns
    Type Description
    ProceduralExpressionProfileSO

    The created profile, or null if failed.

    IsValidAssetPath(string, out string)

    Validates an asset path.

    Declaration
    public static bool IsValidAssetPath(string path, out string error)
    Parameters
    Type Name Description
    string path

    The path to validate.

    string error

    Error message if validation fails.

    Returns
    Type Description
    bool

    True if valid, false otherwise.

    NormalizePath(string)

    Normalizes a path to ensure it starts with "Assets/".

    Declaration
    public static string NormalizePath(string path)
    Parameters
    Type Name Description
    string path

    The path to normalize.

    Returns
    Type Description
    string

    Normalized path starting with "Assets/".

    SelectBestPrimaryBone(List<string>)

    Selects the best primary bone from a list of bone IDs for periodic oscillation. Priority: chest bones > spine bones > first bone > "Chest" fallback.

    Declaration
    public static string SelectBestPrimaryBone(List<string> boneIds)
    Parameters
    Type Name Description
    List<string> boneIds

    List of bone IDs to choose from.

    Returns
    Type Description
    string

    The best bone ID for periodic oscillation.

    In this article
    © 2026 Serenity. All Rights Reserved