void OnDestroy() { if (_instance != null) { _instance.InvokeMember("OnDestroy"); _instance = null; } }
public DuktapeObject SetBridge(DuktapeObject obj) { _instance = obj; _instance.InvokeMember("Awake"); if (enabled) { _instance.InvokeMember("OnEnable"); } return(obj); }
public static void duk_push_classvalue(IntPtr ctx, DuktapeObject o) { if (o == null) { DuktapeDLL.duk_push_null(ctx); return; } if (!o.Push(ctx)) { DuktapeDLL.duk_push_null(ctx); } }
public static bool duk_get_classvalue(IntPtr ctx, int idx, out DuktapeObject o) { object obj; if (duk_get_cached_object(ctx, idx, out obj)) { if (obj is DuktapeObject) { o = (DuktapeObject)obj; return(true); } } if (DuktapeDLL.duk_is_object(ctx, idx)) { DuktapeDLL.duk_dup(ctx, idx); var refid = DuktapeDLL.duk_unity_ref(ctx); o = new DuktapeObject(ctx, refid); return(true); } o = null; return(false); }
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(); }
public static Coroutine StartCoroutine(this MonoBehaviour mb, DuktapeObject val) { return(mb.StartCoroutine(DuktapeCoroutineRun(val))); }