I’m attempting to access the loop time boolean of an animation clip. By default it is set to false if you create an animation clip through code. Its simple to change in the inspector, but I’m making a large amount of clips, and prefer to set this through code. Does anyone have any idea’s how to change it in c#? Looping could be done solely through the wrapmode before, but I cannot figure out this loop time. :sad:
Heres an image of how it looks in the inspector (at the top of the image)
If this interests anyone, I’ve been able to access the loop time using the AnimationUtility and getting the AnimationClipSettings, but when I change the boolean value, it does not actually change the loop time boolean for the clip. Heres the code:
AnimationClip t = AssetDatabase.LoadAssetAtPath("Assets/Animations/testing/MyAnim.anim", typeof(AnimationClip)) as AnimationClip;
AnimationClipSettings tSettings = AnimationUtility.GetAnimationClipSettings(t);
Debug.Log (tSettings.loopTime);
tSettings.loopTime = true;
Debug.Log (tSettings.loopTime);
The first log will return false, while the second will return true. But the clip does not actually change, and the inspector’s checkbox still shows false. Is GetAnimationClipSettings() just returning a copy of the settings? I should note, there is no info on this in the documentation, so this would purely be from experience.
Furthermore, the SetAnimationClipSettings() is private, so I’m unable to access it.
The WrapMode will set your wrap mode to loop, but as of 4.3 the loop time variable needs to be set as well. The loop time variable is a part of the animation clip settings. If you create the animation clip through the gui it will always be set to true. Unfortuantly the reverse for creating clips through code.
Here is a screen shot of the debug mode for the animation clip inspector. As you can see, wrap mode is set to loop, but loop time is false. The actual animator will loop on it, but the animation will not loop until loop time is checked.
From the way it looks the code you posted above should work, I’m not sure what is going wrong with it…but I am curious as to why there is nothing on the AnimationUtility.GerAnimationClipSettings() method in the documentation http://docs.unity3d.com/Documentation/ScriptReference/AnimationUtility.html
I don’t know, try saving it closing unity (or rebooting your computer) and trying again? That’s the best I know, but maybe someone with a little more information will be able to help you out.
Thanks anyway Sild! I tried rebooting, but didn’t help. Theres gotta be some way to adjust that variable. It would just help if that area was documented :p.
Does anyone have experience with accessing the loop time variable?
Hate to bump this, but this issue could lead to a hell of a lot of work when creating animations through script. I’m looking at using this to import animations for about 10 -20 characters, each having 30-40 animations. That would mean I’d have to pass through 300 - 800 clips, and set the loop time value for each one. Unfortunately, this only became a problem with 4.3
Is there some other route I should take with this issue? As I said before, the most difficult part is the lack of documentation in this area.
This is a major issue. Its not just loop time, but all the other properties of the used-to-be-documented AnimationClipSettings that make it impossible to do some very simple things with Mecanim.
I tried this, and it works! Except…AnimationUtility is part of UnityEditor, and is not available in builds. Has anyone found a way around this? Any other way to access AnimationClipSettings?
Wrap Mode could be used, except loopTime doesn’t change the Wrap Mode. It stays at Default regardless of whether loopTime is checked or not. Seems like a big oversight.