- Home /
This question was
closed Jul 24, 2013 at 10:04 PM by
clunk47 for the following reason:
Question was answered, correct answer was accepted.
How to set animations to loop?
I want to set my character's animations to automatically import as looping for my character, but the option seems to have disappeared since Unity 4.0. Is there any way to do it without copying every single animation I have just to free them up in the inspector?
Comment
Best Answer
Answer by clunk47 · Dec 14, 2012 at 08:31 PM
I'd use the wrapmode setting in a script.
animation.wrapMode = WrapMode.Loop;
If you want to do this for ALL animations in scene, try finding all objects w/ animations like this C# Example.
using UnityEngine;
using System.Collections;
public class ctest : MonoBehaviour
{
Animation[] animations;
void Start()
{
animations = (Animation[])Animation.FindObjectsOfType(typeof(Animation));
foreach(Animation a in animations)
{
a.wrapMode = WrapMode.Loop;
}
}
}
If you're taking the second approach, you could just attatch the script to an empty gameObject and it will find all animated objects in scene... Hope this helps.