public class CustomFbxPostprocessor : AssetPostprocessor
ModelImporter modelImporter = (ModelImporter)assetImporter;
// Check if the file is an FBX (you can extend this for other model types if needed)
if (assetPath.ToLower().EndsWith(".fbx"))
// Set the animation type to Humanoid
modelImporter.animationType = ModelImporterAnimationType.Humanoid;
// Set the scale factor to 100
modelImporter.globalScale = 1.0f; // Use 1.0f instead of 100.0f to avoid unexpected scale issues (Unity's internal scale handling)
void OnPreprocessAnimation()
ModelImporter modelImporter = (ModelImporter)assetImporter;
// Make sure the model is set to humanoid before processing animations
if (modelImporter.animationType == ModelImporterAnimationType.Humanoid)
ModelImporterClipAnimation[] clipAnimations = modelImporter.defaultClipAnimations;
foreach (var clip in clipAnimations)
// Set the Y position to be based on the center of mass (Root motion baking settings)
clip.heightFromFeet = false;
// Set 'Bake Into Pose' for root transform position and rotation
clip.lockRootHeightY = true;
clip.lockRootPositionXZ = true;
clip.lockRootRotation = true;
// Apply the modified clip settings
modelImporter.clipAnimations = clipAnimations;
void OnPostprocessModel(GameObject importedObject)
// Disable lights, cameras, and other unnecessary components
foreach (Transform child in importedObject.transform)
if (child.gameObject.GetComponent<Light>() != null || child.gameObject.GetComponent<Camera>() != null)
GameObject.DestroyImmediate(child.gameObject);
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
foreach (string assetPath in importedAssets)
if (assetPath.ToLower().EndsWith(".fbx"))
// Load the GameObject from the asset path
GameObject importedObject = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
if (importedObject != null)
// Disable lights, cameras, and other unnecessary components
foreach (Transform child in importedObject.transform)
if (child.gameObject.GetComponent<Light>() != null || child.gameObject.GetComponent<Camera>() != null)
GameObject.DestroyImmediate(child.gameObject);
// Load all associated animation clips and modify them
var animations = AssetDatabase.LoadAllAssetsAtPath(assetPath);
foreach (var asset in animations)
if (asset is AnimationClip clip)
// Modify the animation clip settings
AnimationClipSettings settings = AnimationUtility.GetAnimationClipSettings(clip);
settings.keepOriginalPositionY = false; // Set to false to enable custom root motion behavior
settings.keepOriginalPositionXZ = false;
settings.keepOriginalOrientation = false;
AnimationUtility.SetAnimationClipSettings(clip, settings);
// Optional: Additional modifications on AnimationCurves, etc.
Debug.Log($"Modified AnimationClip: {clip.name} for asset: {assetPath}");
Place this script in an "Editor" folder within your project (e.g., "Assets/Editor").
Unity will automatically invoke the asset postprocessor when importing FBX files.