Exemplo n.º 1
0
        public void OnBeforeSerialize()
        {
            if (_onBeforeSerializeValid)
            {
                if (_properties == null)
                {
                    _properties = new JSBehaviourProperties();
                }
                else
                {
                    _properties.Clear();
                }

                unsafe
                {
                    var argv = stackalloc[] { Binding.Values.js_push_var(_ctx, _properties) };
                    var rval = JSApi.JS_Call(_ctx, _onBeforeSerializeFunc, _this_obj, 1, argv);
                    JSApi.JS_FreeValue(_ctx, argv[0]);
                    if (rval.IsException())
                    {
                        _ctx.print_exception();
                    }
                    JSApi.JS_FreeValue(_ctx, rval);
                }

                if (_properties.Count == 0)
                {
                    _properties = null;
                }
            }
        }
Exemplo n.º 2
0
        public void _OnScriptingAfterDeserialize()
        {
            if (_onAfterDeserializeValid)
            {
                if (_properties == null)
                {
                    _properties = new JSBehaviourProperties();
                }

                unsafe
                {
                    var argv = stackalloc[] { Binding.Values.js_push_var(_ctx, _properties) };
                    var rval = JSApi.JS_Call(_ctx, _onAfterDeserializeFunc, _this_obj, 1, argv);
                    JSApi.JS_FreeValue(_ctx, argv[0]);
                    if (rval.IsException())
                    {
                        _ctx.print_exception();
                    }
                    JSApi.JS_FreeValue(_ctx, rval);
                }
            }
        }
    }