private static IEnumerator DuktapeCoroutineRun(DuktapeObject val) { // scratch code val.PushProperty(val.ctx, "thread"); var thread = DuktapeDLL.duk_get_context(val.ctx, -1); DuktapeDLL.duk_pop(val.ctx); if (thread == IntPtr.Zero || thread == val.ctx) { Debug.LogError("invalid thread ptr"); yield break; } var context = new DuktapeContext(val.context.vm, thread); bool returnValue; do { returnValue = val.InvokeMemberWithBooleanReturn("next"); var value = val.GetProperty("value"); yield return(value); } while (returnValue); context.Destroy(); }