Class PrefabProceduralExpressionApplier
Static utility class for applying ProceduralExpression components to prefabs. Handles component addition, bone auto-detection, and reference wiring.
Inherited Members
Namespace: Serenity.ProceduralExpression.Infrastructure.Editor
Assembly: Serenity.UnityProceduralExpression.Infrastructure.Editor.dll
Syntax
public static class PrefabProceduralExpressionApplier
Methods
ApplyToPrefab(GameObject, ProceduralExpressionProfileSO, bool)
Applies ProceduralExpression components to a prefab.
Declaration
public static PrefabProceduralExpressionApplier.ApplyResult ApplyToPrefab(GameObject prefabAsset, ProceduralExpressionProfileSO profile, bool skipRigSetup = false)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | prefabAsset | The prefab asset (not an instance). |
| ProceduralExpressionProfileSO | profile | The ProceduralExpressionProfileSO to assign. |
| bool | skipRigSetup | If true, assumes rig definition is already configured and skips auto-population. |
Returns
| Type | Description |
|---|---|
| PrefabProceduralExpressionApplier.ApplyResult | Result containing success status, warnings, and errors. |
DetectAllBoneIds(GameObject)
Detects all bone IDs in a prefab hierarchy. Returns a list of bone ID strings (names) without creating bindings.
Declaration
public static List<string> DetectAllBoneIds(GameObject prefabRoot)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | prefabRoot | The root GameObject to search. |
Returns
| Type | Description |
|---|---|
| List<string> | List of detected bone ID strings. |
DetectAllBones(GameObject)
Detects all known bones in a prefab hierarchy. Returns a list of BoneBindings that can be used to populate a rig definition.
Declaration
public static List<BoneBinding> DetectAllBones(GameObject prefabRoot)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | prefabRoot | The root GameObject to search. |
Returns
| Type | Description |
|---|---|
| List<BoneBinding> | List of detected BoneBindings. |
DetectChestBone(GameObject, UnityRigDefinition)
Detects the best chest bone ID from the prefab hierarchy.
Declaration
public static string DetectChestBone(GameObject prefabRoot, UnityRigDefinition rig = null)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | prefabRoot | The root GameObject to search. |
| UnityRigDefinition | rig | Optional rig definition to check for existing bones. |
Returns
| Type | Description |
|---|---|
| string | The best chest bone ID, or null if none found. |
GetOrAddComponent<T>(GameObject)
Gets an existing component or adds a new one.
Declaration
public static T GetOrAddComponent<T>(GameObject root) where T : Component
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | root |
Returns
| Type | Description |
|---|---|
| T |
Type Parameters
| Name | Description |
|---|---|
| T |
IsValidPrefab(GameObject, out GameObject, out string)
Checks if a GameObject is a valid prefab that can be modified.
Declaration
public static bool IsValidPrefab(GameObject obj, out GameObject resolvedPrefab, out string errorMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | obj | The GameObject to check. |
| GameObject | resolvedPrefab | The resolved prefab asset if valid. |
| string | errorMessage | Error message if not valid. |
Returns
| Type | Description |
|---|---|
| bool | True if the object is a valid, modifiable prefab. |
ResolveToSourcePrefab(GameObject)
Resolves a scene instance to its source prefab asset.
Declaration
public static GameObject ResolveToSourcePrefab(GameObject obj)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | obj |
Returns
| Type | Description |
|---|---|
| GameObject |
ResolveToSourcePrefab(GameObject, out string)
Resolves a scene instance or any object to its source prefab asset. Works with prefab assets, scene instances, and nested prefabs.
Declaration
public static GameObject ResolveToSourcePrefab(GameObject obj, out string errorMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | obj | The GameObject to resolve. |
| string | errorMessage | Error message if resolution fails. |
Returns
| Type | Description |
|---|---|
| GameObject | The source prefab asset, or null if not resolvable. |
ValidateSetup(GameObject)
Validates a prefab for ProceduralExpression setup.
Declaration
public static List<string> ValidateSetup(GameObject prefab)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | prefab |
Returns
| Type | Description |
|---|---|
| List<string> |