Skip to content

A small hack that allows you to use coroutines in classes not inherited from MonoBehaviour

License

Notifications You must be signed in to change notification settings

TinyPlay/Coroutine-Provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Unity Coroutine Provider

A small hack that allows you to use coroutines in classes not inherited from MonoBehaviour

Usage

You can use coroutines in your classes that do not use MonoBehaviour. For example, like this:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TinyPlay.Utils;

public class MyClass{
  // Constructor
  public MyClass(){
  }
  
  // Simple Method for Run Coroutine
  public void DoSomeStuff(){
    CoroutineProvider.Start(MyRoutine());
  }
  
  // Coroutine
  private IEnumerator MyRoutine(){
    yield return new WaitForSeconds(10f);
    Debug.Log("It's Work!");
  }
}

About

A small hack that allows you to use coroutines in classes not inherited from MonoBehaviour

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages