Skip to content

Latest commit

 

History

History
95 lines (66 loc) · 2.61 KB

File metadata and controls

95 lines (66 loc) · 2.61 KB
Game Frame X Logo

Game Frame X Web View

License Version Unity Version Documentation

独立游戏前后端一体化解决方案 · 独立游戏开发者的圆梦大使


文档 · 快速开始 · QQ群: 467608841 / 233840761


English | 简体中文 | 繁體中文 | 日本語 | 한국어

项目简介

Game Frame X Web View 是一个为 Game Frame X 游戏框架提供的 Web View 组件。它允许您在 Unity 游戏中嵌入和显示 Web 内容。

本组件是对 gree/unity-webview 的封装,提供了更简洁的 API 和更方便的集成方式。

功能

  • 在 Unity 游戏中显示 Web 页面
  • 通过 C# 与 JavaScript 进行交互
  • 支持全屏显示
  • 支持 Android 和 iOS 平台

安装

安装

编辑 Unity 项目的 Packages/manifest.json,添加 scopedRegistries 部分:

{
  "scopedRegistries": [
    {
      "name": "GameFrameX",
      "url": "https://gameframex.upm.alianblank.uk",
      "scopes": [
        "com.gameframex"
      ]
    }
  ]
}

scopes 控制哪些包通过此注册表解析。只有以 com.gameframex 开头的包才会从这个注册表获取。

Then add the package to dependencies:

{
  "dependencies": {
    "com.gameframex.unity.webview": "1.0.0"
  }
}

使用说明

using GameFrameX.WebView.Runtime;
using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        var webView = FindObjectOfType<WebViewComponent>();
        webView.Show("https://gameframex.doc.alianblank.com");
    }
}

API

  • Show(string url) - 显示 Web 视图并加载指定 URL
  • Hide() - 隐藏 Web 视图
  • MakeFullScreen() - 将 Web 视图设置为全屏
  • ExecuteJavaScript(string javaScript) - 执行 JavaScript 代码

开源协议

本仓库遵循 MIT 许可证。