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);
This was the issue. Unity's default sprite set has a gap around the outside. Removing the sprite from the Image component removed the gap. Thank you :)
– G-Reusch