I searched some more and found a solution for my issue. In case its of use to anyone else, here's the example code of what I found on the Unity forums:
// Coroutiner.js
// this class is just used to run coroutines and needs
// no further functionality
class Coroutiner extends MonoBehaviour
{
}
// Test.js
// a class inheriting from System.Object, using
// coroutines:
class Test extends System.Object
{
public static var coroutineRunner : Coroutiner = null;
function Test()
{
if (coroutineRunner == null)
{
var go = new GameObject("Coroutiner");
coroutineRunner = go.AddComponent(Coroutiner);
}
}
function Go()
{
coroutineRunner.StartCoroutine(MyCoroutine());
}
function MyCoroutine()
{
yield;
Debug.Log("it worked!");
}
}
↧