Animation stops after camera loses focus. Pls have a look

In my below code function repeat is called when play button is pressed. Onfocus() is called when on OnTrackingfound() and Onfocuslost() is called on OnTrackinglost() . The problem is the animation gets stuck when the camera loses focus of the target when the animation is playing. I want it to replay everytime it loses focus if the nimation is not completed.

var compressor : GameObject; 

var condenser : GameObject;

var repeating : boolean = true;

var menu : GameObject;

var back : GameObject;

var next : GameObject;

var play : GameObject;

var in1 : GameObject;

var in2 : GameObject;

var in3 : GameObject;

var in4 : GameObject;

var in5 : GameObject;

function Update()
{
	
}

function Repeat(){


if(repeating == true)
{


yield Wait();

}




}

function Wait(){

compressor.animation.Play("Take 001");

yield WaitForSeconds (compressor.animation["Take 001"].clip.length);

repeating = false;

play.gameObject.SetActive(false);

menu.gameObject.SetActive(true);

back.gameObject.SetActive(true);Debug.Log("wait");

next.gameObject.SetActive(true);

}

function Onfocus(){

if (compressor.animation.IsPlaying("Take 001") && repeating == true){

play.gameObject.SetActive(true);

menu.gameObject.SetActive(false);

back.gameObject.SetActive(false);

next.gameObject.SetActive(false);

}	

Debug.Log("Onfocus");
}

function Onfocuslost(){

condenser.gameObject.SetActive(false);

play.gameObject.SetActive(false);

in1.gameObject.SetActive(false);

in2.gameObject.SetActive(false);

in3.gameObject.SetActive(false);

in4.gameObject.SetActive(false);

in5.gameObject.SetActive(false);

menu.gameObject.SetActive(false);

back.gameObject.SetActive(false);

next.gameObject.SetActive(false);

Debug.Log("Onfocuslost");

}

I had this issue with the old animation system (not mecanim) and it took me quite some time to figure it out.

Unity will per default stop animations when they are not visible. This is just a setting in the editor and you can change the culling type to “always animate”.

Have a look here: