creator 2.4.3 底层传递Texture2D到js层,得到空对象

平台:IOS 直接上代码
native层:

NSData* imageData = UIImageJPEGRepresentation(img, 0.7f);  //img是一个UIImage对象
cocos2d::Image* ccimg = new cocos2d::Image();
ccimg->initWithImageData((const unsigned char*)imageData.bytes, imageData.length);
cocos2d::renderer::Texture::Options opt;
cocos2d::renderer::Texture::Image timg;
timg.data = ccimg->getData();
timg.length = ccimg->getDataLen();
opt.images.push_back(timg);
opt.width = ccimg->getWidth();
opt.height = ccimg->getHeight();
opt.premultiplyAlpha = ccimg->hasPremultipliedAlpha();
opt.hasMipmap = ccimg->getNumberOfMipmaps()>0;
const cocos2d::Image::PixelFormatInfo &info = ccimg->getPixelFormatInfo();
opt.bpp = info.bpp;
opt.compressed = info.compressed;
opt.glInternalFormat = info.internalFormat;
opt.glFormat = info.format;
opt.glType = info.type;
cocos2d::renderer::Texture2D* rt2d = new (std::nothrow) cocos2d::renderer::Texture2D();
rt2d->init(cocos2d::renderer::DeviceGraphics::getInstance(), opt);
ccimg->release();
se::AutoHandleScope hs;
se::ValueArray args;
args.push_back(se::Value());
bool result = native_ptr_to_seval<cocos2d::renderer::Texture2D>((cocos2d::renderer::Texture2D*)rt2d, &args[0]);
assert(args[0].isObject());
rt2d->release();
if (!result) {
    NSLog(@"natvive_ptr_to_seval error!");
    return;
}
se::Object* globalObj = se::ScriptEngine::getInstance()->getGlobalObject();
se::Value f;
globalObj->getProperty("onCameraFrame", &f);
assert(f.toObject()->isFunction());
bool success = f.toObject()->call(args, nullptr);
if (!success) {
    se::ScriptEngine::getInstance()->clearException();
}

js层:
window.onCameraFrame = function(asset) {
console.log(JSON.stringify(asset)); //此处输出 “{}” 空对象
}

请问大神,我是不是哪里写错了,搞了几天了都

2赞

大老搞定了没