Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CoroutineSample : MonoBehaviour {
IEnumerator coroutine;
void Awake()
{
coroutine = Sample ();
}
void OnEnable()
{
StartCoroutine (coroutine);
}
void OnDisable()
{
StopCoroutine (coroutine);
}
IEnumerator Sample()
{
int count = 0;
while (true) {
count++;
Debug.Log (count);
yield return new WaitForSeconds (0.3f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment