ue-webview-bridge-vite
v1.0.0
Published
Vite plugin for UE WebView Bridge - Automatically integrate UE WebView bridge functionality at build time
Maintainers
Readme
ue-webview-bridge-vite
UE WebView Bridge 的 Vite 插件,用于在构建时自动集成 UE WebView 桥接功能。
📦 安装
同时安装核心库和 Vite 插件:
npm install ue-webview-bridge
npm install ue-webview-bridge-vite -D🚀 快速开始
1. 配置 Vite 插件
在 vite.config.ts 中配置插件:
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import ueWebViewBridge from 'ue-webview-bridge-vite';
export default defineConfig({
plugins: [vue(), ueWebViewBridge()],
});2. 使用 API
import { sendToGame, registerGameInterface } from 'ue-webview-bridge';
// 发送消息到 UE
sendToGame('PlayerAction', { action: 'jump' });
// 接收来自 UE 的消息
registerGameInterface('OnGameEvent', (data) => {
console.log('收到游戏事件:', data);
});✨ 功能特性
1. 资源路径优化
自动配置资源路径,确保在 UE WebView 中正确加载所有资源文件。
2. 兼容性保证
确保构建产物能够在 UE 内置浏览器中正常运行,无需额外配置。
3. 开箱即用
零配置,安装即可使用,插件会自动处理所有必要的构建优化。
📋 配置选项
插件采用零配置设计,开箱即用,无需任何额外配置。
🎯 使用场景
此插件适用于以下场景:
- 使用 Vite 构建的 Vue/React/Svelte 等项目
- 需要在 Unreal Engine 的 WebView 中运行的 Web 应用
- 需要与 UE 进行双向通信的前端项目
📦 依赖关系
Dependencies
@vitejs/plugin-legacy- 提供旧版浏览器支持
Peer Dependencies
vite- 支持版本 ^5.0.0 || ^6.0.0 || ^7.0.0
🔗 相关项目
- ue-webview-bridge - 核心库,提供运行时 API
📝 注意事项
- 自动路径处理: 插件会自动处理资源路径,确保在 UE 中正确加载
- 浏览器兼容: 构建产物已针对 UE 内置浏览器进行优化
- 必须同时安装: 需要同时安装
ue-webview-bridge核心库和本插件
📄 许可证
GPL-3.0 © kongziming
