Is there any way to batch set clip settings for animation imports, ie the settings shown below in an FBX animation from Mixamo?
I understand that errors can arise due to setting them wrong, however, there are more changes required than resetting the ones that don’t need setting.
You can use AssetPreprocessor, but it seems that many of the examples out there from a few years back in time don’t work properly. Afaik, if you try to use SaveAndReimport to apply settings, import will get stuck in a loop, so better not use it.
Put the script in an Editor folder, otherwise it won’t react to the callbacks.
I think it’s also better and safer to configure your script to only process animations in certain folder (imho) so that you can limit the custom importer’s effect just those folders…
This script gets the defaultAnimationClips, modifies them and then feeds them back after modifications. If you don’t set that modelImporter.clipAnimations like I do in my example, the values don’t get applied.
using UnityEngine;
using UnityEditor;
public class CustomImportAnimation : AssetPostprocessor
{
void OnPreprocessAnimation()
{
if (assetPath.Contains("Animations"))
{
ModelImporter modelImporter = assetImporter as ModelImporter;
var animations = modelImporter.defaultClipAnimations;
for (int i=0; i <animations.Length; i++)
{
animations[i].loopTime = true;
animations[i].loopPose = true;
}
modelImporter.clipAnimations = animations;
Debug.Log("Imported animation with custom settings.");
}
}
}
Those other import settings are easy to modify, most of them can be changed by just setting a value.
Glad I could help you. Why not smash that like button then
One more thing abou using those custom importers; think about situation where you (for some reason) apply Reimport All and you’ve forgotten that you had that kind of script (and haven’t built any checks/limits into it.). It might potentially mess up a big amount of your content in your project… Backups or not, it will take time to restore things as they were.
That’s good advice. I think i’ll use a staging project for importing the animations for this script, then copy them over to my working project. Less chance of mass error.
I really want to know if you have ever met this problem now. I wrote an Editor Script before and now every time I select multiple animation clips it shows the error message
"
ModelImporterEditor.OnInspectorGUI must call ApplyRevertGUI to avoid unexpected behavior.
UnityEditor.ModelImporterEditor:OnDisable()
"
I can’t answer your question. since writing this editor, I haven’t had the error again and have installed several new versions of Unity.
I ultimately stopped using this script, as I was getting some other issues with the animations and was not sure if it was this script or my editing of the anims causing the issue. I’ve also installed a dozen different versions of Unity since I stopped using this script, so I can’t say that I’ve ever had the error appear again.
You could try reinstalling Unity perhaps. Sorry I can’t be of more help.