Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created April 2, 2017 16:00
Show Gist options
  • Save tsubaki/01bff322efc1fe8ba54a0456d20eee90 to your computer and use it in GitHub Desktop.
Save tsubaki/01bff322efc1fe8ba54a0456d20eee90 to your computer and use it in GitHub Desktop.
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