IEnumerator unity crash

whats wrong? why does this freeze up unity? the while statement wrong?

using UnityEngine;
using System.Collections;

public class Combos : MonoBehaviour {
	
	private bool combo1;
	public int chainTime;
	public float counter=0;
	private bool count=false;
	
	public AnimateTiledTexture animateTiledTex;
	private int comboNumber=0;
	
	void Start () 
	{
		animateTiledTex=gameObject.GetComponent<AnimateTiledTexture>();
	}
	
	void Update () 
	{
		print (combo1);
		if(Input.GetKeyDown(KeyCode.UpArrow))
		{
			count=true;
			StartCoroutine(Combo1());
		}
		
		if(count)
		{
			counter +=Time.deltaTime;
		}
			
	}
	private IEnumerator Combo1 ()
	{
		int i=0;
		while(counter < chainTime)
		{
			if(Input.GetKeyDown(KeyCode.RightArrow))
				i+=1;
			if(Input.GetKeyDown(KeyCode.DownArrow)  i==1)
				i+=1;
			if(Input.GetKeyDown(KeyCode.LeftArrow)  i==2)
				combo1=true;
				
		}
		yield return new WaitForSeconds(chainTime);
			
		//combo1=false;
		//count=false;
		//counter=0;
		
	}
}

You never increase the value of counter or yield inside the loop so it becomes infinite.

this doesn’t count?

 if(count)

        {

            counter +=Time.deltaTime;

        }

and so this yield return new WaitForSeconds(chainTime); should be inside the loop?

If I understand your code correctly, the yield needs to be in the loop.

The counter increase is in Update not in the loop. That loop is going to run in a single frame until the condition is met. And yes - the yield should be in the loop if you don’t want the entire loop to run in a single frame.