Coroutine과 InvokeRepeating는 Update와는 다른, 별도의 시간의 간격으로 실행되는 동작을 구현할 수 있다.

Coroutine

using UnityEngine;
using System.Collections;
public class CoroutineTest : MonoBehaviour
{
	private void Start()
	{
		StartCoroutine(Test());
	}
	private IEnumerator Test()
	{
		while(true)
		{
			Debug.Log("InvokeRepeating Test");
				
			yield return null;
		}
	}
}
//실행 결과 : 매 프레임 마다 Log가 찍힌다.

InvokeRepeating

using UnityEngine;
public class InvokeRepeatingTest1 : MonoBehaviour
{
	private void Start()
	{
		InvokeRepeating("Test", 1, 1);
	}
	private void Test()
	{
		Debug.Log("InvokeRepeating Test");
	}
}
//실행 결과 : 1초 후부터, 1초마다 Log가 찍힌다.
using UnityEngine;
public class InvokeRepeatingTest2 : MonoBehaviour
{
	private void Start()
	{
		InvokeRepeating("Test", 1, 1);
				
		Invoke("StopInvokeRepeating", 5);
	}
	private void Test()
	{
		Debug.Log("InvokeRepeating Test");
	}
	private void StopInvokeRepeating()
	{
		CancelInvoke("Test");
	}
}
//실행 결과 : CancelInovke로 5초 후에 실행되던 InokeRepeating으로 실행한 Test가 동작하지 않는다.

Coroutine과 InvokeRepeating의 비교

Coroutine과 InvokeRepeating의 성능

Coroutine과 InvokeRepeating의 사용