File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Game Frame X Web View
2+
3+ ## 介绍
4+
5+ ` Game Frame X Web View ` 是一个为 [ Game Frame X] ( https://gameframex.doc.alianblank.com ) 游戏框架提供的 Web View 组件。它允许您在 Unity 游戏中嵌入和显示 Web 内容。
6+
7+ 本组件是对 [ gree/unity-webview] ( https://github.com/gree/unity-webview ) 的封装,提供了更简洁的 API 和更方便的集成方式。
8+
9+ ## 功能
10+
11+ * 在 Unity 游戏中显示 Web 页面
12+ * 通过 C# 与 JavaScript 进行交互
13+ * 支持全屏显示
14+ * 支持 Android 和 iOS 平台
15+
16+ ## 安装
17+
18+ 1 . 在 Unity 编辑器中打开 ` Package Manager `
19+ 2 . 点击 ` + ` 号, 选择 ` Add package from git URL... `
20+ 3 . 输入 ` https://github.com/gameframex/com.gameframex.unity.webview.git `
21+ 4 . 点击 ` Add `
22+
23+ ## 如何使用
24+
25+ 1 . 在您的场景中创建一个新的空 ` GameObject `
26+ 2 . 将 ` WebViewComponent ` 附加到该 ` GameObject `
27+ 3 . 在 ` Inspector ` 视图中,为 ` WebViewComponent ` 选择一个 ` IWebViewManager ` 的实现。默认情况下,框架会自动根据平台选择合适的实现。
28+ 4 . 在您的代码中获取 ` WebViewComponent ` 的实例
29+ 5 . 调用 ` Show(url) ` 方法来显示一个 Web 页面
30+
31+ ``` csharp
32+ using GameFrameX .WebView .Runtime ;
33+ using UnityEngine ;
34+
35+ public class Example : MonoBehaviour
36+ {
37+ void Start ()
38+ {
39+ var webView = FindObjectOfType <WebViewComponent >();
40+ webView .Show (" https://gameframex.doc.alianblank.com" );
41+ }
42+ }
43+ ```
44+
45+ ## API
46+
47+ ### ` void Show(string url) `
48+
49+ 显示一个 Web 视图并加载指定的 URL。
50+
51+ ### ` void Hide() `
52+
53+ 隐藏 Web 视图。
54+
55+ ### ` void MakeFullScreen() `
56+
57+ 将 Web 视图设置为全屏。
58+
59+ ### ` void ExecuteJavaScript(string javaScript) `
60+
61+ 在当前加载的 Web 页面上执行 JavaScript 代码。
62+
63+ ## 贡献
64+
65+ 欢迎通过 Pull Request 或 Issue 为本项目做出贡献。
66+
67+ ## 许可证
68+
69+ 本仓库遵循 [ MIT] ( LICENSE ) 许可证。
You can’t perform that action at this time.
0 commit comments