Hey all, I’ve been grinding my brain against this for half a week, tried solving it several ways but to no avail.
I have written an animpicker and exporter (fbx massager really) in maya that splits a large animation file into named takes, and adds string attrs to an object that my editor script then parses into a dictionary (animSettings is a list of dicts in the code below) with anim names, starts, ends, and wrap details. Eventually I’ll add events as well but for now I’m trying to get new fbx exports to replace the unity anim list completely (including wrap mode which fbx doesnt recognize)
The debug.log at line 47 prints out the correct values, which are read from the modelImporter clips, but the inspector doesnt reflect the changes that the script has made. Do I need to overwrite something with the modelImporter object in order to see the changes saved?
Thanks in advance for any assistance you can provide. I’m an OOP noob and really dont grok this lower level stuff yet.
void OnPreprocessAnimation()
{
var modelImporter = assetImporter as ModelImporter;
//Debug.Log("PreProcessAnim");
modelImporter.clipAnimations = modelImporter.defaultClipAnimations;
foreach (ModelImporterClipAnimation anim in modelImporter.clipAnimations)
{
foreach (Dictionary<string, string> thisAnim in animSettings)
{
if (anim.name == thisAnim["name"])
{
anim.firstFrame = Int32.Parse(thisAnim["start"]) + 1; //im throwing in a +1 just to see the values change
anim.lastFrame = Int32.Parse(thisAnim["end"]) - 1; //will remove these values when working
switch (thisAnim["wrap"])
{
case "Default":
anim.wrapMode = WrapMode.Default;
break;
case "Clamp":
anim.wrapMode = WrapMode.Clamp;
break;
case "ClampForever":
anim.wrapMode = WrapMode.ClampForever;
break;
case "Loop":
anim.wrapMode = WrapMode.Loop;
break;
case "Once":
anim.wrapMode = WrapMode.Once;
break;
case "PingPong":
anim.wrapMode = WrapMode.PingPong;
break;
default:
break;
}
Debug.Log("Found the clip for " + anim.name + ". Start:" + anim.firstFrame.ToString() + ". End:" + anim.lastFrame.ToString() + ". Wrap:" + anim.wrapMode.ToString());
}
}
}
}