Problem with deactivating animateOnlyIfVisible

If I set Animation.animateOnlyIfVisible to false on a game object before any animation has been played on it, no animations will play on that game object. If I, on the other hand, first start an animation on the game object, and then turn off animateOnlyIfVisible in the next frame, everything works as expected.

Some pseudocode to clarify (where gameObject is a gameobject which has just been created and no animations has been started on it yet):

In this case the animation won’t play:
gameObject.animation.animateOnlyIfVisible = false;
gameObject.animation.CrossFade(“Idle”, 0.3f);

In this case the animation won’t play either:
gameObject.animation.CrossFade(“Idle”, 0.3f);
gameObject.animation.animateOnlyIfVisible = false;

In this case the animation will play:
Executed in frame X:
gameObject.animation.CrossFade(“Idle”, 0.3f);
Executed in frame X+1:
gameObject.animation.animateOnlyIfVisible = false;

Has anyone else experienced this? Is it a known bug? If not I could probably set up a scene reproducing it and submit a bug report.

I am using Unity Pro 2.6.1f3. The models are .fbx -files created in Maya.

copy that,
i’m working with Unity3 and have the same problem.
I just figured out that if you set it in the editors inspector to false it work too.

To set it via script to false (and that’s important because of frequent model exchanges) you can use Start() as a coroutine.

Since i’m programming with C# you have to change the result-type to IEnumerator and simply put these two lines at the end:

IEnumerator Start()
{
...
...
    yield return null;
    animation.animateOnlyIfVisible = false;
}

That basically do exactly what you suggest. It seems that you don’t have to start an animation first, but i’m not sure about that. For me the changes above do the job, thanks.