基于WebUI插件在UE中内嵌Vue页面并通信

1,587 阅读1分钟

webui安装

方法一:在项目下面新建一个Plugins文件夹,将WebUI三个相关的包丢进去

image-20240426162618179.png

方法二:安装到虚幻引擎中

image-20240423180620678.png

image-20240423180641131.png

使用

前端内嵌到视口中

image.png

image-20240425144120813.png

image-20240426171243447.png

image-20240426170018995.png

设置锚点为全屏,偏移都设为0,指定一下初始访问的URL

如果是想访问文件,切换到图表如下

image-20240426170123161.png

打开关卡蓝图

image-20240426170239890.png

页面与UE通信

1.在index.html中添加下面代码

<script type="text/javascript">
        "object"!=typeof ue||"object"!=typeof ue.interface?("object"!=typeof ue&&(ue={}),ue.interface={},ue.interface.broadcast=function(e,t){if("string"==typeof e){var o=[e,""];void 0!==t&&(o[1]=t);var n=encodeURIComponent(JSON.stringify(o));"object"==typeof history&&"function"==typeof history.pushState?(history.pushState({},"","#"+n),history.pushState({},"","#"+encodeURIComponent("[]"))):(document.location.hash=n,document.location.hash=encodeURIComponent("[]"))}}):function(e){ue.interface={},ue.interface.broadcast=function(t,o){"string"==typeof t&&(void 0!==o?e.broadcast(t,JSON.stringify(o)):e.broadcast(t,""))}}(ue.interface),(window.ue5=ue.interface.broadcast);
</script>

2.js发送到ue

前端发送

image-20240426170747298.png

第一个参数为函数名,第二个参数为数据

ue接收

image-20240426170918514.png

image-20240426171107244.png

前端发送,ue相应回调函数

image-20240426171610105.png

image-20240426171645135.png

image-20240426171701786.png

callbackTestCall需要与前端的对应起来

3. ue发送到js

    同回调,触发事件调用Call