Created
April 2, 2017 16:00
-
-
Save tsubaki/01bff322efc1fe8ba54a0456d20eee90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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