- Home /
corotuine looping hang the editor.
hi guy i need some help urgent, when i am lerp a color using Color.Lerp(c1,c2,t); in coroutine like
IEnumerator FadeOut() {
while(true) {
if(fader.color.a>0) {
Color clr = Color.Lerp(fader.color, fadeOutColor, Time.deltaTime * 2f);
fader.color = clr;
}
if(fader.color.a <=0.02) {
isStart = false;
}
}
}
Unity editor hang :( after click on play button :(
Answer by ArkaneX · Feb 05, 2014 at 08:16 PM
1) You need
yield return null;
or any other yield inside while loop.
2) Your while loop never ends. You either have to change true to another condition (e.g. while(isStart)
) or when you want to end coroutine, execute yield break
.
3) Your lerping code will not work, because deltaTime is similar each update. Please look at the answer to this question for working code.
came to answer infinite loops make unity crash, but you pretty much solved it, +1
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Vuforia causes lag in editor? 0 Answers
Memory Crash / Hang on build Unity 4.5.3f3 1 Answer
ScriptableObject problem 1 Answer
cant stop my animation 0 Answers