How to edit Animation Clip Settings using an editor script

Hi Everyone,
I’m trying to create an animation clip that loops using an editor script. I can do everything except loop the script. I have tried setting the wrapMode to WrapMode.Loop. I have also used AnimationUtility.Get/Set AnimationClipSettings. neither works…If I use the following code, I can see the “Loop Time” checkbox enabled in the inspector, but the animation does not loop. Is it a bug in Unity, or am I doing something wrong?

AnimationClip newClip = new AnimationClip();
                        AnimationClipSettings acs = AnimationUtility.GetAnimationClipSettings(animClip);
                        AnimationClipSettings newSettings = AnimationUtility.GetAnimationClipSettings(newClip);

                        animClip.wrapMode = WrapMode.Loop;
                        newSettings.cycleOffset = acs.cycleOffset;
                        newSettings.heightFromFeet = acs.heightFromFeet;
                        newSettings.keepOriginalOrientation = acs.keepOriginalOrientation;
                        newSettings.keepOriginalPositionXZ = acs.keepOriginalPositionXZ;
                        newSettings.keepOriginalPositionY = acs.keepOriginalPositionY;
                        newSettings.level = acs.level;
                        newSettings.loopBlend = acs.loopBlend;
                        newSettings.loopBlendOrientation = acs.loopBlendOrientation;
                        newSettings.loopBlendPositionXZ = acs.loopBlendPositionXZ;
                        newSettings.loopBlendPositionY = acs.loopBlendPositionY;
                        newSettings.loopTime = true;
                        newSettings.mirror = acs.mirror;
                        newSettings.orientationOffsetY = acs.orientationOffsetY;
                        newSettings.startTime = acs.startTime;
                        newSettings.stopTime = acs.stopTime;
                        newSettings.additiveReferencePoseClip = acs.additiveReferencePoseClip;
                        newSettings.additiveReferencePoseTime = acs.additiveReferencePoseTime;
                        newSettings.hasAdditiveReferencePose = acs.hasAdditiveReferencePose;

                        //ModelImporterClipAnimation blah = animClip as ModelImporterClipAnimation;

                        AnimationUtility.SetAnimationClipSettings(animClip, newSettings);

If “Loop Time” is true, that should be sufficient. Can you confirm that it remains ticked when the application starts playing (and the animation appears to not loop)

I submitted a bug for this. The Case ID is 864049.

Thanks for the help Adam.