|
@@ -105,6 +105,10 @@ export function getUser(params) {
|
|
|
export const UnityAction = {
|
|
|
event: {},
|
|
|
on(type, callback) {
|
|
|
+ if (window.vuplex) {
|
|
|
+ alert('----------on----------');
|
|
|
+ addUnityListener();
|
|
|
+ }
|
|
|
if (!UnityAction.event[type]) {
|
|
|
UnityAction.event[type] = [];
|
|
|
}
|
|
@@ -147,16 +151,18 @@ export const UnityAction = {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
-// if (window.vuplex) {
|
|
|
-// window.vuplex.addEventListener('message', (e) => {
|
|
|
-// console.log(
|
|
|
-// '============================getMessageForUnity============================',
|
|
|
-// );
|
|
|
-// const data = JSON.parse(e.data);
|
|
|
-// console.log(data);
|
|
|
-// UnityAction.emit(data.type, data.message);
|
|
|
-// });
|
|
|
-// }
|
|
|
+export function addUnityListener() {
|
|
|
+ if (window.vuplex) {
|
|
|
+ window.vuplex.addEventListener('message', (e) => {
|
|
|
+ console.log(
|
|
|
+ '============================getMessageForUnity============================',
|
|
|
+ );
|
|
|
+ const data = JSON.parse(e.data);
|
|
|
+ console.log(data);
|
|
|
+ UnityAction.emit(data.type, data.message);
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
export function getGlobalData(key) {
|
|
|
let data;
|