瀏覽代碼

修复UnityAction没有接收消息

xujunjie 1 年之前
父節點
當前提交
29112de53d
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      src/utils/utils.js

+ 9 - 0
src/utils/utils.js

@@ -144,6 +144,15 @@ 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 getGlobalData(key) {
   let data;
   try {