- Home /
Unity 5.2.1 : InvokeRepeating in a while statement makes my PC Freeze
Ok guys , after programming a bit I needed to Invoke Repeat in a while statement. That's a script example :
function Button1 () //This is attached to a button
{
if (bool1==false && bool2==false)
{
Button1CoolDown();
}
while (bool1==true && bool2==true)
{
InvokeRepeating("Button2",0.1,1);
}
}
function Button1CoolDown()
{
//DO THINGS
}
function Button2()
{
Button1CoolDown();
}
//Basically that script auto clicks the button when bool1 and 2 are true.
What happens there it's that unity and my PC start freezing and I need to power off the PC.
When you are in the while you have provided no way of breaking out.
Unity Lockdown Im$$anonymous$$ent!
I don't want to break out. That should continue with System.DateTime...
Then you should place the code in a coroutine and yield inside the loop to allow the program to continue. You DO want to exit the loop. Your freezing pc says so.
Also, do you really want to Invoke InvokeRepeating so much? InvokeRepeating already calls many repeat functions so stacking the call in a while loop is asking for trouble. Sure you wanted to InvokeRepeating just once and leave that method handle the rest?
Your answer
Follow this Question
Related Questions
ground detection fails 0 Answers
transform.position not working in OnControllerColliderHit 2 Answers
Why is unity lagging so much? 1 Answer
need to refind script execution order from before crashing without touching to other settings 0 Answers
Issue - Bounds.SetMinMax calculate negative extents 0 Answers