while(true) ?

function Start()
{
	abc();
}

function abc()
{
	while(true)
	{
	 transform.Translate(Vector3.forward * Time.deltaTime);
	 
	if(Input.GetKey("1"))
	return;
	
	 yield;
	}	 
}

I think while(true) means while function abc once called.

Is my thought right?

Then why don’t use function update() if continuous working of something needed.

I’m unsure. But my noobish self would do this:

function update(){
abc(true);
}

function abc(var true){
while(true){

}
}

A while loop continues to loop as long as the condition is true. If just you supply “true” as the condition, it will naturally always evaluate as true and therefore will continue looping forever, unless the loop is broken some other way.

It’s not continuous: “if(Input.GetKey(“1”)) return;” That makes the function end if the “1” key is pressed.

I’m not sure what you’re attempting there, but it accomplishes literally nothing at all.

–Eric

function update(){
abc(true);
}

function abc(var true){
while(true){

}
}

this will carry the var true, with a value.

abc(false);

would result in the code within the while loop to not run.

No, it won’t. In fact that code wouldn’t even compile; “var true” is a syntax error. I guess you want

function Update(){ 
   abc(true); 
} 

function abc(var runLoop : boolean){ 
   while(runLoop){ 

   } 
}

However, that’s still pointless…calling “abc(false)” wouldn’t do anything, so why bother? And if you called “abc(true)”, you’d be starting a new infinite loop every frame, so in short order you’d have thousands of infinite loops running all at once, and then it would crash.

–Eric

Yeah, the easiest way to lock up any program is with while(true){}. Thats called an infinite loop. Always make sure there is a way within the loop where the value being evaluated can be switched to false or if you have code that jumps out of it like a return.

ah oops.