uniapp如何将unity项目嵌入到的项目内,并实现数据互通。
6***@qq.com
- 发布:2023-06-05 13:50
- 更新:2024-04-15 20:42
- 阅读:1136
uniapp如何将unity项目嵌入到的项目内,并实现数据互通
分类:uni-app
我们是用离线包,大概代码
// #ifdef APP-PLUS
if (info.platform === "android") {
// @ts-ignore
let abCenter = plus.android
.importClass("com.absir.uniplugin.AbCenter")
// @ts-ignore
.ME();
abCenter.reg(
"message",
plus.android.implements("com.absir.uniplugin.IListener", {
onEvent: function (event: any, paras: string) {
onMessage("$onMessage", paras);
},
})
);
abCenter.reg(
"postMessage",
plus.android.implements("com.absir.uniplugin.IListener", {
onEvent: function (event: any, paras: string) {
onMessage("$postMessage", paras);
},
})
);
vueSelf.$postEvent = function (event: string, paras: string) {
abCenter.postEvent(event, paras);
};
} else {
let abEvent = plus.ios.importClass("AbEvent");
let abCenter = plus.ios.importClass("AbCenter").ME();
plus.ios.invoke(
abCenter,
"reg:listener:",
"message",
// @ts-ignore
plus.ios.implements("IListener", {
"onEvent:": function (event: any) {
//console.log(event.plusIn('hash'))
let paras = event.plusGetAttribute("paras");
if (!paras) {
try {
paras = abEvent.paras(event);
} catch (e) {
console.error(e);
}
}
if (!paras) {
let message = abEvent.refGet("message");
paras = message.plusGetAttribute("paras");
}
//paras = paras ? (plus.ios.invoke(paras, "description") + '') : ''
onMessage("$onMessage", paras);
},
})
);
plus.ios.invoke(
abCenter,
"reg:listener:",
"postMessage",
// @ts-ignore
plus.ios.implements("IListener", {
"onEvent:": function (event: any) {
let paras = event.plusGetAttribute("paras");
if (!paras) {
try {
paras = abEvent.paras(event);
} catch (e) {
console.error(e);
}
}
if (!paras) {
let message = abEvent.refGet("postMessage");
paras = message.plusGetAttribute("paras");
}
//paras = paras ? (plus.ios.invoke(paras, "description") + '') : ''
onMessage("$postMessage", paras);
},
})
);
vueSelf.$postEvent = function (event: string, paras: string) {
// @ts-ignore
plus.ios.invoke(abCenter, "postEvent:paras:", event, paras);
};
}
6***@qq.com (作者)
把unity导出源码格式,通过android studio生成离线包吗
2023-06-05 14:44
4***@qq.com
回复 6***@qq.com: https://ask.dcloud.net.cn/article/40837
2023-11-09 10:23