コード例 #1
0
        void SetupJavaScriptClassInstance()
        {
            if (jsInstance.HasValue)
            {
                return;
            }

            Engine.With(() => {
                JavaScriptValue clazz = Engine.Import(
                    moduleSpecifier,
                    (path) => { // file changed callback
                    Debug.Log("reloading " + moduleSpecifier);
                    JavaScript.API.UpdateHelper.addOneUpdateHook(() => {
                        this.Reload();
                    });
                }
                    ).GetProperty("default");
                clazz.AddRef();
                // jsClass = clazz;

                JavaScriptValue instance = clazz.ConstructObject(
                    JavaScriptValue.Undefined,
                    Bridge.CreateExternalWithPrototype(this)
                    );
                instance.AddRef();
                jsInstance = instance;
            });
        }